Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-06-03 Thread Jay A. Kreibich
On Tue, Jun 03, 2008 at 02:27:01PM -0600, Dennis Cote scratched on the wall: > Jay A. Kreibich wrote: > > > > That, or something like sqlite3_clear_bindings() that actually > > *clears* the bindings (e.g. whatever state they are in just after a > > prepare), and not just sets them to an

Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-06-03 Thread Stephen Oberholtzer
On Tue, Jun 3, 2008 at 5:09 PM, Alex Katebi <[EMAIL PROTECTED]> wrote: > It would be nice to be able to revert back to the default value for a > column. I don't think SQLite support this right now. > The closest thing I found is "pragma table_info(foo)". If you prepare this > and then grab the

Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-06-03 Thread Alex Katebi
It would be nice to be able to revert back to the default value for a column. I don't think SQLite support this right now. The closest thing I found is "pragma table_info(foo)". If you prepare this and then grab the dflt_value for your column. On Tue, May 20, 2008 at 2:33 PM, Jeff Hamilton <[EMAIL

Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-06-03 Thread Dennis Cote
Jay A. Kreibich wrote: > > That, or something like sqlite3_clear_bindings() that actually > *clears* the bindings (e.g. whatever state they are in just after a > prepare), and not just sets them to an explicit NULL, as the current > function does. > Jay, That wouldn't help. The default

Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-06-03 Thread Jay A. Kreibich
On Tue, Jun 03, 2008 at 02:51:57PM -0500, Jeff Hamilton scratched on the wall: > On Tue, May 20, 2008 at 2:56 PM, D. Richard Hipp <[EMAIL PROTECTED]> wrote: > > OK. How about: > > > > INSERT INTO foo(bar) VALUES(coalesce(?,'default-value')); > > This approach is working well for us, but as

Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-06-03 Thread Jeff Hamilton
On Tue, May 20, 2008 at 2:56 PM, D. Richard Hipp <[EMAIL PROTECTED]> wrote: > OK. How about: > > INSERT INTO foo(bar) VALUES(coalesce(?,'default-value')); This approach is working well for us, but as Dennis pointed out it won't work for all situations. I wonder if it's worth adding something

Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-05-22 Thread Dennis Cote
Eric Minbiole wrote: >> I have a table like this >> >> CREATE TABLE foo (bar TEXT NOT NULL DEFAULT 'default_value'); >> >> and I'd like to create a reusable statement to do inserts into foo, like >> this: >> >> INSERT INTO foo (bar) VALUES (?); >> >> Sometimes I have values for bar and sometimes

Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-05-20 Thread D. Richard Hipp
On May 20, 2008, at 3:40 PM, Jeff Hamilton wrote: > This works in the simple case that I described, but in practice I'd > like to use the pattern on more complex tables that have existing > uniqueness constraints. Using REPLACE INTO will get in the way of > those constraints. > OK. How about:

Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-05-20 Thread Jeff Hamilton
This works in the simple case that I described, but in practice I'd like to use the pattern on more complex tables that have existing uniqueness constraints. Using REPLACE INTO will get in the way of those constraints. Regarding multiple statements, the tables I'd like to use this pattern on have

Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-05-20 Thread Eric Minbiole
> I have a table like this > > CREATE TABLE foo (bar TEXT NOT NULL DEFAULT 'default_value'); > > and I'd like to create a reusable statement to do inserts into foo, like this: > > INSERT INTO foo (bar) VALUES (?); > > Sometimes I have values for bar and sometimes I don't and want the >

Re: [sqlite] Bind arguments for insert and not null columns with default values

2008-05-20 Thread D. Richard Hipp
On May 20, 2008, at 2:33 PM, Jeff Hamilton wrote: > Hi all, > > I have a table like this > > CREATE TABLE foo (bar TEXT NOT NULL DEFAULT 'default_value'); > > and I'd like to create a reusable statement to do inserts into foo, > like this: > > INSERT INTO foo (bar) VALUES (?); > > Sometimes I

[sqlite] Bind arguments for insert and not null columns with default values

2008-05-20 Thread Jeff Hamilton
Hi all, I have a table like this CREATE TABLE foo (bar TEXT NOT NULL DEFAULT 'default_value'); and I'd like to create a reusable statement to do inserts into foo, like this: INSERT INTO foo (bar) VALUES (?); Sometimes I have values for bar and sometimes I don't and want the default. Is there