Re: [sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-16 Thread Stefan Brüns
On Sonntag, 16. Februar 2020 21:50:18 CET Simon Slavin wrote: > On 16 Feb 2020, at 8:44pm, Stefan Brüns wrote: > > On Sonntag, 16. Februar 2020 21:26:00 CET Simon Slavin wrote: > >>> One use case I am aware of (although this targets places.sqlite, not > >>> cookies.sqlite) is reading the

Re: [sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-16 Thread Simon Slavin
On 16 Feb 2020, at 8:44pm, Stefan Brüns wrote: > On Sonntag, 16. Februar 2020 21:26:00 CET Simon Slavin wrote: > >>> One use case I am aware of (although this targets places.sqlite, not >>> cookies.sqlite) is reading the history, bookmarks and tags. >> >> These things can be done using the

Re: [sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-16 Thread Stefan Brüns
On Sonntag, 16. Februar 2020 21:26:00 CET Simon Slavin wrote: > > One use case I am aware of (although this targets places.sqlite, not > > cookies.sqlite) is reading the history, bookmarks and tags. > These things can be done using the bookmarks API, WebExtensions API, and > other methods.

Re: [sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-16 Thread Keith Medcalf
On Sunday, 16 February, 2020 10:25, Richard Hipp wrote: >> Why the database can not be read by another sqlite3 session when the >> corresponding -wal file exists? Thanks. >Because Firefox uses "PRAGMA locking_mode=EXCLUSIVE;" Perhaps on some platforms, but Firefox 73.0.0 on Windows 10

Re: [sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-16 Thread Simon Slavin
On 16 Feb 2020, at 8:02pm, Stefan Brüns wrote: > Will this stop anyone from just copying the DB without the -wal file? > Afterwards, the DB can be read, as there is no longer any associated log. The purpose of the locking is to prevent changes being made to the database during a browser

Re: [sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-16 Thread Stefan Brüns
On Sonntag, 16. Februar 2020 18:36:15 CET Simon Slavin wrote: > On 16 Feb 2020, at 5:15pm, Peng Yu wrote: > > Why the database can not be read by another sqlite3 session when the > > corresponding -wal file exists? Thanks. > > This is done on purpose by the developers of Firefox to prevent a

Re: [sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-16 Thread Simon Slavin
On 16 Feb 2020, at 5:15pm, Peng Yu wrote: > Why the database can not be read by another sqlite3 session when the > corresponding -wal file exists? Thanks. This is done on purpose by the developers of Firefox to prevent a security vulnerability which I will not describe in public. One of the

Re: [sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-16 Thread Richard Hipp
On 2/16/20, Peng Yu wrote: >> Does it work when you close Firefox? If it works when Firefox is closed >> but >> not when Firefox is open, then the answer is probably no. > > I can check the content when Firefox is closed (the -wal file > disappears after Firefox is closed). > > Why the database

Re: [sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-16 Thread Peng Yu
> Does it work when you close Firefox? If it works when Firefox is closed but > not when Firefox is open, then the answer is probably no. I can check the content when Firefox is closed (the -wal file disappears after Firefox is closed). Why the database can not be read by another sqlite3

Re: [sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-15 Thread Keith Medcalf
On Saturday, 15 February, 2020 19:27, Peng Yu wrote: >I am trying to see what tables are available in sqlite_master from >firefox cookies sqlite3 fire. >~/Library/Application >Support/Firefox/Profiles/jaseom4q.default-1480119569722/cookies.sqlite >But the error message says "Error: database

[sqlite] Is it possible to dump a sqlite db that has an associated -wal file?

2020-02-15 Thread Peng Yu
Hi, I am trying to see what tables are available in sqlite_master from firefox cookies sqlite3 fire. ~/Library/Application Support/Firefox/Profiles/jaseom4q.default-1480119569722/cookies.sqlite But the error message says "Error: database is locked". I see a cookies.sqlite-wal file in the same

Re: [sqlite] Endless loop possible with simultaneous SELECT and UPDATE?

2019-09-03 Thread Keith Medcalf
On Tuesday, 3 September, 2019 15:01, Kees Nuyt wrote: >On Tue, 3 Sep 2019 18:26:01 +0100, you wrote: >>> // do SELECT on db1 >>> // do UPDATE on db2 >> Do you expect the SELECT to see the results of the previous >> UPDATE ? It won't, until the transaction has ended >> (unless you arrange

Re: [sqlite] Endless loop possible with simultaneous SELECT and UPDATE?

2019-09-03 Thread Kees Nuyt
On Tue, 3 Sep 2019 18:26:01 +0100, you wrote: >> // do SELECT on db1 >> // do UPDATE on db2 > > Do you expect the SELECT to see the results of the previous > UPDATE ? It won't, until the transaction has ended > (unless you arrange this explicitly). That's the nice thing about this construct:

Re: [sqlite] Endless loop possible with simultaneous SELECT and UPDATE?

2019-09-03 Thread Simon Slavin
On 3 Sep 2019, at 5:34pm, Alexander Vega wrote: > sqlite3_open("database1", ); > sqlite3_open("database1", ); Bear in mind that SQLite is not a server/client DBMS. The database is not kept in memory (unless you arrange this explicitly). All operations have to wait for the storage that holds

Re: [sqlite] Endless loop possible with simultaneous SELECT and UPDATE?

2019-09-03 Thread Alexander Vega
So in the original code if I added a NOT INDEXED it would be valid? Also, would an ORDER BY Auth_id ASC fix the issue, since I an not adding any new rows the auth_ids would remain constant? Wow I did not know that you could call open multiple times on the same database! So the following is valid

Re: [sqlite] Endless loop possible with simultaneous SELECT and UPDATE?

2019-09-01 Thread Keith Medcalf
On Sunday, 1 September, 2019 11:12, Alexander Vega wrote: >Thank you Keith for your answer. It has led me to more questions. >"though you may or may not have visited all rows" >From the documentation I did not get the impression that you would >ever not visit ALL ROWS at least once. Is there a

Re: [sqlite] Endless loop possible with simultaneous SELECT and UPDATE?

2019-09-01 Thread Alexander Vega
Thank you Keith for your answer. It has led me to more questions. "though you may or may not have visited all rows" From the documentation I did not get the impression that you would ever not visit ALL ROWS at least once. Is there a technical reason for this? I would assume a full table scan is

Re: [sqlite] Endless loop possible with simultaneous SELECT and UPDATE?

2019-08-31 Thread Keith Medcalf
> Having read : https://www.sqlite.org/isolation.html > Specifically the line "And the application can UPDATE the current row > or any prior row, though doing so might cause that row to reappear in a > subsequent sqlite3_step()." > Is it possible to create and endless loop Eventually you will

[sqlite] Endless loop possible with simultaneous SELECT and UPDATE?

2019-08-31 Thread Alexander Vega
Having read : https://www.sqlite.org/isolation.html Specifically the line "And the application can UPDATE the current row or any prior row, though doing so might cause that row to reappear in a subsequent sqlite3_step()." Is it possible to create and endless loop with the following

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-04-01 Thread Jake Thaw
Hi Shane, You might be interested in trying out my pivot virtual table implementation. https://github.com/jakethaw/pivot_vtab This will cater for changing values, but like a VIEW implementation, it does not satisfy your criteria of dynamically changing rows/columns. Changes to rows/columns can

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-04-01 Thread Simon Slavin
On 1 Apr 2019, at 10:18am, Dominique Devienne wrote: > I can't seem to find that one, but I found another here: > https://metacpan.org/pod/SQLite::VirtualTable::Pivot I looked at that one, but it doesn't do what OP wants, which is to swap rows and columns without the programmer having to

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-04-01 Thread Dominique Devienne
On Mon, Apr 1, 2019 at 7:15 AM Shane Dev wrote: > [...]. By "dynamically changing table", I meant the number of columns and > rows could could change > after the dependant view was created. it appears this is impossible using > only SQL > It's possible using a virtual table, which years ago a

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-03-31 Thread Shane Dev
Hi Keith, Jean-Luc I should have mentioned my shell is configured to display column headers Product/Region|Belgium|France|USA for table t1 and Product/Region|Oil_filter|Spark_plug|Coolent for view v1. By "dynamically changing table", I meant the number of columns and rows could could change after

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-03-31 Thread Keith Medcalf
On Sunday, 31 March, 2019 14:07, Shane Dev wrote: >Is it possible to create a view which switches rows and columns of a >dynamically changing table? >For example, imagine we have table t1 where both columns and rows >could change after the view has been created >sqlite> select * from t1;

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-03-31 Thread Jean-Luc Hainaut
If by "a dynamically changing table " you mean that any data change (not schema change) in t1 will propagate to v1, and if the set of Product values doesn't change, then you can try this: create table t1(Product,Belgium,France,USA); insert into t1 values

Re: [sqlite] Is it possible to transpose a table using SQL?

2019-03-31 Thread Simon Slavin
On 31 Mar 2019, at 9:07pm, Shane Dev wrote: > Is it possible to create a view which switches rows and columns of a > dynamically changing table? Sorry, but no. A VIEW is just a saved SELECT statement. If you can't do it in a SELECT statement, you can't do it in a view. And you can't do

[sqlite] Is it possible to transpose a table using SQL?

2019-03-31 Thread Shane Dev
Hello, Is it possible to create a view which switches rows and columns of a dynamically changing table? For example, imagine we have table t1 where both columns and rows could change after the view has been created sqlite> select * from t1; Product/Region|Belgium|France|USA Oil_filter|1|2|3

Re: [sqlite] is this possible

2019-03-29 Thread Simon Slavin
On 29 Mar 2019, at 1:55pm, Dan Kennedy wrote: > The error doesn't occur unless you actually query the view though, correct? My theory on SQLite was that the VIEW definition was only syntax-checked and not compiled in any way. So you could do CREATE VIEW v as select * from t ORDER BY a;

Re: [sqlite] is this possible

2019-03-29 Thread Igor Tandetnik
On 3/29/2019 9:55 AM, Dan Kennedy wrote: On 29/3/62 03:00, Igor Tandetnik wrote: On 3/28/2019 3:21 PM, Mark Wagner wrote: Imagine I have these two tables and one view defining a join. CREATE TABLE t (foo); CREATE TABLE s (bar); CREATE VIEW v as select * from t join s on (foo = q);

Re: [sqlite] is this possible

2019-03-29 Thread Dan Kennedy
On 29/3/62 03:00, Igor Tandetnik wrote: On 3/28/2019 3:21 PM, Mark Wagner wrote: Imagine I have these two tables and one view defining a join. CREATE TABLE t (foo); CREATE TABLE s (bar); CREATE VIEW v as select * from t join s on (foo = q); Surprisingly, this last statement succeeds. But if

Re: [sqlite] is this possible

2019-03-28 Thread Keith Medcalf
On Thursday, 28 March, 2019 13:21, Mark Wagner wrote: >Imagine I have these two tables and one view defining a join. >CREATE TABLE t (foo); >CREATE TABLE s (bar); >CREATE VIEW v as select * from t join s on (foo = q); >I appear to be able to do this query: >select 20 as q, * from t join s on

Re: [sqlite] is this possible

2019-03-28 Thread Igor Tandetnik
On 3/28/2019 3:21 PM, Mark Wagner wrote: Imagine I have these two tables and one view defining a join. CREATE TABLE t (foo); CREATE TABLE s (bar); CREATE VIEW v as select * from t join s on (foo = q); Surprisingly, this last statement succeeds. But if you then close the database and try to

Re: [sqlite] is this possible

2019-03-28 Thread Amit Yaron
From the page https://sqlite.org/lang_createview.html : "The CREATE VIEW command assigns a name to a pre-packaged SELECT statement ..." So, it seems that the command "CREATE VIEW" just creates a name for a SELECT statement, and checks nothing more than syntax. On 28.3.2019 21:21, Mark

[sqlite] is this possible

2019-03-28 Thread Mark Wagner
Imagine I have these two tables and one view defining a join. CREATE TABLE t (foo); CREATE TABLE s (bar); CREATE VIEW v as select * from t join s on (foo = q); I appear to be able to do this query: select 20 as q, * from t join s on (foo=q); But apparently I cannot do this: sqlite> select 20

Re: [sqlite] Is it possible to use sqlite online-backup system in an ongoing manner?

2019-03-13 Thread Barry Smith
I think the sessions extension can be used for what you want to do. I haven't used it myself, but from it's documented behaviour it looks like you could record change sets for every three second interval then apply them back to your database on disk. If your app is multi-threaded it might be a

Re: [sqlite] Is it possible to use sqlite online-backup system in an ongoing manner?

2019-03-13 Thread Simon Slavin
On 13 Mar 2019, at 2:31pm, John Smith wrote: > I am working with IN-MEMORY database. > When my program starts I load data from file-system DB into my IN-MEMORY DB. > All other SQL operations are performed directly on my IN-MEMORY database. > This is in order to keep performance high. First,

[sqlite] Is it possible to use sqlite online-backup system in an ongoing manner?

2019-03-13 Thread John Smith
I am working with IN-MEMORY database. When my program starts I load data from file-system DB into my IN-MEMORY DB. All other SQL operations are performed directly on my IN-MEMORY database. This is in order to keep performance high. However, I have a requirement that my original file-system

Re: [sqlite] Is it possible to concatenate an arbitrary number of columns into one?

2018-11-20 Thread Michael Falconer
As Simon points out there is no SQL solution to your issue. Some sort of external utility processing with things like awk, sed or even cut may assist or for a quick and dirty method you could set the sqlite3 command line utility .separator value to a blank string which may (or may not) provide a

Re: [sqlite] Is it possible to concatenate an arbitrary number of columns into one?

2018-11-20 Thread Simon Slavin
On 20 Nov 2018, at 11:54pm, Shane Dev wrote: > Is there an SQL statement to concatenate all columns into a single column > without explicitly naming them? No. And I can't think of any short-cut way to do what you want. Simon. ___ sqlite-users

[sqlite] Is it possible to concatenate an arbitrary number of columns into one?

2018-11-20 Thread Shane Dev
Hello, An asterisk in the result-column represents all columns from the FROM clause without explicitly naming them, https://www.sqlite.org/syntax/result-column.html Is there an SQL statement to concatenate all columns into a single column without explicitly naming them? If it existed, I could

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-24 Thread Csányi Pál
2018-03-23 21:52 GMT+01:00 David Raymond : > This gets a little ugly. Was stuck for a while wondering what the heck was > going on until I found out that the modulo operator can return negatives. > Which makes absolutely no sense coming from someone who was a math

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-23 Thread David Raymond
On Behalf Of csanyipal Sent: Friday, March 23, 2018 4:19 PM To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way? csanyipal wrote > csanyipal wrote > 2017-09-01|F|1-2|5|b > 2017-09-01|F|1-2|7|c > 2017-09-04|M|1-

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-23 Thread csanyipal
csanyipal wrote > csanyipal wrote > 2017-09-01|F|1-2|5|b > 2017-09-01|F|1-2|7|c > 2017-09-04|M|1-2|7|b > 2017-09-04|M|1-2|5|a > 2017-09-05|Tu|1-2|8|c > 2017-09-05|Tu|1-2|8|b > 2017-09-06|W|1-2|8|a > 2017-09-06|W|1-2|7|a > 2017-09-07|Th|1-2|6|a > 2017-09-07|Th|1-2|5|c > 2017-09-08|F|3-4|5|b >

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-23 Thread csanyipal
csanyipal wrote > 2017-09-01|F|1-2|5|b > 2017-09-01|F|1-2|7|c > 2017-09-04|M|1-2|7|b > 2017-09-04|M|1-2|5|a > 2017-09-05|Tu|1-2|8|c > 2017-09-05|Tu|1-2|8|b > 2017-09-06|W|1-2|8|a > 2017-09-06|W|1-2|7|a > 2017-09-07|Th|1-2|6|a > 2017-09-07|Th|1-2|5|c > 2017-09-08|F|3-4|5|b > 2017-09-08|F|3-4|7|c >

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-22 Thread csanyipal
R Smith-2 wrote > On 2018/03/21 9:58 PM, csanyipal wrote: >> >> I am really trying to understand how CTEs works and trying to achive my >> goal >> ( see bellow ) so I modified a little your code: >> ... >> As you can see I tried to add more CTEs into code out there but must >> these >> comment out

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-22 Thread R Smith
On 2018/03/21 9:58 PM, csanyipal wrote: I am really trying to understand how CTEs works and trying to achive my goal ( see bellow ) so I modified a little your code: ... As you can see I tried to add more CTEs into code out there but must these comment out because I get wrong Results. So for

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-21 Thread csanyipal
David Raymond wrote > In the commented out section: > > TimeTable(DoWeek,Grade,Class_) AS > (VALUES('M'),(7),('b'),('M'),(5),('a'),('Tu'),(8),('c')... > > Shouldn't that be ...AS (VALUES ('M', 7, 'B'), ('M', 5, 'a'), ('Tu', 5, > 'c')...? > > WITH PAR(calStartDate, calEndDate) AS (SELECT

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-21 Thread csanyipal
R Smith-2 wrote > On 2018/03/17 12:40 PM, csanyipal wrote: >> R Smith-2 wrote >>> Here is a query that will produce all days of the year (without Sundays) >>> plus their week days (and I've expanded for lesson blocks too, but you >>> will probably need to add/edit as I don't know the exact values,

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-21 Thread David Raymond
...@mailinglists.sqlite.org] On Behalf Of csanyipal Sent: Wednesday, March 21, 2018 3:58 PM To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way? R Smith-2 wrote > On 2018/03/17 12:40 PM, csanyipal wrote: >> R Smith-2 wrote

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-21 Thread csanyipal
R Smith-2 wrote > On 2018/03/17 12:40 PM, csanyipal wrote: >> R Smith-2 wrote >>> Here is a query that will produce all days of the year (without Sundays) >>> plus their week days (and I've expanded for lesson blocks too, but you >>> will probably need to add/edit as I don't know the exact values,

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-17 Thread R Smith
On 2018/03/17 12:40 PM, csanyipal wrote: R Smith-2 wrote Here is a query that will produce all days of the year (without Sundays) plus their week days (and I've expanded for lesson blocks too, but you will probably need to add/edit as I don't know the exact values, but the method should be

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-17 Thread Keith Medcalf
>boun...@mailinglists.sqlite.org] On Behalf Of csanyipal >Sent: Saturday, 17 March, 2018 04:40 >To: sqlite-users@mailinglists.sqlite.org >Subject: Re: [sqlite] Is it possible to CREATE TABLE from other >tables in a complex way? > >R Smith-2 wrote >> Here is a query that will prod

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-17 Thread csanyipal
R Smith-2 wrote > Here is a query that will produce all days of the year (without Sundays) > plus their week days (and I've expanded for lesson blocks too, but you > will probably need to add/edit as I don't know the exact values, but the > method should be clear). You can JOIN this to the

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-11 Thread csanyipal
R Smith-2 wrote > This seems like a whole assignment, and we are not in the habit to do > assignments for people, > > BUT, we can get you started down the path. > > You should know how to do all you are asking by simple RDBMS mechanics, > except maybe how to initialize a table with all dates

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-11 Thread Simon Slavin
On 11 Mar 2018, at 12:05pm, Csányi Pál wrote: > Columns are: id,date,D,lb,g,c,lp,ld,re > > where D is a Day name in Week, > lb is the number of the Lesson Block hour, > g is the grade of a school class, > c is the name of the school class, > lp is LessonPlan, > ld is

Re: [sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-11 Thread R Smith
This seems like a whole assignment, and we are not in the habit to do assignments for people, BUT, we can get you started down the path. You should know how to do all you are asking by simple RDBMS mechanics, except maybe how to initialize a table with all dates and other things

[sqlite] Is it possible to CREATE TABLE from other tables in a complex way?

2018-03-11 Thread Csányi Pál
Hi, is it possible to create a table from other tables with the following conditions? Note! My goal is to create that table 'Hours' with a say 362 records and after that to update those records with UPDATE sql commands. That is, I don't want to INSERT in that table any more records, but just

Re: [sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread Dan Kennedy
On 01/11/2018 12:48 PM, Shane Dev wrote: Thanks, that works Or, if you have a lot of data and an index on "value", this one might be faster: INSERT INTO max_value SELECT value FROM source_value ORDER BY value DESC LIMIT 1; On 11 January 2018 at 06:40, Dan Kennedy

Re: [sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread Shane Dev
Thanks, that works On 11 January 2018 at 06:40, Dan Kennedy wrote: > On 01/11/2018 03:41 AM, Shane Dev wrote: > >> Hi Dan, >> >> Your statement seems to insert a NULL into max_value >> > > So it does. How about this then: > > INSERT INTO max_value SELECT max FROM ( >

Re: [sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread Shane Dev
Hi Peter, Your solution quite simple and obvious in hindsight. Just to be clear - I am using the sqlite3 shell exclusively at the moment and only I post questions when I am stuck with a problem or observe behavior which appears not to be documented. I appreciate the time spent by yourself and

Re: [sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread Dan Kennedy
On 01/11/2018 03:41 AM, Shane Dev wrote: Hi Dan, Your statement seems to insert a NULL into max_value So it does. How about this then: INSERT INTO max_value SELECT max FROM ( SELECT max(value) AS max FROM source_table ) WHERE EXISTS (SELECT 1 FROM source_table); Dan. sqlite>

Re: [sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread petern
Functions and aggregates have to return a scalar value or NULL. Please recall functions as a basic concept from early high school: https://en.wikipedia.org/wiki/Function The query below will never return a NULL max(value) row from the empty_table table: WITH empty_table(value) AS (SELECT 1

Re: [sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread Shane Dev
Hi Ryan, Nice! I have never used IGNORE before. Would you agree the documentation is wrong for the case of SELECT max(X) FROM [an empty table or subquery]? max(X) The max() aggregate function returns the maximum value of all values in the group. The maximum value is the value that would be

Re: [sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread R Smith
Perhaps like this:   -- SQLite version 3.20.1  [ Release: 2017-08-24 ]  on SQLitespeed version 2.0.2.4.   -- Script Items: 4  Parameter Count: 0   -- create table source_table(value);

Re: [sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread Shane Dev
Hi Dan, Your statement seems to insert a NULL into max_value sqlite> delete from source_table; sqlite> delete from max_value; sqlite> INSERT INTO max_value SELECT max(value) FROM source_table WHERE EXISTS (SELECT 1 FROM source_table); sqlite> select * from max_value; max_value sqlite> Erik

Re: [sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread Dan Kennedy
On 01/10/2018 11:48 PM, Shane Dev wrote: Hello, sqlite> create table source_table(value); sqlite> create table max_value(max_value); sqlite> insert into max_value select max(value) from source_table; sqlite> select * from table_max_value; max_value sqlite> How can the maximum value of column

Re: [sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread Nelson, Erik - 2
Can you use something along the lines of this? insert into max_value select value as "value" from source_table order by value desc limit 1; Shane Dev Sent: Wednesday, January 10, 2018 11:49 AM To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> Subject: [sqlite

[sqlite] Is it possible to conditionally insert a record?

2018-01-10 Thread Shane Dev
Hello, sqlite> create table source_table(value); sqlite> create table max_value(max_value); sqlite> insert into max_value select max(value) from source_table; sqlite> select * from table_max_value; max_value sqlite> How can the maximum value of column source_table.value be inserted into

Re: [sqlite] [EXTERNAL] Re: Possible User Defined Function (UDF) Bug?

2017-12-05 Thread Richard Hipp
On 12/5/17, no...@null.net wrote: > On Tue Nov 28, 2017 at 03:30:54PM +, David Raymond wrote: > > SQLite developers, do you recognise this thread as an issue? Not a serious issue, no. I might look into it when I have time, but I'm neck-deep in other issues at the moment. --

Re: [sqlite] [EXTERNAL] Re: Possible User Defined Function (UDF) Bug?

2017-12-05 Thread nomad
On Tue Nov 28, 2017 at 03:30:54PM +, David Raymond wrote: > With an integer primary key, not just any primary key. Probably > something to do with the deterministic flag as well. Looks like in > checking if it's gonna be a good integer for a rowid it calls it > twice. Below you can see where

Re: [sqlite] [EXTERNAL] Re: Possible User Defined Function (UDF) Bug?

2017-11-28 Thread David Raymond
] On Behalf Of Hick Gunter Sent: Tuesday, November 28, 2017 9:35 AM To: 'SQLite mailing list' Subject: Re: [sqlite] [EXTERNAL] Re: Possible User Defined Function (UDF) Bug? I suspect that the udf() function is called once to build the record and once again to build the parameter list for the trig

Re: [sqlite] [EXTERNAL] Re: Possible User Defined Function (UDF) Bug?

2017-11-28 Thread Hick Gunter
. November 2017 15:04 An: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> Betreff: [EXTERNAL] Re: [sqlite] Possible User Defined Function (UDF) Bug? Here is a trimmed-down test case for my issue: CREATE TABLE d ( id INTEGER NOT NULL PRIMA

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-20 Thread Hick Gunter
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Clemens Ladisch Gesendet: Donnerstag, 20. April 2017 09:38 An: sqlite-users@mailinglists.sqlite.org Betreff: Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite? Olivier Mascia wrote: &

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-20 Thread Clemens Ladisch
Olivier Mascia wrote: > As far as I understood, SQLite will parse and compile the trigger text > as part of each statement using them. No bytecode compilation upfront, > nor storage of it. SQLite parses all triggers (and all other schema objects) when it reads the schema (see "struct Trigger"

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-20 Thread Olivier Mascia
> Le 20 avr. 2017 à 01:13, petern a écrit : > > 2. Here is a question. It would be helpful to know if TRIGGERs are stored > as prepared SQLite byte code or not. What does the SQLite engine do > exactly? Anybody? I'm answering to test my understanding, confronting

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-19 Thread petern
1. Forgot to mention. In cases where the WHEN clause is not convenient for trigger style stored procedure condition branching there is also "SELECT raise(ignore) WHERE ": https://sqlite.org/lang_createtrigger.html#raise 2. Here is a question. It would be helpful to know if TRIGGERs are stored

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-19 Thread R Smith
On 2017/04/19 6:58 PM, James K. Lowden wrote: On Sun, 16 Apr 2017 12:01:01 +0200 Darko Volaric wrote: There are good reasons to have stored procedures other than reducing connection latency - developers like to encapsulate logic that is associated entirely with the database

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-19 Thread Simon Slavin
On 19 Apr 2017, at 8:59pm, Domingo Alvarez Duarte wrote: > > What I understood looking at the sqlite3 sources is that an update is always > 3 operations: > > 1- Read old row > > 2- Delete old row > > 3- Insert updated row > > So I seems that using "insert" would be less

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-19 Thread Domingo Alvarez Duarte
Hello ! What I understood looking at the sqlite3 sources is that an update is always 3 operations: 1- Read old row 2- Delete old row 3- Insert updated row So I seems that using "insert" would be less work. Cheers ! On 19/04/17 16:27, Simon Slavin wrote: On 19 Apr 2017, at 7:47pm,

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-19 Thread Simon Slavin
On 19 Apr 2017, at 7:47pm, no...@null.net wrote: > I use > triggers quite heavily as a kind of stored procedure. > > Instead of basing them on views however I use real tables and AFTER > INSERT triggers whose final statement deletes the NEW row just > inserted. > > I see two benefits to the

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-19 Thread nomad
On Wed Apr 19, 2017 at 09:53:07AM -0700, petern wrote: > My sense from these replies is that nobody bothers to try using > triggers to store their SQLite procedural code within the DB. I was > skeptical when I first learned of the technique but the trigger > syntax is very computationally

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-19 Thread James K. Lowden
On Sun, 16 Apr 2017 12:01:01 +0200 Darko Volaric wrote: > There are good reasons to have stored procedures other than reducing > connection latency - developers like to encapsulate logic that is > associated entirely with the database in the database, use them to do > extended

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-19 Thread petern
My sense from these replies is that nobody bothers to try using triggers to store their SQLite procedural code within the DB. I was skeptical when I first learned of the technique but the trigger syntax is very computationally permissive. Frankly, I'm still surprised by what one is allowed to do

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-19 Thread Domingo Alvarez Duarte
Hello Philip ! There was this attempt https://www.sqliteconcepts.org/PL_index.html and I tried to adapt to sqlite3 but the change on the sqlite3 vm compared to sqlite2 made it a lot harder. The vm of sqlite3 is not well documented and is changing all the time. But I also agreed with you if

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-19 Thread Philip Warner
There is another reason to have stored procedures: encapsulating logic across apps/clients. A great deal can be done in triggers, but not much in terms of queries or complex parameterized updates. It would be great, imo, if triggers could have durable local storage (ie. variables) and if

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-16 Thread Simon Slavin
On 16 Apr 2017, at 5:27pm, Jens Alfke wrote: > Is this list archived anywhere convenient? I just google for posts I remember and google usually turns up an archive of this list. googling "sqlite stored procedure latency" turns up

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-16 Thread Jens Alfke
> On Apr 15, 2017, at 2:17 PM, Simon Slavin wrote: > > I do agree that DRH’s explanation of why it’s not as important in SQLite as > in client/server engines is well written. We can point to it when we need it. Is this list archived anywhere convenient? Last time I

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-16 Thread Tim Streater
On 15 Apr 2017 at 22:17, Simon Slavin wrote: > On 15 Apr 2017, at 9:14pm, petern wrote: > >> Yes, please include it in the FAQ > > It’s not a FAQ. Not on this list, at least. I would argue against it. Well he meant on the sqlite website.

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-16 Thread Darko Volaric
If you really wanted to have stored procedures and did not mind calling them using a function syntax, you could write your own stored procedure extension. You'd store them in their own table, write a custom function that evaluates them and call them something like this: sp("name", param1,

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-15 Thread Simon Slavin
On 15 Apr 2017, at 9:14pm, petern wrote: > Yes, please include it in the FAQ It’s not a FAQ. Not on this list, at least. I would argue against it. I do agree that DRH’s explanation of why it’s not as important in SQLite as in client/server engines is well

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-15 Thread petern
Yes, please include it in the FAQ along with a description of the SQLite stored procedure pattern syntax which is never disclosed in these replies: CREATE TRIGGER my_sproc INSTEAD OF INSERT on my_sproc_caller_view BEGIN --My procedural code to be prepared and stored in the database. END;

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-15 Thread Christian Werner
On 04/15/2017 06:18 PM, Richard Hipp wrote: On 4/15/17, Manoj Sengottuvel wrote: Hi Richard, Is it possible to create the Stored Procedure (SP) in Sqlite? if not , is there any alternate way for SP? Short answer: No. Longer answer: With SQLite, your application is

Re: [sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-15 Thread Richard Hipp
On 4/15/17, Manoj Sengottuvel wrote: > Hi Richard, > > Is it possible to create the Stored Procedure (SP) in Sqlite? > > if not , is there any alternate way for SP? Short answer: No. Longer answer: With SQLite, your application is the stored procedure. In a traditional

[sqlite] Is it possible to create the Stored Procedure (SP) in Sqlite?

2017-04-15 Thread Manoj Sengottuvel
Hi Richard, Is it possible to create the Stored Procedure (SP) in Sqlite? if not , is there any alternate way for SP? regards Manoj ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] Is it possible to change "synchronous" flag of ZIPVFS pager?

2017-03-17 Thread Tomasz Maj
sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] Is it possible to change "synchronous" flag of ZIPVFS pager? On 03/16/2017 05:00 PM, Tomasz Maj wrote: > I have an application which work with many zipped databases in WAL journal > mode and the databases are stored on a media of low write band

Re: [sqlite] Is it possible to change "synchronous" flag of ZIPVFS pager?

2017-03-16 Thread Dan Kennedy
iling list Subject: Re: [sqlite] Is it possible to change "synchronous" flag of ZIPVFS pager? 2017-03-16 9:51 GMT+01:00 Dan Kennedy <danielk1...@gmail.com>: On 03/16/2017 01:40 PM, Tomasz Maj wrote: Hi, According to my observations, "PRAGMA synchronous=...;" query affect

Re: [sqlite] Is it possible to change "synchronous" flag of ZIPVFS pager?

2017-03-16 Thread Tomasz Maj
oun...@mailinglists.sqlite.org> on behalf of Tomek Maj <majek...@gmail.com> Sent: Thursday, March 16, 2017 10:50:37 AM To: SQLite mailing list Subject: Re: [sqlite] Is it possible to change "synchronous" flag of ZIPVFS pager? 2017-03-16 9:51 GMT+01:00 Dan Kennedy <danielk1...@gmail.com>: >

Re: [sqlite] Is it possible to change "synchronous" flag of ZIPVFS pager?

2017-03-16 Thread Tomek Maj
2017-03-16 9:51 GMT+01:00 Dan Kennedy : > On 03/16/2017 01:40 PM, Tomasz Maj wrote: > >> Hi, >> >> >> According to my observations, "PRAGMA synchronous=...;" query affects >> only the standard sqlite pager. But for zipped databases sqlite uses >> additional ZIPVFS pager

Re: [sqlite] Is it possible to change "synchronous" flag of ZIPVFS pager?

2017-03-16 Thread Dan Kennedy
On 03/16/2017 01:40 PM, Tomasz Maj wrote: Hi, According to my observations, "PRAGMA synchronous=...;" query affects only the standard sqlite pager. But for zipped databases sqlite uses additional ZIPVFS pager layer which actually decide whether and when to sync content of files associated

[sqlite] Is it possible to change "synchronous" flag of ZIPVFS pager?

2017-03-16 Thread Tomasz Maj
Hi, According to my observations, "PRAGMA synchronous=...;" query affects only the standard sqlite pager. But for zipped databases sqlite uses additional ZIPVFS pager layer which actually decide whether and when to sync content of files associated with a database. It looks like "PRAGMA

  1   2   3   4   5   >