Parameters in Stored Procedures
Posted: 10.09.2013, 08:12
Hi,
I tried to call Stored Procedures using TZStoredProc on MS SQL Server 2008 and I experience problems submitting parameters:
Here is my code (fragment):
with SP1 do begin
StoredProcName := 'test';
p0:=params.createparam(ftDateTime,'@par1',ptInput);
p1:=params.createparam(ftVariant,'@par2',ptInput);
ParamByName('@par1').Value := '20130707';
ParamByName('@par2').Value := '302092';
Open;
sp1.Params.RemoveParam(p0);
sp1.Params.RemoveParam(p1);
end;
Calling with this ends up with the following message in ZSQLMonitor-Log:
Execute, proto: FreeTDS_MsSQL>=2005, msg: exec sp_sproc_columns 'test', null, null, null
Other, proto: FreeTDS_MsSQL>=2005, msg: EXECUTEPREPARED:dbRPCExec, errcode: 0, error: DBError : [0201] : General SQL Server error: Check messages from the SQL Server
Procedure or function 'test' expects parameter '@par2', which was not supplied.
Calling the stored procedure by executing a TZQuery works.
So, it seems the TZStoredProc has Problems with parameters. If the parameters are defined within the object inspector only (without the two create-lines as in the code above listed), they are not known at all, so this definition does not have any effect.
Maybe, I Do not use TZStoredProc in a proper way?
Environment: Lazarus 1.0.10 on Windows XP, Zeoslib: 7.0.4
Any help would be nice,
woec
I tried to call Stored Procedures using TZStoredProc on MS SQL Server 2008 and I experience problems submitting parameters:
Here is my code (fragment):
with SP1 do begin
StoredProcName := 'test';
p0:=params.createparam(ftDateTime,'@par1',ptInput);
p1:=params.createparam(ftVariant,'@par2',ptInput);
ParamByName('@par1').Value := '20130707';
ParamByName('@par2').Value := '302092';
Open;
sp1.Params.RemoveParam(p0);
sp1.Params.RemoveParam(p1);
end;
Calling with this ends up with the following message in ZSQLMonitor-Log:
Execute, proto: FreeTDS_MsSQL>=2005, msg: exec sp_sproc_columns 'test', null, null, null
Other, proto: FreeTDS_MsSQL>=2005, msg: EXECUTEPREPARED:dbRPCExec, errcode: 0, error: DBError : [0201] : General SQL Server error: Check messages from the SQL Server
Procedure or function 'test' expects parameter '@par2', which was not supplied.
Calling the stored procedure by executing a TZQuery works.
So, it seems the TZStoredProc has Problems with parameters. If the parameters are defined within the object inspector only (without the two create-lines as in the code above listed), they are not known at all, so this definition does not have any effect.
Maybe, I Do not use TZStoredProc in a proper way?
Environment: Lazarus 1.0.10 on Windows XP, Zeoslib: 7.0.4
Any help would be nice,
woec