[sqlite] foreign key problems

2009-06-05 Thread robinsmathew
hey i hve created a table CREATE TABLE video_tab (video_id INTEGER, project_id INTEGER, video_path VARCHAR(100), video_length INTEGER, video_type VARCHAR(10), video_size VARCHAR(10), CONSTRAINT video_pk PRIMARY KEY(video_id, project_id), CONSTRAINT fk_project_id FOREIGN KEY (project_id) REFERENC

Re: [sqlite] how can we solve IF EXIST in SQLite

2009-06-03 Thread robinsmathew
its showing an error near "if": syntax error Kees Nuyt wrote: > > On Tue, 2 Jun 2009 03:36:46 -0700 (PDT), robinsmathew > wrote: > >> >>hey thanx for the reply... u leave the things happening inside.. wat i jus >>wanna do is i wanna insert a new row

Re: [sqlite] how can we solve IF EXIST in SQLite

2009-06-02 Thread robinsmathew
new.purchase_id+2, new.prod_batch_code, > new.purchase_qty + ifnull(b.stock_qty, 0), new.purchase_date >FROM (SELECT new.prod_batch_code) a > LEFT JOIN stock_tab b ON b.prod_batch_code = > a.prod_batch_code > > > Pavel > > On Tue, Jun 2, 2009 at

Re: [sqlite] how can we solve IF EXIST in SQLite

2009-06-02 Thread robinsmathew
gt; Date: Tue, 02 Jun 2009 12:46:58 +0200 > > Hi, > > as far as I know, you cannot do what you want to do in pure SQL. > However, perhaps someone cleverer can contradict me. > > You could first execute the update statement, check if there was a row > which was updated using sqlite

Re: [sqlite] how can we solve IF EXIST in SQLite

2009-06-02 Thread robinsmathew
sqlite3_changes() (see > http://www.sqlite.org/capi3ref.html#sqlite3_changes), and then issue the > insert if there was none. > > Martin > > robinsmathew wrote: >> hey thanx for the reply... u leave the things happening inside.. wat i >> jus >> wanna do is i w

Re: [sqlite] how can we solve IF EXIST in SQLite

2009-06-02 Thread robinsmathew
nsert or replace" (see > http://www.sqlite.org/lang_insert.html), because you look first for a > record with prod_batch_code=1000, and if you do not find it you insert > one with prod_batch_code = 1003. > S,. it seems to me that you have to implement the logic in your > application. &g

[sqlite] how can we solve IF EXIST in SQLite

2009-06-02 Thread robinsmathew
hi am new to SQLite can anybody please tell me how this query can be solved in SQLite? IF EXISTS (SELECT prod_batch_code FROM stock_tab WHERE prod_batch_code=1000) UPDATE stock_tab SET stock_qty=stock_qty+(SELECT purchase_qty ROM purchase_tab WHERE oduct_batch_code=1000 )