Subject RE: [firebird-support] Returning values from INSERT
Author Tim Ledgerwood
Nope - I am doing something wrong, and I don't know what I am doing wrong.
Both the SP and the Query have the same (IBX) transaction object. The line

SMSRecord.MsgID := IBQryInsertSMSMSGNO.AsInteger;

Is where I read the returned value from the insert procedure. It is always
zero. ??? It should return the primary key value of the newly inserted record.

TIA

Tim

Delphi Code :

if not IBQryInsertSMS.Transaction.Active then
IBQryInsertSMS.Transaction.Active := True;
if not IBSPInsertSMS.Transaction.InTransaction then
IBSPInsertSMS.Transaction.StartTransaction;

with IBQryInsertSMS do
begin
{fill in parameters here}
if not Prepared then Prepare;
Open;
end;

SMSRecord.MsgID := IBQryInsertSMSMSGNO.AsInteger;

for i := 1 to 8 do
begin
{check if the record has data - if yes, insert a new record}
ParamByName('SMSMSGNUMBER').AsInteger := SMSRecord.MsgID;
end;

IBQryInsertSMS.Transaction.Commit;