Re: [sqlite] Is the file I'm about to open an SQLite Database

2017-09-04 Thread Papa
Yes, what I do to check for the existance of a database is: //This method will returns true if the table does not exit, false otherwise. bool SQLite3_RDB::notExist(const std::wstring& table) {     // SQL statement     sql_statement_request = "SELECT *  FROM " + table + " LIMIT 0";     // Feed the

[sqlite] dbSize calculation

2017-09-04 Thread zhiting zhu
Hi, I send this email to the dev mailing list but no response. It seems this mailing list has more activity and attention. I have a question about how dbSize is calculated when I was reading the source code of sqlite3. In the description of the dbSize, it said: "If the size of the file is not an i

[sqlite] GnuCOBOL to support SQLite3

2017-09-04 Thread Phoenix
The GnuCOBOL project now has a new contribution, CobolSQLite3, that is a library of User Defined Functions (UDF) that adds another entry of the list of Databases supported. In this case the supported database is SQLite3. The current library, version X.01.00, is still in BETA but should become a

Re: [sqlite] [EXTERNAL] Re: SQLITE bug

2017-09-04 Thread Richard Damon
Depends on why you are restoring a backup (what data got corrupted). Even if you are restoring a full backup of all the tables, you still need to restore the ID fields rather than using the auto increment value or you still break the relationships. On 9/4/17 2:42 AM, Hick Gunter wrote: Are yo

[sqlite] Writing a SQLite work-alike

2017-09-04 Thread Simon Slavin
An article on what it takes to write a very simple SQLite work-alike. Gives full credit to SQLite. Discusses prepared statements and the virtual machine. I like the emphasis on a test suite even for something as simple as this. Simon. _

Re: [sqlite] Is the file I'm about to open an SQLite Database

2017-09-04 Thread Gwendal Roué
> Le 4 sept. 2017 à 16:46, Phoenix a écrit : > > Is there anyway to confirm the file I am about to open, via > sqlite3_open, is in fact an SQLite Database? You may have noticed that sqlite3_open doesn't fail if the file is not a database. To check if the file is a valid database, read somethi

Re: [sqlite] Is the file I'm about to open an SQLite Database

2017-09-04 Thread Simon Slavin
On 4 Sep 2017, at 3:46pm, Phoenix wrote: > Is there anyway to confirm the file I am about to open, via > sqlite3_open, is in fact an SQLite Database? Read the file header from it using fopen()/fread()/fclose() (i.e. not the SQLite library). The file will start with "SQLite format 3" followed

[sqlite] Is the file I'm about to open an SQLite Database

2017-09-04 Thread Phoenix
Is there anyway to confirm the file I am about to open, via sqlite3_open, is in fact an SQLite Database? ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread David Wellman
Now that could be really useful for some things that I'm doing. Many thanks. Dave Ward Analytics Ltd - information in motion Tel: +44 (0) 118 9740191 Fax: +44 (0) 118 9740192 www: http://www.ward-analytics.com Registered office address: The Oriel, Sydenham Road, Guildford, Surrey, United King

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread R Smith
One last thing I forgot to mention, on the topic of making INSERT and UPDATE easy - If you are using SQLite 3.15 or later, you can use Row-value functionality to UPDATE several fields in one go from a sub query. An example of how such an update query might look: WITH CTE(ID, ta, tb, tc) AS

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread R Smith
On 2017/09/04 12:46 PM, David Wellman wrote: Hi Ryan, Thanks for that. It is certainly valid syntax and I'll do some testing to check that it gives me the correct answer. It's always a pleasure. Your email has 'crossed in the post' with my second one and you've answered something that I

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread David Wellman
Hi Ryan, Thanks for that. It is certainly valid syntax and I'll do some testing to check that it gives me the correct answer. Your email has 'crossed in the post' with my second one and you've answered something that I asked in that (I'm impressed, how did you do that ?) I understand that the

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread David Wellman
I've been able to get my code runing by changing it to the following: update relation set wamapname = (select wrk.mapname from waPSM_TABLE_MAPNAME_WRK as wrk inner join relation as rel on wrk.queryid = 1 and wrk.queryid = rel.queryid

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread R Smith
You are essentially trying to use a CTE (which for the intents and purposes of the UPDATE SQL is just the same as using any other table) inside an UPDATE statement as if it is the main referenced table. In an UPDATE or INSERT however, there can only ever be 1 single main referenced table (i.e.

[sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread David Wellman
Hi, (I have a feeling that this will be depressingly simple - but I just can't see it right now.) The following code is failing with: Error: near line 3: no such column: dtls.mapname2 explain with dtls as (select distinct wrk.mapname as mapname2 ,udb.udb_key

Re: [sqlite] sqlite 3.20.1: Core dump when running query with json functions in subquery

2017-09-04 Thread Bart Smissaert
Thanks that runs fine now. RBS On Mon, Sep 4, 2017 at 8:45 AM, Richard Hipp wrote: > On 9/4/17, Bart Smissaert wrote: > > > > malformed JSON > > > > SQLite should never segfault, regardless of whether or not the JSON is > malformed. > > The ticket (https://sqlite.org/src/info/b899b6042f97f5) s

Re: [sqlite] sqlite 3.20.1: Core dump when running query with json functions in subquery

2017-09-04 Thread Bart Smissaert
Thanks, this runs OK now. I am not familiar with JSON, but was just trying this out and see if I could make it work in SQLite. RBS On Mon, Sep 4, 2017 at 8:40 AM, Rowan Worth wrote: > On 4 September 2017 at 15:37, Bart Smissaert > wrote: > > > Trying this out, so I edited the source and inde

Re: [sqlite] sqlite 3.20.1: Core dump when running query with json functions in subquery

2017-09-04 Thread Richard Hipp
On 9/4/17, Bart Smissaert wrote: > > malformed JSON > SQLite should never segfault, regardless of whether or not the JSON is malformed. The ticket (https://sqlite.org/src/info/b899b6042f97f5) shows a modified test case that uses no JSON at all. -- D. Richard Hipp d...@sqlite.org __

Re: [sqlite] sqlite 3.20.1: Core dump when running query with json functions in subquery

2017-09-04 Thread Rowan Worth
On 4 September 2017 at 15:37, Bart Smissaert wrote: > Trying this out, so I edited the source and indeed now there is no crash. > I get however a message: > > malformed JSON > > This is the dump of that testing table, dataset: > > doc > {"field1": [{"value": "val1"}, {"value": "val2"}] > {"field1

Re: [sqlite] sqlite 3.20.1: Core dump when running query with json functions in subquery

2017-09-04 Thread Bart Smissaert
Trying this out, so I edited the source and indeed now there is no crash. I get however a message: malformed JSON This is the dump of that testing table, dataset: doc {"field1": [{"value": "val1"}, {"value": "val2"}] {"field1": [{"value": "val3"}, {"value": "val2"}] {"field1": [{"value": "val4"}