I have the following instructions in ORACLE:
Code: Select all
CREATE OR REPLACE TRIGGER "DESARROLLO"."TA_LIQ_GENERAR_NUM_ORDEN"
BEFORE INSERT
OR UPDATE OF "N_NUM_ORDEN" ON "TA_LIQUIDACIONES" FOR EACH ROW begin
if :new.n_num_orden is null then
select TA_LIQ_NUM_ORDEN.NextVal
into :new.n_num_orden
from Dual;
end if;
end;Code: Select all
CREATE SEQUENCE "DESARROLLO"."TA_LIQ_NUM_ORDEN" INCREMENT BY 1
START WITH 5000 MAXVALUE 99999 MINVALUE 1 NOCYCLE
NOCACHE ORDERfdm.SmartQuery. SequenceMode = smInsert
fdm.SmartQuery.KeySequence :='DESARROLLO.TA_LIQ_NUM_ORDEN';
fdm.SmartQuery.Keyfields := 'n_num_orden';
fdm.SmartQuery.Refreshoptions := [roAfterUpdate];
Code: Select all
procedure TfLiq.grabaSQLliq;
begin
fdm.SmartQuery.SQL.clear;
fdm.SmartQuery.SQL.Text:=
'INSERT INTO Desarrollo.ta_liquidaciones '+#13+
'(C_NUM_OFICINA, N_NUM_YEAR, N_NUM_ORDEN)'+#13+
' VALUES '+#13+
'(:C_NUM_OFICINA, :N_NUM_YEAR, :N_NUM_ORDEN)'+#13+
'RETURNING'+#13+
' N_NUM_ORDEN'+#13+
'INTO'+#13+
' :N_NUM_ORDEN';
fdm.SmartQuery.ParamByName('C_NUM_OFICINA').AsString := Num_oficina.text;
fdm.SmartQuery.ParamByName('N_NUM_YEAR').AsString := Num_year.text;
fdm.SmartQuery.ParamByName('N_NUM_ORDEN').AsString := Num_Orden.Text;
fdm.SmartQuery.prepared;
fdm.SmartQuery.execute;
*************************
Here it is the error, does not give back the sequence for N_NUM_ORDEN
************************
Num_orden.text:= fdm.SmartQuery.ParamByName('N_NUM_ORDEN').AsString;
end;ORA-01722: invalid number
ORA-06512: at line 1