[sqlite] Copy records from one DB to another

2007-04-24 Thread Yuriy Martsynovskyy
What is the best way to copy records between tables located in different DB files? Both DBs have completely the same structure. I need to add records from table in DB1 to table in DB2. Logically something like this: INSERT INTO .table1 SELECT * FROM .table1

[sqlite] CREATE TABLE fails if SQL starts with comment

2007-04-27 Thread Yuriy Martsynovskyy
When I execute the SQL code below on a newly created DB file I get an error 'table Tab already exists', and it creates a table -- comment CREATE TABLE Tab(ID); Code below works without error messages: CREATE TABLE Tab(ID);

Re: [sqlite] CREATE TABLE fails if SQL starts with comment

2007-04-27 Thread Yuriy Martsynovskyy
Update to version version 3.3.17 has solved the problem. The issue existed in version 3.3.14 - To unsubscribe, send email to [EMAIL PROTECTED] -

[sqlite] Select the top N rows from each group

2007-05-11 Thread Yuriy Martsynovskyy
I need to select top 2 (or N) most expensive fruits of each type from this table: +++---+ | type | variety| price | +++---+ | apple | gala | 2.79 | | apple | fuji | 0.24 | | apple | limbertwig | 2.87 | | orange | valencia |

Re: [sqlite] Re: Select the top N rows from each group

2007-05-11 Thread Yuriy Martsynovskyy
Igor, select * from (select * from fruits where type = 'apple' order by price limit 2) union all select * from (select * from fruits where type = 'orange' order by price limit 2) SQlite allows only one LIMIT clause per query, that is applied to the final resultset

Re: [sqlite] Re: Re: Select the top N rows from each group

2007-05-11 Thread Yuriy Martsynovskyy
Igor, That's not quite true. ORDER BY and LIMIT are allowed in sub-selects, as is the case here. This query works, I tested it before posting. Your query returns 2 records instead of 4. I'm testing it on SQLite v3.3.10

Re: [sqlite] Re: Re: Re: Select the top N rows from each group

2007-05-11 Thread Yuriy Martsynovskyy
Igor, Your query works now and returns 4 records. that was my mistake probably. Thank you! - To unsubscribe, send email to [EMAIL PROTECTED] -

[sqlite] Conditional execution

2007-09-11 Thread Yuriy Martsynovskyy
Is it possible to write a conditional SQL code like this? CASE expression does not seem to work here IF (exists (Select * from tab1)) THEN Insert into tab2 select * from tab3 ELSE Insert into tab2 select * from tab4 ENDIF;

Re: [sqlite] passing C variable in query

2007-09-13 Thread Yuriy Martsynovskyy
Hi Nishit, > can anyone tell me the syntax of passing a C variable in a query. > i have taken a variable as float hd= 2000.0; > how it'll be passed in a query and what'll be the syntax of that query. First use sprintf () to insert your variable into SQL code. Then execute the resulting SQL

[sqlite] LIKE operator syntax for white space

2007-10-23 Thread Yuriy Martsynovskyy
How do I filter out records that contain WHITE SPACE in a field or have this field empty? For example: select * from mytable where fld <> "" and fld LIKE . - To unsubscribe, send email to [EMAIL PROTECTED]

Re: [sqlite] LIKE operator syntax for white space

2007-10-24 Thread Yuriy Martsynovskyy
These only strip lines with Space characters. I need also to filter out also tabs, carriage returns and all series characters that constitute a white space. - To unsubscribe, send email to [EMAIL PROTECTED]

[sqlite] Database is locked when working in 2 processes

2007-01-16 Thread Yuriy Martsynovskyy
until you close and open the process 2 again. How is such configuration supposed to work in SQLite when we need 1 writer process and 1 or more reader processes? Working on Windows XP SP2 SQLite 3.3.8 with CppSqlite3 wrapper -- Thanks, Yuriy Mar

Re: [sqlite] Database is locked when working in 2 processes

2007-01-16 Thread Yuriy Martsynovskyy
happens after writing is finished. Only when you restart the reader process in can read again. -- Thanks, Yuriy Martsynovskyy - To unsubscribe, send email to [EMAIL PROTECTED] -

Re: [sqlite] Database is locked when working in 2 processes

2007-01-16 Thread Yuriy Martsynovskyy
This issue has been resolved. I did not call sqlite3_finalize() in the reader process and kept the READ lock How to read after the database was written by another process? Reading function should wait until other process finishes writing and unlocks the file. But in our case unlocking never