To take advantage of the light weight TIBSQL component for
executing stored procedures, execute the procedure with
the SQL statement 'execute procedure procedure_name'. The
results are passed back through a TIBXSQLDA object.
A TIBXSQLDA is an object which encapsulates an InterBase
API data type and contains all of the return parameters
for the stored procedure. TIBSQL.Current returns the
current TIBXSQLDA object associated with the TIBSQL.
The following code example executes a stored procedure,
new_key, that does not take any parameters but does return
a value. The 'new_key' procedure is defined as follows:
create procedure new_key returns (newkey integer)
as
begin
newkey = gen_id(vote_pui_gen, );
end
For more information on creating stored procedures refer to
the InterBase "Data Definition Guide", and "Programmer's
Guide".
procedure TForm .Button Click(Sender: TObject);
begin
IBSQL .SQL.Clear;
IBSQL .SQL.Add('execute procedure new_key');
IBSQL .ExecQuery;
Form .Caption := IBSQL .Current.Vars ;0].AsString;
end;
If the procedure returns multiple parameters, you can
iterate through the Vars array to extract all of the
parameters.