[OT] SQL question

Malte Brill revolution at derbrill.de
Mon Nov 11 06:00:34 EST 2013

Hi all,

I am tearing my hair out on an SQL query. Before I lose my marbles I'd better ask here:

given are 2 tables



table 2

I need to do an INSERT into table 2. 

running_number should always be the last inserted running_number +1, if datasets for UUID are already present in table 2, otherwise, if no data is present for UUID,  it should be table1s first_number +1 for the given UUID.

Anybody can help me to put this into a single query? (reason I need it in one query is, that there might be concurring connections to the DB and I want to lock the table first on postGreSQL)

All the best,


More information about the Use-livecode mailing list