Subject Re: [ib-support] Example Code
Author Louis van Alphen
At 13:37 2001-08-30 -0500, you wrote:
>Does anybody know where I can find example SQL code for
>
>things like, Stored Procedures, Doing loops in stored procedures,
>
>passing parameters to stored procedures....
>

Example 1
---------------
in IB:

create procedure SP1(IN_PARAM1 INTEGER)
returns (OUT_PARAM1 INTEGER)
as
begin
for select INTEGER_COLUMN from TABLE
where SOME_COLUMN = :IN_PARAM1
into :OUT_PARAM1
do
suspend;
end
end

to use in Delphi, simply create a query:

qryTest.Close;
qryTest.SQL.Clear;
qryTest.SQL.Add('select * from SP1 (1)'); // or use a variable a the
parameter
qryTest.Open

while qryTest.EOF = Fasle do
begin
SomeVariable = qryTest.FieldByName('OUT_PARAM1').Value;
qryTest.Open;
end;

OR

set the SQL property to select * from SP1 (:InParam)
and then in code:

qryTest.Close;
qryTest.ParamByName('InParam').Value := 111;
qryTest.Open
SomeVariable = qryTest.FieldByName('OUT_PARAM1').Value;


HTH


L.J. van Alphen
Director
Basix Automation

E-mail: lja@...
WWW: http://www.basix.co.za
Tel: (+27) (0)21-409 7018


P.O. Box 6330
Roggebaai
8012
Cape Town
South Africa