Sqlite problem with purebasic

Just starting out? Need help? Post your questions and find answers here.
loulou2522
Enthusiast
Enthusiast
Posts: 550
Joined: Tue Oct 14, 2014 12:09 pm

Sqlite problem with purebasic

Post by loulou2522 »

Who can help me get around this SQL instruction problem in Purebasic?
The purpose of this instruction is to compare two files in a “ZRUM” area and display the records from file one that do not have a match in the common RUM area of file two.
Here is the instruction

Code: Select all

   DatabaseQuery(openingDatabase::opening, ‘Select ZRUM, ZIBAN, ZNOM FROM MANDAT Where  ZRUM  Not IN (Select DISTINCT(RUMDBT) from CLIENT)  and ZIBAN  in (SELECT DISTINCT IBANDBT From client)  and ZNOM  in (SELECT DISTINCT NOMDBT From client)’)
This instruction returns the correct result using an SQLite editor but returns an empty record with PureBasic.

ISorry but i can't transmit file because it's confidential files
miso
Enthusiast
Enthusiast
Posts: 466
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Sqlite problem with purebasic

Post by miso »

I can't say I know the answer, but maybe it's just a ";" if its sqlite.

Can you try this?

Code: Select all

DatabaseQuery(openingDatabase::opening, "SELECT zrum, ziban, znom FROM mandat WHERE zrum NOT IN (SELECT DISTINCT(RUMDBT) FROM client) AND ziban IN (SELECT DISTINCT IBANDBT FROM client) AND znom  IN (SELECT DISTINCT NOMDBT FROM client);")
loulou2522
Enthusiast
Enthusiast
Posts: 550
Joined: Tue Oct 14, 2014 12:09 pm

Re: Sqlite problem with purebasic

Post by loulou2522 »

thanks miso ,
problem is resolved , it's work perfectly
miso
Enthusiast
Enthusiast
Posts: 466
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Sqlite problem with purebasic

Post by miso »

No problem, your welcome.
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Re: Sqlite problem with purebasic

Post by ebs »

I'm glad that miso's solution worked, but I don't think it's because of the semicolon at the end of the SQL statement.
I use SQLite extensively without the trailing semicolon and it works fine.

I think the reason miso's code worked is that he used double quotes (") around the SQL statement, which is necessary for a string in PureBasic. Your code used single quotes (') around the string, which I think should produce an error.

What happens if you just change the quote characters?
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 459
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: Sqlite problem with purebasic

Post by Mindphazer »

@ebs, you're probably right !
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
loulou2522
Enthusiast
Enthusiast
Posts: 550
Joined: Tue Oct 14, 2014 12:09 pm

Re: Sqlite problem with purebasic

Post by loulou2522 »

I have another problem because even if the instruction works fine, I'm stuck because I also need to retrieve the value of rumdbt in the client file in the same instruction, and that's where I'm lost.
User avatar
skywalk
Addict
Addict
Posts: 4215
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Sqlite problem with purebasic

Post by skywalk »

Use a db browser to verify your SQL syntax.
I use db browser for sqlite.
You can attach the 2nd db file in a separate query and then refer to its tables.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
loulou2522
Enthusiast
Enthusiast
Posts: 550
Joined: Tue Oct 14, 2014 12:09 pm

Re: Sqlite problem with purebasic

Post by loulou2522 »

HI skywalk
Thanks for your answers? I am not familiar with attachdabase. Can you give me anexample
Thanks in advance
Post Reply