Page 1 of 1

Parameters in Stored Procedures

Posted: 10.09.2013, 08:12
by woec
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

Re: Parameters in Stored Procedures

Posted: 10.09.2013, 15:23
by EgonHugeist
The TZStoredProc determines all available Params by MetaInformations on assigning StoredProc-name.

It might be possible the params are named different and you can't assign the values this way. Did you check it @designtime too?

Which lib do you use for connect?

Re: Parameters in Stored Procedures

Posted: 11.09.2013, 13:36
by woec
Hi, Michael

thanks for reply.

I tried at design time and get the same error message about the missing parameter, wenn I try to set the Procedureobject to Active.
Also I noticed, there is no possibility to assign a value to a parameter at design time ?

I use msdblibd.dll (Build 2012-11-08) Protocol FreeTDS-mssql >= 2005

Sincerely
Johann

Re: Parameters in Stored Procedures

Posted: 28.09.2013, 17:52
by EgonHugeist
I'm sorry for the long delay.

Your issue makes me wondering, May i ask for an example?

Hint FreeTDS is a trouble-maker here. Zeos uses the native access and there are 3 functions missing in the FreeTDS implementation. Long times i'm looking for somebody who can fix the lib, recompile everything and share the lib's..

Re: Parameters in Stored Procedures

Posted: 10.10.2013, 10:44
by woec
Hi Michael,

thanks for your reply. Please tell me, wich additional part(s) of code beyond the fragment I supplied as example in my first post of this thread you need.

Best regards,
Johann