Код: Выделить всё
IBQuery1.SQL.Clear;
IBQuery1.SQL.Add('execute procedure SP_CHECKINSERTCONTRACT (:NUMBERCONTRACT)');
IBQuery1.ParamByName('NUMBERCONTRACT').AsInteger:=ContractNamber;
IBQuery1.ExecSQL;
FMain.IBTransaction1.Commit;
FMain.IBTransaction1.StartTransaction;
IDNUMBERCONTRACT:=IBQuery1.Current[0].AsInteger;
Сама ХП
Код: Выделить всё
begin
if (not exists (select ID from contracts where numbercontract=:numbercontract)) then
begin
insert into contracts (numbercontract)
values (:numbercontract)
returning id into :id;
result=1;
end
else
begin
result=0;
select (ID) from contracts where numbercontract=:numbercontract into :id;
end
/* Procedure Text */
suspend;
end