Subject Correct Way?
Author wuiler
I want to know how the correct way to get and id field after insert a
row...
I put the lines above in a stored procedure, and its works...
insert into gastos
(gastos.gas_tcom, gastos.gas_ncom, gastos.gas_rub_id,
gastos.gas_nneg, gastos.gas_mont) values
(:ptcom, :pncom, :prubid, :pnneg, :pmont);

then I have a trigger for the table "Gastos", and its works too...
...
IF (NEW.GAS_ID IS NULL) THEN
NEW.GAS_ID = GEN_ID(GEN_GASTOS_ID,1);
....

BUT i need to get the ID "GAS_ID" after inserted the row, so solve the
problem with this 3 options.

option 1
In the stored procedures I put an output parameter "vid" that return
the ID:
....
vid = gen_id(gen_gastos_id,0);
....

option 2
I made my own system creating a table where id are stored for each
table, so when the trigger execute, increment the values.
....
IF (NEW.GAS_ID IS NULL) THEN
NEW.GAS_ID = GEN_ID(GEN_GASTOS_ID,1);
execute procedure spidentidad('GASTOS',NEW.GAS_ID);
....

option 3
The last think i made is the typical execute to get the last "ID".
So i put into the stored procedure.
....
select max(gas_id) from gastos
into :prResult;
....

My question is.
Is there other way to do that, get and ID as and output parameter
after insert a row? Triggers on after inserted? Transactions perhaps?
I hope to get an answer.