Re: [sqlite] CASE WHEN sample ?
Am 11.05.2008 um 22:25 schrieb Igor Tandetnik: > "Lothar Behrens" > <[EMAIL PROTECTED]> wrote in > message news:[EMAIL PROTECTED] >> Unique index and using replace into ... changes the primary key value, >> what I cannot handle yet, because I am using triggers >> to force foreign key referential integrity and updating is not yet >> implemented. > > Use simple INSERT, it will fail if uniqueness is violated, preserving > your id. > Now I am using that and INSERT OR IGNORE INTO. Thanks, Lothar > Igor Tandetnik > > > > ___ > 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] CASE WHEN sample ?
"Lothar Behrens" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Unique index and using replace into ... changes the primary key value, > what I cannot handle yet, because I am using triggers > to force foreign key referential integrity and updating is not yet > implemented. Use simple INSERT, it will fail if uniqueness is violated, preserving your id. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] CASE WHEN sample ?
Thanks, I will answer to both postings: Unique index and using replace into ... changes the primary key value, what I cannot handle yet, because I am using triggers to force foreign key referential integrity and updating is not yet implemented. Am 11.05.2008 um 04:23 schrieb Harold Wood & Meyuni Gani: > Better would be > Insert into tablea(ida, value1a) > Select idb, value1b > from tableb > where idb not in(select ida from tablea); > I do not understand this. Do I have to use a second table, tempory table or alias ? If my table is Application, is this then correct ? INSERT INTO "Application" (id, name) SELECT id, 'lbDMF Manager' from "Application" where id not in (SELECT id from "Application") It works syntactically (in sqliteman) but has no effect. Thanks Lothar > Woody > from his pda > > -Original Message- > From: Lothar Behrens <[EMAIL PROTECTED]> > Sent: Saturday, May 10, 2008 2:23 PM > To: sqlite-users@sqlite.org > Subject: [sqlite] CASE WHEN sample ? > > Hi, > > I am searching for a sample that uses the case when expression. > I like to insert values into a table when these values are not in that > table before. > > My tries to read, understand and try the documentation of expressions > failed. > > Executing this statemen twice creates two rows: > > replace into anwendungen (name) values ('lbDMF Manager') > > This is pseudo code: > > if not exsists (select id from mytable where name = 'some name') > insert into mytable (name) values ('some name') > > Is this possible ? > > Thanks > > Lothar > > ___ > 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 > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] CASE WHEN sample ?
Better would be Insert into tablea(ida, value1a) Select idb, value1b from tableb where idb not in(select ida from tablea); Woody from his pda -Original Message- From: Lothar Behrens <[EMAIL PROTECTED]> Sent: Saturday, May 10, 2008 2:23 PM To: sqlite-users@sqlite.org Subject: [sqlite] CASE WHEN sample ? Hi, I am searching for a sample that uses the case when expression. I like to insert values into a table when these values are not in that table before. My tries to read, understand and try the documentation of expressions failed. Executing this statemen twice creates two rows: replace into anwendungen (name) values ('lbDMF Manager') This is pseudo code: if not exsists (select id from mytable where name = 'some name') insert into mytable (name) values ('some name') Is this possible ? Thanks Lothar ___ 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] CASE WHEN sample ?
"Lothar Behrens" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Executing this statemen twice creates two rows: > > replace into anwendungen (name) values ('lbDMF Manager') Make "name" column unique, or create a unique index on it. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] CASE WHEN sample ?
Hi, I am searching for a sample that uses the case when expression. I like to insert values into a table when these values are not in that table before. My tries to read, understand and try the documentation of expressions failed. Executing this statemen twice creates two rows: replace into anwendungen (name) values ('lbDMF Manager') This is pseudo code: if not exsists (select id from mytable where name = 'some name') insert into mytable (name) values ('some name') Is this possible ? Thanks Lothar ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users