Re: [sqlite] Bug in trigger: when comparing a value of an int column to a quoted value

2011-12-19 Thread romtek
On Mon, Dec 19, 2011 at 11:23 PM, Roger Binns wrote: > > > On 19/12/11 20:31, romtek wrote: > > As you can see, isActive is declared as an integer in table2, > > > This type of thing worked for years with an older version of SQLite > > library > > Are you sure? Absolutely. I have the same DB file

Re: [sqlite] Bug in trigger: when comparing a value of an int column to a quoted value

2011-12-19 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 19/12/11 20:31, romtek wrote: > As you can see, isActive is declared as an integer in table2, That declaration only does type coercion on the value stored in the database (if appropriate). > ... when I expect it to be activated ... Why would you

Re: [sqlite] Bug in trigger: when comparing a value of an int column to a quoted value

2011-12-19 Thread Nico Williams
On Mon, Dec 19, 2011 at 10:31 PM, romtek wrote: > I've always thought that because SQLite didn't enforce data types, I could > do what I have in the example, and this has worked! So, is this a bug in > more recent versions of SQLite or an intended change that I am unaware of? SQLite3 doesn't do a

[sqlite] Bug in trigger: when comparing a value of an int column to a quoted value

2011-12-19 Thread romtek
Hi, I would like to know if I am dealing with a bug or a backward incompatible change that I am not aware of. Consider this example: CREATE TABLE [table2] ( [id] INTEGER NOT NULL ON CONFLICT FAIL PRIMARY KEY ON CONFLICT FAIL AUTOINCREMENT, [isActive] INTEGER NOT NULL ON CONFLICT FAIL DEFAULT

Re: [sqlite] Procedure (Conditional statement) workaround

2011-12-19 Thread Nico Williams
You can do conditionals via WHERE clauses, as others have pointed out. You can also use WHEN clauses on triggers. Think of it as IF . And remember that the WHERE clause can refer to all sorts of things, including parameters from the application (something like WHERE @foo = 1). You can do itera

Re: [sqlite] Binding C for numeric type

2011-12-19 Thread Alexandre K
Well, when I quiclky read the paragraph about types I understood that they were existing... In fact not, so I completly agree with your solution, It seems to be the best one to allow comparison or sum. I will save the 'cents' in integer and do multiplication and division and you said. Thanks for

Re: [sqlite] Binding C for numeric type

2011-12-19 Thread Simon Slavin
On 19 Dec 2011, at 7:18pm, Alexandre K wrote: > @Simon : Do you mean to store as integer or string whereas the Numeric > (x,y) column type exists, in order to have a nice binding in C ? The numeric (x,y) column type does not exist. SQLite supports only the following five types:

Re: [sqlite] Strange behavior for timeouts in transactions

2011-12-19 Thread Pavel Ivanov
> 5. Enter the following in session 2 (demonstrates unexpected behavior): > >       .timeout 1 >       begin; >       select * from my_table; >       update my_table set userid=1; > >    -> A 'database locked' error message is returned immediately. > >       rollback; > > Is this the expected b

Re: [sqlite] Error: disk I/O error while creating an index

2011-12-19 Thread Simon Slavin
On 19 Dec 2011, at 7:04pm, Tal Tabakman wrote: > 1. I am using version 3.3.6 of sqlite. > > 2. My journal mode is memory > > 3. I am opening a transaction and then do 5 inserts before > committing and opening a new transaction > > > given the above, what are the requirnments (disk-wise) w

Re: [sqlite] Binding C for numeric type

2011-12-19 Thread Alexandre K
> Thanks Sean and Simon :) @Seam : The library seems interesting, but I would not use an external library, as I use C as interface for Ada. @Simon : Do you mean to store as integer or string whereas the Numeric (x,y) column type exists, in order to have a nice binding in C ? It's sure that I want

[sqlite] Strange behavior for timeouts in transactions

2011-12-19 Thread Sigurdur Ragnarsson
I have observed a peculiar behavior for timeouts in transactions when a transaction begins with a 'select' statement. Basically, it seems like the timeout setting is not honored in this instance and if an 'update' statement follows the 'select' statement, a 'database locked' error message is immed

[sqlite] Error: disk I/O error while creating an index

2011-12-19 Thread Tal Tabakman
Hi Simon, thanks for the response below. as for your questions: 1. I am using version 3.3.6 of sqlite. 2. My journal mode is memory 3. I am opening a transaction and then do 5 inserts before committing and opening a new transaction given the above, what are the requirnments (disk-wise)

Re: [sqlite] primary key and rowid

2011-12-19 Thread David Garfield
Simon Slavin writes: > > On 19 Dec 2011, at 7:04am, YJM YAN wrote: > > //Second way create primary key: > > CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x AUTOINCREMENT)); > > "x" being an alias for the rowid? > > Second way will work too. It correctly declares "x INTEGER" and SQLite > understan

Re: [sqlite] Binding C for numeric type

2011-12-19 Thread Simon Slavin
On 19 Dec 2011, at 4:38pm, Alexandre K wrote: > I have a question about C binding for sqlite. I have seen those for > integer, float... but I was wondering how to deal with a NUMERIC (x, y) > type ? > We can't use float or double, we could loose precision, so maybe with a > string ? There are tw

Re: [sqlite] Binding C for numeric type

2011-12-19 Thread Sean Pieper
I'm assuming you care about rounding and precision because you are doing some sort of financial application. In that case, you'd want to be doing decimal floating point math. This library will probably do the job for you, but there should be arbitrary precision libraries out there if not. . . h

[sqlite] Binding C for numeric type

2011-12-19 Thread Alexandre K
Hi everone ! I have a question about C binding for sqlite. I have seen those for integer, float... but I was wondering how to deal with a NUMERIC (x, y) type ? We can't use float or double, we could loose precision, so maybe with a string ? If someone has a solution, I will really help me. Thanks i

Re: [sqlite] primary key and rowid

2011-12-19 Thread Simon Slavin
On 19 Dec 2011, at 7:04am, YJM YAN wrote: > //First way create primary key: > CREATE TABLE t(x INTEGER PRIMARY KEY AUTOINCREMENT, y, z); > "x" being an alias for the rowid? First way will work. > //Second way create primary key: > CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x AUTOINCREMENT)); >

Re: [sqlite] using sqlite calculated field

2011-12-19 Thread Kees Nuyt
On Sun, 18 Dec 2011 21:20:00 -0300, Esteban Cervetto wrote: > END) AS 'INDEM' INDEM should not be quoted. Single quotes are used for text literals. If you want to quote identifiers (e.g. because they are keywords) use backticks `identifier` or double quotes "identifier" or brackets [identifier