BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with params with TSQLStoredProc

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Jacob Pedersen
Guest





PostPosted: Fri Nov 21, 2003 10:50 am    Post subject: Problem with params with TSQLStoredProc Reply with quote



Example:

function GetNextNumber(const SQLConnection : TSQLConnection; TheTable:
string; Increase: Integer = 1): Integer; overload;
begin
if not Assigned(MySP) then
begin
MySP := TSQLStoredProc.Create(nil);
MySP.SQLConnection := SQLConnection; // needed for dbExpress
MySP.StoredProcName := 'GetNextNumber';
MySP.SchemaName := 'dbo';
MySP.Params.CreateParam(ftString, '@TableName', ptInput);
MySP.Params.CreateParam(ftInteger, '@Increase', ptInput);
MySP.Params.CreateParam(ftInteger, '@Identity', ptOutput);
end;

MySP.SQLConnection := SQLConnection;

MySP.ParamByName('@TableName').AsString := 'testtable';
MySP.ParamByName('@Increase').AsInteger := 1;

MySP.ExecProc;

Result := MySP.ParamByName('@Identity').AsInteger;
end;


From SQL Profiler:

declare @P1 int
set @P1=2
declare @P2 int
set @P2=NULL
exec sp_prepexecrpc @P1 output, N'"dbo"."GetNextNumber"', @TableName = '',
@Increase = 0
select @P1


As you can see @TableName is set to what looks like a square and @Increase
is 0. @Identity is not there at all.

If you add a dummy param after Identity, I get the Identity param (and then
not the dummy param), but still the params are not used by dbExpress.

I'm using latest dbExpress driver from august.


Same code with BDE works fine!

Example:

if not Assigned(MySP) then
begin
MySP := TStoredProc.Create(nil);
MySP.DatabaseName := MyDB.DatabaseName;
MySP.StoredProcName := 'GetNextNumber';
MySP.Params.CreateParam(ftString, '@TableName', ptInput);
MySP.Params.CreateParam(ftInteger, '@Increase', ptInput);
MySP.Params.CreateParam(ftInteger, '@Identity', ptOutput);
end;

MySP.DatabaseName := TheDatabase;

MySP.ParamByName('@TableName').AsString := Trim(TheTable);
MySP.ParamByName('@Increase').AsInteger := Increase;

MySP.ExecProc;

Result := MySP.ParamByName('@Identity').AsInteger


This clearly is a huge dbExpress bug or?!

--
Jacob Pedersen
AK Techotel
[email]J.PedersenGOAWAY (AT) noXspaMtechotel (DOT) dk[/email]
(Remove GOAWAY and noXspaM when replying!)
Back to top
Jacob Pedersen
Guest





PostPosted: Tue Nov 25, 2003 2:57 pm    Post subject: Re: Problem with params with TSQLStoredProc Reply with quote



I downloaded the CoreLabs dbExpress driver for MSSQL to see if that would
fix the problem. Keeping in mind that it is a trial version... Does not
even get as far as Borlands driver. I get List Index out of bounds (4).
Looking at the stack, the problem seems to be related to params. *sight*

You can say alot about BDE but atleast it could call stored procs without
problems...

Is it really true noone can help? Do I have to go the ADO way :(

--
Jacob Pedersen
AK Techotel
[email]J.PedersenGOAWAY (AT) noXspaMtechotel (DOT) dk[/email]
(Remove GOAWAY and noXspaM when replying!)
Back to top
Ricardo
Guest





PostPosted: Tue Nov 25, 2003 9:49 pm    Post subject: Re: Problem with params with TSQLStoredProc Reply with quote



Did you see the trial limitations?
The CoreLab driver only show 6 Fields, for example.


"Jacob Pedersen" <J.Pedersen (AT) techotel (DOT) dk> escreveu na mensagem
news:Xns943EACBA098D3jpedersentechotel (AT) 207 (DOT) 105.83.66...
Quote:
I downloaded the CoreLabs dbExpress driver for MSSQL to see if that would
fix the problem. Keeping in mind that it is a trial version... Does not
even get as far as Borlands driver. I get List Index out of bounds (4).
Looking at the stack, the problem seems to be related to params. *sight*

You can say alot about BDE but atleast it could call stored procs without
problems...

Is it really true noone can help? Do I have to go the ADO way :(

--
Jacob Pedersen
AK Techotel
[email]J.PedersenGOAWAY (AT) noXspaMtechotel (DOT) dk[/email]
(Remove GOAWAY and noXspaM when replying!)



Back to top
Jacob Pedersen
Guest





PostPosted: Wed Nov 26, 2003 8:38 am    Post subject: Re: Problem with params with TSQLStoredProc Reply with quote

"Ricardo" <no (AT) no (DOT) com> wrote in news:3fc3ce33$1 (AT) newsgroups (DOT) borland.com:

Quote:
Did you see the trial limitations?
The CoreLab driver only show 6 Fields, for example.


Yes I know but this has nothing to do with calling a simple
stored proc like in my example... Normal TSQLQuery works
fine with CoreLabs except it seemed alot slower. Might just be
me...


--
Jacob Pedersen
AK Techotel
[email]J.PedersenGOAWAY (AT) noXspaMtechotel (DOT) dk[/email]
(Remove GOAWAY and noXspaM when replying!)

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.