[OT] SQL question
Pierre Sahores
sc at sahores-conseil.com
Mon Nov 11 06:40:24 EST 2013
Hi Malte,
No sure that you can design such kind of request as long as write-mode requests don't handle heritage under PostgreSQL. If you use PG v 9.xx, you can try :
http://docs.postgresql.fr/9.0/rules.html
else, as long as PG nor LC-server will never be the bottleneck in about speed, ram and processor's cycles (Apache is, at least, teen time slower than PG or LC-Server), you should be OK in handling a serial of two requests (select + conditional insert) handled by some lc-script code.
Best,
Pierre
Le 11 nov. 2013 à 12:00, Malte Brill a écrit :
> 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
>
> table1
>
> ID,UUID,first_number
>
>
> table 2
>
> ID,UUID,running_number
> 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,
>
> Malte
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
--
Pierre Sahores
mobile : 06 03 95 77 70
www.sahores-conseil.com
More information about the use-livecode
mailing list