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 multiple columns with default values, so the number of
required statements for all cases can get fairly large.

-Jeff

On Tue, May 20, 2008 at 11:40 AM, D. Richard Hipp <[EMAIL PROTECTED]> wrote:
>
> 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 have values for bar and sometimes I don't and want the
>> default. Is there any way to indicate to the statement that I want the
>> bound parameter to be "nothing" therefore giving me the default value?
>> If I bind that column to NULL I get a constraint error.
>>
>
> REPLACE INTO foo(bar) VALUES(?)
>
> D. Richard Hipp
> [EMAIL PROTECTED]
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to