Re: [sqlite] using sqlite calculated field

2011-12-19 Thread Kees Nuyt
On Sun, 18 Dec 2011 21:20:00 -0300, Esteban Cervetto estebancs...@gmail.com 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

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)); x

[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

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. . .

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 two

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 understands this. See

[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)

[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

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

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) when I

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 behavior in

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] 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] 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 statement IF condition. And remember that the WHERE clause can refer to all sorts of things, including parameters from the application (something like WHERE @foo =

[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

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 rom...@gmail.com 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?

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 romtek
On Mon, Dec 19, 2011 at 11:23 PM, Roger Binns rog...@rogerbinns.com 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