Как вытащить результат из ХП
Добавлено: 11 янв 2007, 15:11
Здравствуйте у меня вопрос....
в результате переменной IDNUMBERCONTRACT ничего не присваивается, хотя на сервере в ХП все работает а вот через обращение IDNUMBERCONTRACT:=IBQuery1.Current[0].AsInteger; вытянуть возвращаемый результат не получается....
Сама ХП
Код: Выделить всё
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