Страница 1 из 1

Как вытащить результат из ХП

Добавлено: 11 янв 2007, 15:11
Vetal
Здравствуйте у меня вопрос....

Код: Выделить всё

    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;
в результате переменной IDNUMBERCONTRACT ничего не присваивается, хотя на сервере в ХП все работает а вот через обращение 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

Добавлено: 11 янв 2007, 15:42
Dimitry Sibiryakov
А кто вам сказал, что этот результат может пережить конец транзакции?

Добавлено: 11 янв 2007, 15:47
Vetal

Код: Выделить всё

    IBQuery1.ExecSQL;
    IDNUMBERCONTRACT:=IBQuery1.Current[0].AsInteger;
    FMain.IBTransaction1.Commit;
    FMain.IBTransaction1.StartTransaction;
Так тоже ничего не получается

Добавлено: 11 янв 2007, 16:07
Vetal
Спасибо подсказка верна....