Re: [sqlite] How do I attach a database from C++? -- RESOLVED

2005-08-19 Thread Greg Stark
The problem was that I'd started a transaction prior to attaching the  
second database.  Apparently that's not legal in SQLite3.


On a related issue, does anyone know if nested transactions are  
planned for SQLite?


Thanks again to all those who tried to help!

-Greg

On Aug 19, 2005, at 10:08 AM, Puneet Kishor wrote:


Greg Stark wrote:


On Aug 19, 2005, at 9:37 AM, Puneet Kishor wrote:


Greg Stark wrote:



Tom,
I appreciate you're help but I'm pretty sure that the semicolon   
has  to be there (well. at least it's required in all the other   
statements  I've written to date -- this one statement is part  
of  a much large  program that's working fine other than for  
this one  ATTACH).
My guess is that SQLite3 doesn't know where to find my  
database,  but  I'm not sure how to tell it where to look.





well, have you tried giving it the full path name to the database?


You may have a good point.  I've been entering the full path the  
same  way as I would in unix ('/Users/bsllc/Development/databases/  
window_5.sdb'), but is this proper syntax for a path within SQLite3?





yeah, that is fine if you are on a Unix box. Change it to the  
Windows path if you are on a Windows box (C:\\foo\\bar\\window_5.mdb).


>('/Users/bsllc/Development/databases/ window_5.sdb')

But you have a space above... (at least that is what seems to me in  
my email.









-Greg
On Aug 19, 2005, at 6:07 AM, Thomas Briggs wrote:




   I think that the semi-colon at the end of the statement is  
what's
causing your problem.  The command shell requires the semi- 
colon  to  mark
the end of a statement; in code, your statement ends at the  
end  of the

string.

   -Tom





-Original Message-
From: Greg Stark [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 7:38 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] How do I attach a database from C++?

I'm having difficulty attaching a database from C++.

Within my code, I'm using an sqlite3_prepare call:

 prepareResult = pSqlBundle->sqlite3_prepare (db_,  
"ATTACH
DATABASE 'window_5.sdb' AS W5;", -1, ,   
);


but it returns an error (i.e., prepareResult comes back as
SQLITE_ERROR).

Just to make sure that there were no problems with the  
databases or

my syntax, I tried the attach command (i.e., ATTACH DATABASE
'window_5.sdb' AS W5;) from the command line, and everything  
worked
fine.  I tried using the full path name for the database- 
filename,

but that didn't work either.

I'm sure it's something simple, but what I'm I doing wrong?

Thanks,
Greg






















Re: [sqlite] SQL for finding non-matching rows

2005-08-19 Thread John LeSueur

Clark Christensen wrote:


I've seen it described here before, but I can't seem to
find it.

select a from t1 where a not in (select b from t2);

will find the resultset I'm looking for, and it seems OK
when the resulting in () list is small (maybe < 1000).  But
it seems less than ideal when the resulting list is large. 
Isn't there a join I can do to accomplish the same a little

more elegantly?

Thanks!

-Clark

 


select a
from t1
   left outer join
   t2 on
   t1.a = t2.b
where
   t2.b is null

John


Re: [sqlite] SQL for finding non-matching rows

2005-08-19 Thread Kurt Welgehausen
> select a from t1 where a not in (select b from t2)

select a from t1 except select b from t2

or (SQLite v3 only)

select a from t1 where not exists
   (select b from t2 where b = a)

Which of these is fastest will probably depend on table
size and indexing; you'll have to try them out.


Regards


[sqlite] SQLite3 Explorer dates

2005-08-19 Thread Clark Christensen
Mike,

If appropriate for a future rev of SQLite3 Explorer (EXP),
I'm requesting an update to the handling of date strings.

Using SQLite3 Explorer (EXP) v1.6 under WinXP, "select
date('2005-08-19')" gives a "not a valid FP number" error.

Using the SQLite3 shell, I get '2005-08-19'.

Maybe I'm mistaken, but shouldn't EXP return the result of
the valid SQLite3 function (a string, in this case)?  It's
the same if I ask for a date string from a field value.
"select date(datefield) from t1" (where datefield is a
julian number), gives a number in EXP, and the expected
date string in the SQLite3 shell.

For what it's worth, strftime() seems to return the
expected date string.  Which is fine, except I'm using EXP
to test my queries during development.  I don't like having
to change to strftime() where the app can work with date()
or datetime()  :-))

Is this a limitation in EXP, or am I missing something?

Thanks!

 -Clark



Re: [sqlite] How do I attach a database from C++?

2005-08-19 Thread Puneet Kishor

Greg Stark wrote:


On Aug 19, 2005, at 9:37 AM, Puneet Kishor wrote:


Greg Stark wrote:


Tom,
I appreciate you're help but I'm pretty sure that the semicolon  has  
to be there (well. at least it's required in all the other  
statements  I've written to date -- this one statement is part of  a 
much large  program that's working fine other than for this one  
ATTACH).
My guess is that SQLite3 doesn't know where to find my database,  
but  I'm not sure how to tell it where to look.




well, have you tried giving it the full path name to the database?



You may have a good point.  I've been entering the full path the same  
way as I would in unix ('/Users/bsllc/Development/databases/ 
window_5.sdb'), but is this proper syntax for a path within SQLite3?





yeah, that is fine if you are on a Unix box. Change it to the Windows 
path if you are on a Windows box (C:\\foo\\bar\\window_5.mdb).


>('/Users/bsllc/Development/databases/ window_5.sdb')

But you have a space above... (at least that is what seems to me in my 
email.










-Greg
On Aug 19, 2005, at 6:07 AM, Thomas Briggs wrote:



   I think that the semi-colon at the end of the statement is what's
causing your problem.  The command shell requires the semi-colon  
to  mark

the end of a statement; in code, your statement ends at the end  of the
string.

   -Tom




-Original Message-
From: Greg Stark [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 7:38 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] How do I attach a database from C++?

I'm having difficulty attaching a database from C++.

Within my code, I'm using an sqlite3_prepare call:

 prepareResult = pSqlBundle->sqlite3_prepare (db_, "ATTACH
DATABASE 'window_5.sdb' AS W5;", -1, ,  );

but it returns an error (i.e., prepareResult comes back as
SQLITE_ERROR).

Just to make sure that there were no problems with the databases or
my syntax, I tried the attach command (i.e., ATTACH DATABASE
'window_5.sdb' AS W5;) from the command line, and everything worked
fine.  I tried using the full path name for the database-filename,
but that didn't work either.

I'm sure it's something simple, but what I'm I doing wrong?

Thanks,
Greg

















Re: [sqlite] How do I attach a database from C++?

2005-08-19 Thread Greg Stark


On Aug 19, 2005, at 9:37 AM, Puneet Kishor wrote:


Greg Stark wrote:


Tom,
I appreciate you're help but I'm pretty sure that the semicolon  
has  to be there (well. at least it's required in all the other  
statements  I've written to date -- this one statement is part of  
a much large  program that's working fine other than for this one  
ATTACH).
My guess is that SQLite3 doesn't know where to find my database,  
but  I'm not sure how to tell it where to look.




well, have you tried giving it the full path name to the database?



You may have a good point.  I've been entering the full path the same  
way as I would in unix ('/Users/bsllc/Development/databases/ 
window_5.sdb'), but is this proper syntax for a path within SQLite3?


-Greg






-Greg
On Aug 19, 2005, at 6:07 AM, Thomas Briggs wrote:



   I think that the semi-colon at the end of the statement is what's
causing your problem.  The command shell requires the semi-colon  
to  mark
the end of a statement; in code, your statement ends at the end  
of the

string.

   -Tom




-Original Message-
From: Greg Stark [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 7:38 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] How do I attach a database from C++?

I'm having difficulty attaching a database from C++.

Within my code, I'm using an sqlite3_prepare call:

 prepareResult = pSqlBundle->sqlite3_prepare (db_, "ATTACH
DATABASE 'window_5.sdb' AS W5;", -1, ,  
);


but it returns an error (i.e., prepareResult comes back as
SQLITE_ERROR).

Just to make sure that there were no problems with the databases or
my syntax, I tried the attach command (i.e., ATTACH DATABASE
'window_5.sdb' AS W5;) from the command line, and everything worked
fine.  I tried using the full path name for the database-filename,
but that didn't work either.

I'm sure it's something simple, but what I'm I doing wrong?

Thanks,
Greg















Re: [sqlite] How do I attach a database from C++?

2005-08-19 Thread Greg Stark


On Aug 19, 2005, at 9:37 AM, Puneet Kishor wrote:


Greg Stark wrote:


Tom,
I appreciate your help but I'm pretty sure that the semicolon has   
to be there (well, at least it's required in all the other  
statements  I've written to date -- this one statement is part of  
a much larger  program that's working fine other than for this one  
ATTACH).
My guess is that SQLite3 doesn't know where to find my database,  
but  I'm not sure how to tell it where to look.




well, have you tried giving it the full path name to the database?


I've tried the full path name, too -- no luck there either...




-Greg
On Aug 19, 2005, at 6:07 AM, Thomas Briggs wrote:



   I think that the semi-colon at the end of the statement is what's
causing your problem.  The command shell requires the semi-colon  
to  mark
the end of a statement; in code, your statement ends at the end  
of the

string.

   -Tom




-Original Message-
From: Greg Stark [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 7:38 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] How do I attach a database from C++?

I'm having difficulty attaching a database from C++.

Within my code, I'm using an sqlite3_prepare call:

 prepareResult = pSqlBundle->sqlite3_prepare (db_, "ATTACH
DATABASE 'window_5.sdb' AS W5;", -1, ,  
);


but it returns an error (i.e., prepareResult comes back as
SQLITE_ERROR).

Just to make sure that there were no problems with the databases or
my syntax, I tried the attach command (i.e., ATTACH DATABASE
'window_5.sdb' AS W5;) from the command line, and everything worked
fine.  I tried using the full path name for the database-filename,
but that didn't work either.

I'm sure it's something simple, but what I'm I doing wrong?

Thanks,
Greg















Re: [sqlite] blocking - busy_timeout vs database is locked(5)

2005-08-19 Thread Ray Mosley
I have somewhat-related questions. 
1) Using the Tcl binding for SQLite 2.8, how do I even obtain the value to 
know the DB is busy?
2) If I use
 db timeout 2000
 won't the application wait until the db is free to access the db? Do I even 
need to know it was once busy if SQLite waits until it can proceed?
 Thanks from a DB rookie.

 On 8/18/05, Robert Simpson <[EMAIL PROTECTED]> wrote: 
> 
> - Original Message -
> From: "Jonathan H N Chin" <[EMAIL PROTECTED]>
> To: 
> Sent: Thursday, August 18, 2005 8:00 AM
> Subject: [sqlite] blocking - busy_timeout vs database is locked(5)
> 
> 
> [snip]
> >
> > but I still occasionally get failures:
> >
> > DBD::SQLite::db do failed: database is locked(5) at dbdimp.c line
> > 403
> >
> > Am I doing something wrong?
> >
> > What is the correct way to make accesses block/retry when the
> > database is busy?
> 
> I'm afraid you'll have to write your own internal retry mechanism. The
> busy_timeout only works in certain areas when the database is busy. When 
> an
> update is in progress however, all attempts to read will return
> *immediately* with a failure message. You'll then have to call
> sqlite3_reset() to find out what that error message is. If its a
> SQLITE_SCHEMA you need to call sqlite3_prepare() again (don't forget to
> rebind your parameters if any), and if its a SQLITE_LOCKED then you need 
> to
> sleep for some random amount of time and retry -- with hopefully an 
> eventual
> timeout mechanism in place.
> 
> Robert
> 
> 
> 


-- 
Ray Mosley


Re: [sqlite] How do I attach a database from C++?

2005-08-19 Thread Puneet Kishor

Greg Stark wrote:

Tom,

I appreciate you're help but I'm pretty sure that the semicolon has  to 
be there (well. at least it's required in all the other statements  I've 
written to date -- this one statement is part of a much large  program 
that's working fine other than for this one ATTACH).


My guess is that SQLite3 doesn't know where to find my database, but  
I'm not sure how to tell it where to look.


well, have you tried giving it the full path name to the database?




-Greg

On Aug 19, 2005, at 6:07 AM, Thomas Briggs wrote:



   I think that the semi-colon at the end of the statement is what's
causing your problem.  The command shell requires the semi-colon to  mark
the end of a statement; in code, your statement ends at the end of the
string.

   -Tom



-Original Message-
From: Greg Stark [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 7:38 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] How do I attach a database from C++?

I'm having difficulty attaching a database from C++.

Within my code, I'm using an sqlite3_prepare call:

 prepareResult = pSqlBundle->sqlite3_prepare (db_, "ATTACH
DATABASE 'window_5.sdb' AS W5;", -1, , );

but it returns an error (i.e., prepareResult comes back as
SQLITE_ERROR).

Just to make sure that there were no problems with the databases or
my syntax, I tried the attach command (i.e., ATTACH DATABASE
'window_5.sdb' AS W5;) from the command line, and everything worked
fine.  I tried using the full path name for the database-filename,
but that didn't work either.

I'm sure it's something simple, but what I'm I doing wrong?

Thanks,
Greg











Re: [sqlite] How do I attach a database from C++?

2005-08-19 Thread Greg Stark

Tom,

I appreciate you're help but I'm pretty sure that the semicolon has  
to be there (well. at least it's required in all the other statements  
I've written to date -- this one statement is part of a much large  
program that's working fine other than for this one ATTACH).


My guess is that SQLite3 doesn't know where to find my database, but  
I'm not sure how to tell it where to look.


-Greg

On Aug 19, 2005, at 6:07 AM, Thomas Briggs wrote:



   I think that the semi-colon at the end of the statement is what's
causing your problem.  The command shell requires the semi-colon to  
mark

the end of a statement; in code, your statement ends at the end of the
string.

   -Tom



-Original Message-
From: Greg Stark [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 7:38 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] How do I attach a database from C++?

I'm having difficulty attaching a database from C++.

Within my code, I'm using an sqlite3_prepare call:

 prepareResult = pSqlBundle->sqlite3_prepare (db_, "ATTACH
DATABASE 'window_5.sdb' AS W5;", -1, , );

but it returns an error (i.e., prepareResult comes back as
SQLITE_ERROR).

Just to make sure that there were no problems with the databases or
my syntax, I tried the attach command (i.e., ATTACH DATABASE
'window_5.sdb' AS W5;) from the command line, and everything worked
fine.  I tried using the full path name for the database-filename,
but that didn't work either.

I'm sure it's something simple, but what I'm I doing wrong?

Thanks,
Greg









RE: [sqlite] How do I attach a database from C++?

2005-08-19 Thread Thomas Briggs

   I think that the semi-colon at the end of the statement is what's
causing your problem.  The command shell requires the semi-colon to mark
the end of a statement; in code, your statement ends at the end of the
string.

   -Tom

> -Original Message-
> From: Greg Stark [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, August 18, 2005 7:38 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] How do I attach a database from C++?
> 
> I'm having difficulty attaching a database from C++.
> 
> Within my code, I'm using an sqlite3_prepare call:
> 
>  prepareResult = pSqlBundle->sqlite3_prepare (db_, "ATTACH  
> DATABASE 'window_5.sdb' AS W5;", -1, , );
> 
> but it returns an error (i.e., prepareResult comes back as  
> SQLITE_ERROR).
> 
> Just to make sure that there were no problems with the databases or  
> my syntax, I tried the attach command (i.e., ATTACH DATABASE  
> 'window_5.sdb' AS W5;) from the command line, and everything worked  
> fine.  I tried using the full path name for the database-filename,  
> but that didn't work either.
> 
> I'm sure it's something simple, but what I'm I doing wrong?
> 
> Thanks,
> Greg
> 


ODP: [sqlite] Possible bug regarding endiannes and realstorageclass (sqlite3)

2005-08-19 Thread Jarosław Nozderko
> Od: D. Richard Hipp [mailto:[EMAIL PROTECTED] 
> Wysłano: 18 sierpnia 2005 20:11
> Do: sqlite-users@sqlite.org
> Temat: Re: [sqlite] Possible bug regarding endiannes and 
> realstorageclass (sqlite3)
> 
> On Thu, 2005-08-18 at 09:40 -0700, Robert Simpson wrote:
> > http://www.psc.edu/general/software/packages/ieee/ieee.html
> > 
> > The way I interpreted this site, is that the IEEE standard for 
> > floating point numbers was processor agnostic and the 
> storage of the 
> > bits went from left to right.
> > 
> 
> I wrote a test program to print out the byte values for 1.0 
> and 1 on both ix86 (Intel, Linux) and powerpc (G5, OS-X).  
> The results:
> 
> ix86:   f03f  0100
>  powerpc:   3ff0  0001
> 
> This seems to validate the approach taken by SQLite, which is 
> to byteswap floating point values on ix86 machines.

CORBA CDR specification also clearly states that floating
point numbers are byte swapped on different endian
architectures:

http://www.omg.org/docs/formal/04-03-01.pdf

15.3.1.3 "Floating Point Data Types"
Fig 15.2 on page 535

Regards,
Jarek