Re: [sqlite] how can we solve IF EXIST in SQLite

2009-08-19 Thread Asif Lodhi
Sorry, I don't see EXISTS in SQLite documentation. On 8/20/09, Asif Lodhi wrote: > Hi, > > Perhaps you can do this in TWO SQL STATEMENTS - see below. However, > this way you inefficiently check the existence twice: > > On 6/2/09, robinsmathew wrote: >> IF EXISTS (SELECT prod_batch_code FROM stoc

Re: [sqlite] how can we solve IF EXIST in SQLite

2009-08-19 Thread Asif Lodhi
Hi, Perhaps you can do this in TWO SQL STATEMENTS - see below. However, this way you inefficiently check the existence twice: On 6/2/09, robinsmathew wrote: > IF EXISTS (SELECT prod_batch_code FROM stock_tab WHERE prod_batch_code=1000) > UPDATE stock_tab > SET stock_qty=stock_qty

[sqlite] Huge numbers of save points.

2009-08-19 Thread Chris Dew
http://www.sqlite.org/lang_savepoint.html I'm looking for a datastore with the following properties: * I need to 'mark' the state frequently (sub second interval). * I need to be able to revert the datastore to a previous mark (with no appreciable delay). * I only need to keep the last few hundr

[sqlite] SUGGESTION: sqlite3 and TMP environment variable

2009-08-19 Thread Roger Paratore Bock
If I set PRAGMA temp_store = MEMORY; and PRAGMA temp_store_directory = 'C:\scratch'; but TMP is set to an invalid directory, I get the following error sqlite3.OperationalError: unable to open database file Two suggestions: 1) If temp_store_directory is set, sqlite should not care what TMP is

[sqlite] Huge numbers of savepoints.

2009-08-19 Thread Chris Dew
http://www.sqlite.org/lang_savepoint.html I'm looking for a datastore with the following properties: * I need to 'mark' the state frequently (sub second interval). * I need to be able to revert the datastore to a previous mark (with no appreciable delay). * I only need to keep the last few hundr

Re: [sqlite] how can we solve IF EXIST in SQLite

2009-08-19 Thread sub sk79
Hi, You might want to check-out StepSqlite PL/SQL compiler for SQLite at http://www.metatranz.com/stepsqlite Using it you can write the trigger (as part of a package body) almost the way you wrote in original post. StepSqlite compiles the PL/SQL code to a linux x86 shared library which can be link

[sqlite] building an extension

2009-08-19 Thread P Kishor
are the following instructions at http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions for building a loadable extension still valid? How To Build a Loadable Extension Shared Library on Linux 0. untar latest sqlite3 source code in a new directory 1. cd to the newly untarred sqlite directory 2.

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread Kit
2009/8/19 Mário Anselmo Scandelari Bussmann : > Both work for me, Kit solution is very fast, but I think John is right. In > my case, the tables have sequencial rowid. If I delete some row, then will > not work anymore. When you create an index of column data, John's solution will be fast too. --

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread Mário Anselmo Scandelari Bussmann
Both work for me, Kit solution is very fast, but I think John is right. In my case, the tables have sequencial rowid. If I delete some row, then will not work anymore. On Wed, Aug 19, 2009 at 12:44 PM, John Machin wrote: > On 20/08/2009 12:57 AM, Kit wrote: > > Right form (tested): > > > > SELE

Re: [sqlite] Increment a value if constraint violated

2009-08-19 Thread Pavel Ivanov
> Are you sure that was the OP's intention? No, I'm not sure, of course, because OP didn't answer yet. But words "First row with id 3" and "Third row with id 3" suggested to me that they are different rows. And mentioning SQLITE_CONSTRAINT I've interpreted as "unique constraint on id-count pair".

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread Kit
2009/8/19 John Machin : > On 20/08/2009 12:57 AM, Kit wrote: >> Right form (tested): >> >> SELECT petr4.data AS data,petr4.preult AS preult,temp.data AS >> previous_data,temp.preult AS previous_preult >>FROM petr4,petr4 AS temp >>WHERE petr4.rowid=temp.rowid+1; > > Don't you think that rely

Re: [sqlite] Increment a value if constraint violated

2009-08-19 Thread Igor Tandetnik
Pavel Ivanov wrote: >> insert or replace into mytable(id, count) >> values (:id, coalesce((select count from mytable where id=:id), 0) + >> 1); > > I guess it doesn't work as OP intended: > > sqlite> select * from t; > id|count > 1|1 > 1|2 > 1|3 > 1|4 Are you sure that was the OP's intention? His

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread John Machin
On 20/08/2009 12:57 AM, Kit wrote: > Right form (tested): > > SELECT petr4.data AS data,petr4.preult AS preult,temp.data AS > previous_data,temp.preult AS previous_preult >FROM petr4,petr4 AS temp >WHERE petr4.rowid=temp.rowid+1; Don't you think that relying on (a) rowid being consecutive

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread Mário Anselmo Scandelari Bussmann
I said its slow but I forget index. Now is as fast as a lightningbolt!! Thanks again! On Wed, Aug 19, 2009 at 12:23 PM, Mário Anselmo Scandelari Bussmann < mario.bussm...@gmail.com> wrote: > Bingo! This works very well (a little bit slow, since I have a 30 > rows). Thank you all!!! > > > On W

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread Mário Anselmo Scandelari Bussmann
Bingo! This works very well (a little bit slow, since I have a 30 rows). Thank you all!!! On Wed, Aug 19, 2009 at 11:42 AM, John Machin wrote: > On 20/08/2009 12:10 AM, Mário Anselmo Scandelari Bussmann wrote: > > I have a table like this: > > > > petr4 > > --- > > rowid|data|preabe|

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread Kit
Right form (tested): SELECT petr4.data AS data,petr4.preult AS preult,temp.data AS previous_data,temp.preult AS previous_preult FROM petr4,petr4 AS temp WHERE petr4.rowid=temp.rowid+1; -- Kit ___ sqlite-users mailing list sqlite-users@sqlite.org h

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread John Machin
On 20/08/2009 12:10 AM, Mário Anselmo Scandelari Bussmann wrote: > I have a table like this: > > petr4 > --- > rowid|data|preabe|premax|premin|preult|voltot > 1|2007-01-02|50.0|50.45|49.76|50.45|256115409.0 > 2|2007-01-03|50.16|50.4|48.01|48.7|492591256.0 [snip] > 9|2007-01-12|45.3|45.61|4

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread Kit
2009/8/19 Mário Anselmo Scandelari Bussmann : > I have a table like this: > > petr4 > --- > rowid|data|preabe|premax|premin|preult|voltot > 1|2007-01-02|50.0|50.45|49.76|50.45|256115409.0 > 2|2007-01-03|50.16|50.4|48.01|48.7|492591256.0 > 3|2007-01-04|48.5|48.75|47.4|47.65|505916186.0 > 4|2

Re: [sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread Pavel Ivanov
Without looking at your select statement it's very hard to help. But general suggestion is insert your results into temporary table and then issue a select on that table joined with itself with condition like t.rowid = prev.rowid + 1. Pavel On Wed, Aug 19, 2009 at 10:10 AM, Mário Anselmo Scandela

[sqlite] How to select data from 2 lines in one line?

2009-08-19 Thread Mário Anselmo Scandelari Bussmann
I have a table like this: petr4 --- rowid|data|preabe|premax|premin|preult|voltot 1|2007-01-02|50.0|50.45|49.76|50.45|256115409.0 2|2007-01-03|50.16|50.4|48.01|48.7|492591256.0 3|2007-01-04|48.5|48.75|47.4|47.65|505916186.0 4|2007-01-05|47.2|47.99|45.1|46.19|581485748.0 5|2007-01-08|46.5|4

Re: [sqlite] PRAGMA locking_mode could stand a rewrite

2009-08-19 Thread Pavel Ivanov
> 1. When is a lock released during a SELECT? Is it after the first > call to step()? The last call to step()? The call to finalize()? > Yes, I'm using the C API. Lock is released during the call to finalize() or reset(). > 2. If while in the step() process of a SELECT, there is a c

Re: [sqlite] Huge numbers of savepoints.

2009-08-19 Thread Pavel Ivanov
But how do you expect your application to deal with restarts and/or OS crashes? Do you want to still be able to revert to "marks" set in previous application run or not? And what about accessing to the data stored between "marks" from other processes? Pavel On Wed, Aug 19, 2009 at 4:07 AM, Chris

Re: [sqlite] SQL documentation

2009-08-19 Thread Pavel Ivanov
Personally for me the current documentation style is more understandable at a glance. Looking at it it's easier for me to understand the sequence of terms I should use, what can be omitted, what terms cannot be used together and so on. Old style looks for me more like list of requirements for progr

Re: [sqlite] Increment a value if constraint violated

2009-08-19 Thread Pavel Ivanov
> insert or replace into mytable(id, count) > values (:id, coalesce((select count from mytable where id=:id), 0) + 1); I guess it doesn't work as OP intended: sqlite> select * from t; id|count 1|1 1|2 1|3 1|4 sqlite> insert or replace into t(id, count) values (1, coalesce((select count from t whe

[sqlite] PRAGMA locking_mode could stand a rewrite

2009-08-19 Thread Angus March
For one thing, they shouldn't be using the word "exclusive" to mean two different things. There's "locking_mode=EXCLUSIVE" meaning "permanent" and "exclusive lock" meaning "write lock". At least I think that's what they mean. But my problem is understanding exactly when a lock is released durin

Re: [sqlite] Huge numbers of savepoints.

2009-08-19 Thread Dan Kennedy
On Aug 19, 2009, at 3:07 PM, Chris Dew wrote: > http://www.sqlite.org/lang_savepoint.html > I'm looking for a datastore with the following properties: > * I need to 'mark' the state frequently (sub second interval). > * I need to be able to revert the datastore to a previous mark (with > no > a

[sqlite] Huge numbers of savepoints.

2009-08-19 Thread Chris Dew
http://www.sqlite.org/lang_savepoint.html I'm looking for a datastore with the following properties: * I need to 'mark' the state frequently (sub second interval). * I need to be able to revert the datastore to a previous mark (with no appreciable delay). * I only need to keep the last few hundr

[sqlite] SQL documentation

2009-08-19 Thread Glenn Maynard
SQLite had extremely readable SQL documentation: http://www.3rd-impact.net/Document/SQLite/Translation/Current/Original/lang_createtable.html. It was clear and intuitive; I can understand it at a glance. At some point, it was replaced with http://sqlite.org/lang_createtable.html. It's closer to