Re: [sqlite] Inserting a row with all defaults set in table
Perfect. Thanks guys. On Sat, Oct 25, 2014 at 10:03 AM, Simon Davieswrote: > On 25 October 2014 14:49, Stephen Chrzanowski wrote: > > I've got a table that has defaults set for all fields > > > > CREATE TABLE [tEvents] ( > > [EventID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, > > [Airline] CHAR DEFAULT '', > > [TicketID] INTEGER DEFAULT 0, > > [Resolved] BOOL DEFAULT 0); > > > > > > Seems to me it'd be a bit redundant to do an "insert into tEvents > > (TicketID) values (0)" when the default is already set (And who says I > may > > not want to change the default later to -1 for whatever reason?). > > > > The question is, how would I insert a blank row and rely on the defaults > > I've got in the schema? "insert into tEvents () values ()" fails, as > does > > removing the first pair of brackets, as well as removing all brackets. > > INSERT INTO tEvents( EventId ) VALUES( null ); > > Regards, > Simon > ___ > 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
Re: [sqlite] Inserting a row with all defaults set in table
On 25 October 2014 14:49, Stephen Chrzanowskiwrote: > I've got a table that has defaults set for all fields > > CREATE TABLE [tEvents] ( > [EventID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, > [Airline] CHAR DEFAULT '', > [TicketID] INTEGER DEFAULT 0, > [Resolved] BOOL DEFAULT 0); > > > Seems to me it'd be a bit redundant to do an "insert into tEvents > (TicketID) values (0)" when the default is already set (And who says I may > not want to change the default later to -1 for whatever reason?). > > The question is, how would I insert a blank row and rely on the defaults > I've got in the schema? "insert into tEvents () values ()" fails, as does > removing the first pair of brackets, as well as removing all brackets. INSERT INTO tEvents( EventId ) VALUES( null ); Regards, Simon ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Inserting a row with all defaults set in table
On Sat, Oct 25, 2014 at 9:49 AM, Stephen Chrzanowskiwrote: > I've got a table that has defaults set for all fields > > CREATE TABLE [tEvents] ( > [EventID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, > [Airline] CHAR DEFAULT '', > [TicketID] INTEGER DEFAULT 0, > [Resolved] BOOL DEFAULT 0); > > > The question is, how would I insert a blank row and rely on the defaults > I've got in the schema? > INSERT INTO tEvents DEFAULT VALUES; -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Inserting a row with all defaults set in table
I've got a table that has defaults set for all fields CREATE TABLE [tEvents] ( [EventID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [Airline] CHAR DEFAULT '', [TicketID] INTEGER DEFAULT 0, [Resolved] BOOL DEFAULT 0); Seems to me it'd be a bit redundant to do an "insert into tEvents (TicketID) values (0)" when the default is already set (And who says I may not want to change the default later to -1 for whatever reason?). The question is, how would I insert a blank row and rely on the defaults I've got in the schema? "insert into tEvents () values ()" fails, as does removing the first pair of brackets, as well as removing all brackets. I plan on getting the last_insert_row value after I do the insert to do other things on my form, and at that point, I don't care what the other fields are, as they'll be blank on the field anyways. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users