Subject Re: [IBO] help with stored procedures
Author Dmitry Beloshistov
Hello!

Simple sample:
with IB_Query1 do
begin
close; sql.clear;
sql.add('execute My_Insert_Proc(:Par1,:Par2)');
Prepare; //<--- !!!!! without it ParamByName() not work!
ParamByName('Par1').Value:=MyPar1;
ParamValues['Par2']:=MyPar2; // another way for set parameters values
Execute; // or ExecSQL;
Close;
end;

If you stored procedure should return some values, you should write:

sql.add('select MyNeedData from My_Insert_Proc(:Par1,:Par2)');
....
Open;
MyValueFromSP:=FieldByName('MyNeedData').AsInteger;
Close;

P.S. What should be returned from stored procedure? You are use SUSPEND, but in procedure SELECT not present.

WBR, Dmitry Beloshistov AKA [-=BDS=-]

----- Original Message -----
From: newgen3152003
To: IBObjects@yahoogroups.com
Sent: Monday, February 23, 2004 3:30 PM
Subject: [IBO] help with stored procedures


Hi,

Could someone help me, with this please. My code to insert a row
below gives me an error with parambyname. what am I doing wrong. I
get this error no matter which field I use. the stored procedure
included below.

Could someone please set me straight on the proper usage params and
stored procedures, if this is not correct.

Please
Daniel

Error message:
"FieldName "ADD1" not found"

Procedure:
with DataM.AllLoc do
begin
ReadOnly := False;
RequestLive := true;

InsertSQL.Text := ' ';
InsertSQL.Append('execute procedure NewLocation');
InsertSQL.Append
('(:LOCCODE, :LOCNAME, :LOCTYPE , :ADD1, :ADD2, :CITY,');
InsertSQL.Append
(':PROV, :ZIP , :PHONE, :FAX , :AUX, :CONTACT, :EMAIL , :COMMENTS , :N
OTE );');

error ==> ParamByName('ADD1').value := 'testing';

open;
insert;
end;

Stored Procedure:
IDLOC created in a trigger and generator

begin
insert into LOCATIONS
(LOCCODE,LOCNAME,LOCTYPE ,ADD1,ADD2,CITY,PROV, ZIP , PHONE, FAX ,
AUX, CONTACT, EMAIL , COMMENTS , NOTE )
values

(:LOCCODE, :LOCNAME, :LOCTYPE , :ADD1, :ADD2, :CITY, :PROV, :ZIP , :PH
ONE, :FAX , :AUX, :CONTACT, :EMAIL , :COMMENTS , :NOTE );
suspend;
end




[Non-text portions of this message have been removed]