Return Parameter for StoredProcedure

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
michaelJ
Posts: 30
Joined: Thu 13 Jan 2011 16:11

Return Parameter for StoredProcedure

Post by michaelJ » Tue 18 Jun 2013 12:08

Hi,

it is possible to use a ReturnParameter (from a Insert Statement with ...returning ...) in a StoredProcedure using TIBCSQL?
How can I do that to get the value in Delphi?

AndreyZ

Re: Return Parameter for StoredProcedure

Post by AndreyZ » Wed 19 Jun 2013 07:25

Hello,

You can use the following code:

Code: Select all

begin
  IBCSQL.CreateProcCall('new_dept');
  IBCSQL.Execute;
  ShowMessage(IBCSQL.ParamByName('deptno').AsString);
end;
, where NEW_DEPT is the following stored procedure:

Code: Select all

create procedure new_dept
returns (
  deptno integer)
as
begin
  insert into dept(deptno) values(next value for gen_dept) returning deptno into :deptno;
end
, dept is the following table:

Code: Select all

create table dept (
    deptno  integer primary key,
    dname   varchar(14),
    loc     varchar(13)
);
, and gen_dept is a generator.

michaelJ
Posts: 30
Joined: Thu 13 Jan 2011 16:11

Re: Return Parameter for StoredProcedure

Post by michaelJ » Wed 19 Jun 2013 09:21

Thank you - that answers my question!

AndreyZ

Re: Return Parameter for StoredProcedure

Post by AndreyZ » Wed 19 Jun 2013 10:08

I am glad to help. If any other questions come up, please contact us.

Post Reply