Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?

2016-12-13 Thread Hick Gunter
>On 12/13/2016 01:47 AM, Bob Friesenhahn wrote: >> I am reworking code for a virtual table module and need to provide >> proper error codes from the xColumn() and xRowid() callbacks for the >> case where the row id does not exist, or the current row goes away. >> This problem occurs because the

Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?

2016-12-13 Thread Hick Gunter
xRowid() is only called if the (hidden field) rowid is explicitly mentioned in the select list, join condition or where clause(s) of a SELECT statement; or if your VTAB supports write operations (see xUpdate documentation http://www.sqlite.org/vtab.html#the_xupdate_method ). -Ursprüngliche

Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?

2016-12-13 Thread Hick Gunter
Current documentation http://www.sqlite.org/rescode.html suggests you return (267) SQLITE_CORRUPT_VTAB in this case. Other candidates would be SQLITE_IOERR or SQLITE_NOTFOUND. You may also call one or more of the sqlite_result_error() functions to set an error string and/or an error code;

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Nathan Bossett
I'm not sure exactly what you're trying to do, but if sqlite3_close() returns SQLITE_OK then it closed and if it returns SQLITE_BUSY then it's not closed but possibly in a messy state (my selects have default handling too but I think those are the only defined responses). If you know it

[sqlite] How do I check if the DB is open?

2016-12-13 Thread Igor Korot
Hi, ALL, I'm using following code to check for errors in debug mode: int res = sqlite3_close( m_db ); if( res != SQLITE_OK ) { // error handling } #ifdef DEBUG sqlite3_stmt *statement = sqlite3_next_stmt( m_db, NULL ); if( statement ) const char *query =

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Dan Kennedy
On 12/14/2016 10:56 AM, Igor Korot wrote: Keith, On Tue, Dec 13, 2016 at 8:34 PM, Keith Medcalf wrote: int res = sqlite3_close( m_db ); if( res == SQLITE_OK ) m_db = NULL; else { // error handling } #ifdef DEBUG sqlite3_stmt

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Igor Korot
Simon, On Tue, Dec 13, 2016 at 8:33 PM, Simon Slavin wrote: > > On 14 Dec 2016, at 1:20am, Igor Korot wrote: > >> So are you saying that this code should be executed if sqlite3_close() >> didn't return SQLITE_OK? > > Hold on. Closing the database is a

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Jens Alfke
> On Dec 13, 2016, at 5:33 PM, Simon Slavin wrote: > > The only thing you should do if sqlite3_close() doesn’t work is to print an > error message which includes the value returned. Because if you can’t close > the database what are you going to do instead ? Igor is

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Igor Korot
Keith, On Tue, Dec 13, 2016 at 8:34 PM, Keith Medcalf wrote: > > int res = sqlite3_close( m_db ); > if( res == SQLITE_OK ) > m_db = NULL; > else > { > // error handling > } > #ifdef DEBUG > sqlite3_stmt *statement = sqlite3_next_stmt( m_db,

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Keith Medcalf
int res = sqlite3_close( m_db ); if( res == SQLITE_OK ) m_db = NULL; else { // error handling } #ifdef DEBUG sqlite3_stmt *statement = sqlite3_next_stmt( m_db, NULL ); if( statement ) const char *query = sqlite3_sql( statement ); #endif Then you simply

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Nathan Bossett
On Tue, Dec 13, 2016 at 08:20:44PM -0500, Igor Korot wrote: > > What more are you trying to find out? > > If I forget to finalize statement, I can use that sequence to find > which query is dangling. > > So are you saying that this code should be executed if sqlite3_close() > didn't return

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Igor Korot
Hi, Nathan, On Tue, Dec 13, 2016 at 8:03 PM, Nathan Bossett wrote: > I'm not sure exactly what you're trying to do, but if sqlite3_close() > returns SQLITE_OK then it closed and if it returns SQLITE_BUSY then it's > not closed but possibly in a messy state (my selects have

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Simon Slavin
On 14 Dec 2016, at 1:20am, Igor Korot wrote: > So are you saying that this code should be executed if sqlite3_close() > didn't return SQLITE_OK? Hold on. Closing the database is a special case. The only thing you should do if sqlite3_close() doesn’t work is to print an

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Igor Korot
Nathan, On Tue, Dec 13, 2016 at 8:36 PM, Nathan Bossett wrote: > On Tue, Dec 13, 2016 at 08:20:44PM -0500, Igor Korot wrote: >> > What more are you trying to find out? >> >> If I forget to finalize statement, I can use that sequence to find >> which query is dangling. >> >>

Re: [sqlite] How do I check if the DB is open?

2016-12-13 Thread Igor Korot
Jens, On Tue, Dec 13, 2016 at 8:38 PM, Jens Alfke wrote: > >> On Dec 13, 2016, at 5:33 PM, Simon Slavin wrote: >> >> The only thing you should do if sqlite3_close() doesn’t work is to print an >> error message which includes the value returned.

[sqlite] Node js and sqlite see

2016-12-13 Thread Rosina joy01
Hi, Could some one share the steps on how to build the sqlite-see with node js? Thanks, Rosina ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Date (from REAL) with Negative Year

2016-12-13 Thread Richard Hipp
On 12/12/16, Lipson, Ed wrote: > Python 32bit, Windows 7 64bit > How do I turn a real into a date? That depends on how the real number represents a date. SQLite supports two very popular encodings: Julian Day Number (https://en.wikipedia.org/wiki/Julian_day) and Unix

Re: [sqlite] System.Data.SQLite -> ChangePassword 2nd time has opposite behavior

2016-12-13 Thread Baugher, Melody
Thanks, Jens. I'll keep an eye on that. Take care, Melody -Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Jens Alfke Sent: Monday, December 12, 2016 12:32 PM To: SQLite mailing list Subject:

Re: [sqlite] Node js and sqlite see

2016-12-13 Thread Richard Hipp
On 12/12/16, Rosina joy01 wrote: > Hi, > > Could some one share the steps on how to build the sqlite-see with node js? > Sure. But first, can you please share with me (perhaps via reply to d...@sqlite.org instead of back to this list) the email address associated with

Re: [sqlite] Foreign key child index question

2016-12-13 Thread Paul Egli
On Tue, Dec 13, 2016 at 9:41 AM, Simon Slavin wrote: > > On 13 Dec 2016, at 3:20pm, Paul Egli wrote: > > > Why must SQLite find rows where the value is NULL? > > Because the related fields in the offspring row might have NULL in them, > and SQLite

Re: [sqlite] Foreign key child index question

2016-12-13 Thread Simon Slavin
On 13 Dec 2016, at 3:53pm, Paul Egli wrote: > Well if i am missing something, i still cannot see it. > > Based on these quotes in the docs, i assume that a NULL in the child table > means that it does not have a parent. You are correct. I missed that. So yes, the

Re: [sqlite] Foreign key child index question

2016-12-13 Thread Simon Slavin
On 13 Dec 2016, at 3:20pm, Paul Egli wrote: > Why must SQLite find rows where the value is NULL? Because the related fields in the offspring row might have NULL in them, and SQLite needs to know how to find the parent row for that row. Mind you, if the relating key

Re: [sqlite] Date (from REAL) with Negative Year

2016-12-13 Thread Paul Sanderson
rather unintuitively excel uses the OLE automation timestamp that records the number of days since 1899/12/30 http://sandersonforensics.com/forum/content.php?131-A-brief-history-of-time-stamps https://msdn.microsoft.com/en-us/library/system.datetime.tooadate(v=vs.110).aspx now no need for the

Re: [sqlite] Foreign key child index question

2016-12-13 Thread Paul Egli
On Wed, Dec 7, 2016 at 3:11 PM, Simon Slavin wrote: > > On 7 Dec 2016, at 8:40pm, David Raymond wrote: > > > Question on making indexes for the child fields of foreign keys. I have > a child table with a number of foreign keys on fields which the

Re: [sqlite] Foreign key child index question

2016-12-13 Thread Paul Egli
On Tue, Dec 13, 2016 at 9:56 AM, Simon Slavin wrote: > > On 13 Dec 2016, at 3:53pm, Paul Egli wrote: > > > Well if i am missing something, i still cannot see it. > > > > Based on these quotes in the docs, i assume that a NULL in the child > table > >

Re: [sqlite] Date (from REAL) with Negative Year

2016-12-13 Thread Daniel Dumitriu
> But that does not seems to be the whole story, since if I do: > > SELECT datetime(42713.1916667+julianday('1900-01-01')); > > I get 2016-12-11 04:36:00 instead of what you were expecting > 2016-12-09 05:15. Something is a little off. I suspect that there I think he is expecting

Re: [sqlite] Foreign key child index question

2016-12-13 Thread Dan Kennedy
On 12/13/2016 11:02 PM, Paul Egli wrote: On Tue, Dec 13, 2016 at 9:56 AM, Simon Slavin wrote: On 13 Dec 2016, at 3:53pm, Paul Egli wrote: Well if i am missing something, i still cannot see it. Based on these quotes in the docs, i assume that a

Re: [sqlite] Date (from REAL) with Negative Year

2016-12-13 Thread Keith Medcalf
Well, no. Microsoft intended to store the number of days since 1900/01/01 with 1900/01/01 being day 1. Unfortunately, Microsoft being Microsoft does not know how to calculate leap years properly -- I think they still have problems with the divisible by 100 and 400 bits, and will probably

Re: [sqlite] Foreign key child index question

2016-12-13 Thread Simon Slavin
On 13 Dec 2016, at 4:02pm, Paul Egli wrote: > Great. Just to clarify, SQLite will already use "alternateChildIndex1" from > the example? Or just that it would be possible as an enhancement request? I don’t know the answer, but you can find out exactly what SQLite has

Re: [sqlite] Node js and sqlite see

2016-12-13 Thread Richard Hipp
On 12/12/16, Rosina joy01 wrote: > Hi, > > Could some one share the steps on how to build the sqlite-see with node js? You are going to need to recompile the SQLite adaptor for Node.js. I don't know how to do that, but as Node.js is open-source, surely it is not too hard.

Re: [sqlite] Foreign key child index question

2016-12-13 Thread David Raymond
Hurray for intelligent logic! Also seems to work for composite foreign keys. Thank you all for checking more into this. And thank you to the developers for already having this in there. I think this would be worthy of having a couple sentences written up for the "Foreign Key Support" page.

Re: [sqlite] Foreign key child index question

2016-12-13 Thread Dominique Devienne
On Tue, Dec 13, 2016 at 8:07 PM, David Raymond wrote: > sqlite> create table parentTable >...> ( >...> id integer primary key, >...> a int not null, >...> b int not null, >...> otherStuff, >...> unique (a, b) >...> ); > > sqlite>

Re: [sqlite] Foreign key child index question

2016-12-13 Thread David Raymond
For the specific case below I was just banging something out to test if it worked, so didn't adhere to the best design practices. All your comments are good ones for actual designs though. -Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On