RE: [sqlite] Re: Sqlite3_prepare() question
> > "SELECT *, Table1.ID AS _ID FROM Table1 LEFT JOIN Table2 ON > > Table2.ID=Table1.ID WHERE _ID=?1" and bind only the _ID > parameter in > > this case? > > This would work. > > > The issue is that I don't know beforehand what can be in that WHERE > > statement and how many parameters it might have - it's formed > > elsewhere. > > Parameters cannot change a structure of the query. If you > need to do this, then you have to build the query in a > string, with sprintf or similar, then prepare. Of course you > can still use parameters in place of any literals you may > need in the query. Thank you for a quick reply - I was afraid that it wouldn't work like that :) I guess I'll need to revise the way these statements are built, which might be a good thing in the end after all. Dennis > > Igor Tandetnik > > > -- > --- > To unsubscribe, send email to [EMAIL PROTECTED] > -- > --- > > - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Re: Sqlite3_prepare() question
Dennis Volodomanov wrote: I'm converting sqlite3_mprintf() into sqlite3_prepare_v2() and the SQL for that was like this: "SELECT *, Table1.ID AS _ID FROM Table1 LEFT JOIN Table2 ON Table2.ID=Table1.ID %s" and I was putting a "WHERE _ID=1", for example, in the %s Now, I'm trying to do the same: "SELECT *, Table1.ID AS _ID FROM Table1 LEFT JOIN Table2 ON Table2.ID=Table1.ID ?1" and then sqlite3_bind_text No, you can't do that. You can only use a parameter in place of, say, an integer constant or a string literal. You can't replace whole SQL fragments. My question is, can I do it like this or do I have to something like: "SELECT *, Table1.ID AS _ID FROM Table1 LEFT JOIN Table2 ON Table2.ID=Table1.ID WHERE _ID=?1" and bind only the _ID parameter in this case? This would work. The issue is that I don't know beforehand what can be in that WHERE statement and how many parameters it might have - it's formed elsewhere. Parameters cannot change a structure of the query. If you need to do this, then you have to build the query in a string, with sprintf or similar, then prepare. Of course you can still use parameters in place of any literals you may need in the query. Igor Tandetnik - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Sqlite3_prepare() question
Hello all, Maybe what I want is not possible or maybe I'm just not doing it right, so I wanted to ask... Thank you in advance for your answers. I'm converting sqlite3_mprintf() into sqlite3_prepare_v2() and the SQL for that was like this: "SELECT *, Table1.ID AS _ID FROM Table1 LEFT JOIN Table2 ON Table2.ID=Table1.ID %s" and I was putting a "WHERE _ID=1", for example, in the %s Now, I'm trying to do the same: "SELECT *, Table1.ID AS _ID FROM Table1 LEFT JOIN Table2 ON Table2.ID=Table1.ID ?1" and then sqlite3_bind_text(pStmt,1,"WHERE _ID=1",-1,SQLITE_STATIC), but it returns a NULL pStmt and says that the syntax is wrong near ?1 My question is, can I do it like this or do I have to something like: "SELECT *, Table1.ID AS _ID FROM Table1 LEFT JOIN Table2 ON Table2.ID=Table1.ID WHERE _ID=?1" and bind only the _ID parameter in this case? The issue is that I don't know beforehand what can be in that WHERE statement and how many parameters it might have - it's formed elsewhere. Thanks again for reading. Best regards, Dennis - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] not sqlite question, but design ? for IoMethod & os_????.c
Can you explain the IoMethod and IoFile from the os.h ??? I see the follwing in the code... #if OS_UNIX #define sqlite3OsOpenReadWrite sqlite3UnixOpenReadWrite . #endif #if OS_WIN #define sqlite3OsOpenReadWrite sqlite3WinOpenReadWrite #if OS_OS2 #define sqlite3OsOpenReadWrite sqlite3Os2OpenReadWrite etc... followed by IoMethod and IoFile type and struct delcarations. I understand the the defines are used as subtitutions in the pre processor for calls. int sqlite3OsOpenReadWrite(const char*, OsFile**, int*); --- Really becomes an instance of one of the above specific calls such as : sqlite3UnixOpenReadWrite My questions is why are the pointers stored in IxMethod ??? Since really the ifdefs above define the various interfaces to the operating system specific calls. why keep reference pointers to the functions inside of IxMethod ??? I'm building an interface into os system calls such as open/fopen read/fread and i'd like to be able to have the calling code dynamically set up which interace to use, so I'm trying to get a handle on the above code as a roadmap... Thanks, Ken
Re: [sqlite] custom collation problem with delphi
Hello jp, >Thanks Ralf, that seems to be more stable - the process is not crashing >anymore (ran it twice, no errors). Glad to read this! >Pardon my ignorance - I am still using cdecl, how can I use 'register'? >Doesn't sqlite expects cdecl? There is no ignorance involved: The sqlite3.dll of course expects cdecl. It is only DISQLite3 which does not require cdecl but allows to use Delphi's default register calling convention. DISQLite3 is a special build of sqlite3 specially targeted at Delphi. Since it does not use the sqlite3.dll (it compiles straight into applications), it was possible to apply register calling conventions throughout (internally as well as for the external API). Register was choosen because according to the Delphi help "The default register convention is the most efficient, since it usually avoids creation of a stack frame." My tests have confirmed this to be true for DISQLite3. It is available from http://www.yunqa.de/delphi/sqlite3/. Regards, Ralf - To unsubscribe, send email to [EMAIL PROTECTED] -
RE: [sqlite] Lemon example
URL didn't work for me either, but you'll see what you want at the root (at least today): http://www.cesarodas.com/ -Original Message- From: Cesar Rodas [mailto:[EMAIL PROTECTED] Sent: Monday, March 05, 2007 10:44 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] Lemon example The URL is ok, I opened here... try again and let me know if you could not and I will email you the content of the example. On 05/03/07, Clay Dowling <[EMAIL PROTECTED]> wrote: > > > Cesar Rodas wrote: > > Here is Lemon tutorial. Shows how to make a calculator with a > feature of > > use Parents "()" in math expression. > > > http://www.cesarodas.com/2007/03/creating-basic-calculator-with-lemon. > html > . > > > > The author disclaims the copyright of the calculator. > > There's a problem with that URL. Could you check it, or check your > server? I'd love to read the example, but my browser steadfastly > refuses to resolve an address for cesarodas.com > > Clay Dowling > -- > Simple Content Management > http://www.ceamus.com > > > > -- > --- To unsubscribe, send email to > [EMAIL PROTECTED] > > -- > --- > > -- Cesar Rodas http://www.sf.net/projects/pagerank (The PageRank made easy...) http://www.sf.net/projects/fastfs ( The Fast File System) Mobile Phone: 595 961 974165 Phone: 595 21 645590 [EMAIL PROTECTED] [EMAIL PROTECTED] This email was sent to you by Reuters, the global news and information company. To find out more about Reuters visit www.about.reuters.com Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Reuters Limited. Reuters Limited is part of the Reuters Group of companies, of which Reuters Group PLC is the ultimate parent company. Reuters Group PLC - Registered office address: The Reuters Building, South Colonnade, Canary Wharf, London E14 5EP, United Kingdom Registered No: 3296375 Registered in England and Wales - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Lemon example
The URL is ok, I opened here... try again and let me know if you could not and I will email you the content of the example. On 05/03/07, Clay Dowling <[EMAIL PROTECTED]> wrote: Cesar Rodas wrote: > Here is Lemon tutorial. Shows how to make a calculator with a feature of > use Parents "()" in math expression. > http://www.cesarodas.com/2007/03/creating-basic-calculator-with-lemon.html . > > The author disclaims the copyright of the calculator. There's a problem with that URL. Could you check it, or check your server? I'd love to read the example, but my browser steadfastly refuses to resolve an address for cesarodas.com Clay Dowling -- Simple Content Management http://www.ceamus.com - To unsubscribe, send email to [EMAIL PROTECTED] - -- Cesar Rodas http://www.sf.net/projects/pagerank (The PageRank made easy...) http://www.sf.net/projects/fastfs ( The Fast File System) Mobile Phone: 595 961 974165 Phone: 595 21 645590 [EMAIL PROTECTED] [EMAIL PROTECTED]
Re: [sqlite] Lemon example
Cesar Rodas wrote: > Here is Lemon tutorial. Shows how to make a calculator with a feature of > use Parents "()" in math expression. > http://www.cesarodas.com/2007/03/creating-basic-calculator-with-lemon.html. > > The author disclaims the copyright of the calculator. There's a problem with that URL. Could you check it, or check your server? I'd love to read the example, but my browser steadfastly refuses to resolve an address for cesarodas.com Clay Dowling -- Simple Content Management http://www.ceamus.com - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Lemon example
Here is Lemon tutorial. Shows how to make a calculator with a feature of use Parents "()" in math expression. http://www.cesarodas.com/2007/03/creating-basic-calculator-with-lemon.html. The author disclaims the copyright of the calculator. -- Cesar Rodas http://www.sf.net/projects/pagerank (The PageRank made easy...) http://www.sf.net/projects/fastfs ( The Fast File System) Mobile Phone: 595 961 974165 Phone: 595 21 645590 [EMAIL PROTECTED] [EMAIL PROTECTED]
Re: [sqlite] custom collation problem with delphi
Thanks Ralf, that seems to be more stable - the process is not crashing anymore (ran it twice, no errors). Pardon my ignorance - I am still using cdecl, how can I use 'register'? Doesn't sqlite expects cdecl? jp --- Ralf Junker <[EMAIL PROTECTED]> wrote: > Hello jp, > > with DISQLite3, I use the the following colation > callback function without problems: > > function SQLite3_Compare_System_NoCase_Ansi( > UserData: Pointer; > l1: Integer; const s1: Pointer; > l2: Integer; const s2: Pointer): Integer; > begin > Result := CompareStringA(LOCALE_SYSTEM_DEFAULT, > NORM_IGNORECASE, s1, l1, s2, l2) - 2; > end; > > This function should be functionally equivalent to > your implementation, but accesses the Win32 API > directly. Also, it does not implicitly convert the > PChar pointers to AnsiStrings like your call > "copy(B,1,lenB);" implicitly does. > > Notes: > > * The above function is not declared as "cdecl" > because DISQLite3 uses the faster "register" calling > convention instead. > > * The above function (just as yours) does not treat > UTF-8 sequences properly. You might want to consider > a WideString function instead, depending on the data > you are processing. > > Regards, > > Ralf > Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Re: Re: Why it does not work properly?
woj <[EMAIL PROTECTED]> wrote: Thank's for your reply. I didnt realize this, but of course it is logical. So, now I think how to select not only one row (what seems to be easy) but set of rows from previously mentioned data where only these rows are picked up with largest Data value for each IdMat, so correct version of querry: SELECT Mieszalnia.IdMat, Mieszalnia.Partia, Mieszalnia.Kont, Mieszalnia.Uk, Max(Mieszalnia.Data) FROM Mieszalnia GROUPED BY Mieszalnia.IdMat; I'm not sure if this was meant as a question or a statement. In case it was in fact a question, consider this: select IdMat, ..., Data from Mieszalnia m1 where not exists ( select * from Mieszalnia m2 where m2.IdMat = m1.IdMat and m2.Data > m1.Data ); Igor Tandetnik - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Crosscompiling Problem
Hi, I followed to below order to crosscompile the source but the end I get some undefined reference errors. Do you have any idea how to solve this problem. Note: There is no problem when I try to crosscompile ver. 2.8.17. Every thing works great. ** rm tclsqlite.c PATH=/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/arm-linux/bin/:$PATH for i in *.c; do arm-gcc -O -c $i; done rm shell.o ar cr libsqlite.a *.o ranlib libsqlite.a arm-gcc -o sqlite shell.c libsqlite.a libsqlite.a(os_unix.o)(.text+0xf6c): In function `sqlite3UnixDlopen': : undefined reference to `dlopen' libsqlite.a(os_unix.o)(.text+0xf78): In function `sqlite3UnixDlsym': : undefined reference to `dlsym' libsqlite.a(os_unix.o)(.text+0xf84): In function `sqlite3UnixDlclose': : undefined reference to `dlclose' collect2: ld returned 1 exit status ** Thanks and best regards. F. Ugurtan Erdem - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: Why it does not work properly?
Thank's for your reply. I didnt realize this, but of course it is logical. So, now I think how to select not only one row (what seems to be easy) but set of rows from previously mentioned data where only these rows are picked up with largest Data value for each IdMat, so correct version of querry: SELECT Mieszalnia.IdMat, Mieszalnia.Partia, Mieszalnia.Kont, Mieszalnia.Uk, Max(Mieszalnia.Data) FROM Mieszalnia GROUPED BY Mieszalnia.IdMat; IdW IdMat Partia Kont Uk Data 12 1 1179760 136832 F16 1171951258 12 2 1176865 315060 F21 1171915832 13 3 1177504 318272 F9 1171538132 15 4 1153571 277827 F15 1171437632 16 5 1153437 062022 F16 1171368032 17 6 1185543 323063 SL1 1171978232 18 7 1156166 077690 F3 1169082032 19 8 1156269 075825 F8 116832 20 9 1166581 101109 F11 1168014032 21 10 1099211 081868 F17 1166497232 22 11 1084774 054445 F20 1169530232 23 12 1143641 157155 F24 1171485032 24 13 1180275 179329 SF3 1169521232 25 14 1102698 150010 SF4 1171494000 26 15 1130267 266647 SF5 1170282600 27 6 11 11 sl1 1172135769 28 6 3 3 sl1 1172054927 woj <[EMAIL PROTECTED]> wrote: Now, when I run a query: SELECT Mieszalnia.IdMat, Mieszalnia.Partia, Mieszalnia.Kont, Mieszalnia.Uk, Max(Mieszalnia.Data) FROM Mieszalnia; I always get: IdMat Partia KontUk Data 6 3 3 sl1 1172135769 In this result there is indeed max from Data field but rest of the fields fit not... When a SELECT statement involves aggregate functions, all column references in the SELECT must be either parameters to some aggregate functions, or else be also mentioned in GROUP BY clause. SQLite allows, as an extension, departure from this rule, but the row from which values for columns that are neither aggregated nor grouped by are taken is random and unpredictable. Specifically, in the query you show, there's no guarantee that values for IdMat, Partia and so on would be taken from the same row from which Max(Data) comes. Even if SQLite really wanted to help you out here, it is impossible in general. Consider: SELECT IdMat, Max(Data), Min(Data) from Mieszalnia; Which value of IdMat would you expect to see in response to such a query? Should it come from the row with the largest value of Data, with the smallest, or some other? There are many ways to formulate the query you seem to want. E.g. select IdMat, Data from Mieszalnia order by Data desc limit 1; select IdMat, Data from Mieszalnia where Data = (select max(Data) from Mieszalnia); Igor Tandetnik - To unsubscribe, send email to [EMAIL PROTECTED] - -- Używam klienta poczty Opera Mail: http://www.opera.com/mail/ - To unsubscribe, send email to [EMAIL PROTECTED] -