Page 1 of 1

INSERT UPDATE

Posted: 04.03.2012, 22:57
by sfxcc
When we insert a a row normaly we have a primarykey and most times is a sequencial number.

insert into table aa(autoinc integer) returning autoinc;
What im asking is when we insert or update it returns automatic the row, without using zupdatesql (zupdatesql is useful too).

This should be done because is useful.
( we avoid to move the cursor by refreshing atable.refresh, and when we use zupdatesql after insert we dont have the primarykey id any way so we cant refresh from an insert , or if we have a zquery like select * from (select *,sum(a+b) from table1) where date<=aDate) where Date=aDate we cant directly insert into the table1 using zupdate but we cant the use primarykey on refreshsql because it doesnt got it from server ....

and using zsequence if we use 10 call at same time it will return the same number so it does fix the problem.

Normaly autoinc are controled on server side on a triger so ... is the best way.


At least add to zupdatesql or even a descendant component the ability to do on insert update (insert into table aa(autoinc integer) returning autoinc;).

Posted: 09.03.2012, 22:19
by EgonHugeist
Can you export some code-lines concerning the auto-inc, eventually? I use triggers or stored-procedures to solve this like you wrote. I don't understand why the ZSequence returns allways the same value. Normaly it calls the server for (Interbase) GEN_ID(Genarator/Sequence-name). Can you debug out why it fails? Or do i missunderstand you here?

Posted: 10.03.2012, 00:19
by sfxcc
Ok, ill debug to try to found a prob.

Other :

zupdate does only refresh 1 row even if select * from table where primary>=avalue , can this be reformuled to update all the result rows of the refreshsql to table and not just 1 ?

Other : Does zpgEvent is working ? i try this out but it seams that it cant be triggerd and notified by the same session.