On Wed, 3 Jun 2009 00:42:53 -0700 (PDT), Harold Wood <hwoody2w...@yahoo.com> wrote:
>you should use the insert or replace statement, >it inserts if the row doesnt exist, if the row >does exists then it updates the row. No, that doesn't fulfil the requirement, because quantity isn't incremented. >--- On Wed, 6/3/09, robinsmathew <robinsmat...@hotmail.com> wrote: > > >From: robinsmathew <robinsmat...@hotmail.com> >Subject: Re: [sqlite] how can we solve IF EXIST in SQLite >To: sqlite-users@sqlite.org >Date: Wednesday, June 3, 2009, 3:15 AM > > > >its showing an error near "if": syntax error > > >Kees Nuyt wrote: >> >> On Tue, 2 Jun 2009 03:36:46 -0700 (PDT), robinsmathew >> <robinsmat...@hotmail.com> wrote: >> >>> >>>hey thanx for the reply... u leave the things happening inside.. wat i jus >>>wanna do is i wanna insert a new row to a table >>>the table will be like this >>>stock_id PK product_id FK quantity stock_date >>>10000 1000 10 28-05-2009 >>>10001 1001 5 27-05-2009 >>> >>>and wen i insert a new row with values NULL, 1000, 15, 30-05-2009 >>> >>>i dont want want it as a new recorde i jus want to update the first row >coz >>>its also having the same product id i jus want set the quantity = 10+15 >and >>>the date new date that is 30-05-2009 >>>and suppose if i insert row with different product_id it should be >inserted >>>as it is.. >> >> Pseudocode: >> BEGIN; >> UPDATE stock_tab SET ..... WHERE stock_id = 10000; >> if sqlite_error() >> INSERT INTO stock_tab SET (...) VALUES (...); >> endif >> COMMIT; >> -- >> ( Kees Nuyt -- ( Kees Nuyt ) c[_] _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users