Board index » delphi » MSSQL 7 + D4 C/S + Output parameters

MSSQL 7 + D4 C/S + Output parameters

Hi All,

   I am having problems with SQL Server 7 stored procedures and output
parameters.

   I am using  D4 C/S to call stored procedures that have output
parameters assigned and for some reason I cannot get the output
parameters to work correctly.

   If the output parameter is defined as an INT datatype in the stored
procedure it will return an assigned value properly, however, if the
output parameter is defined as a VARCHAR datatype it will give an access
violation.

   Does this mean that you can only use the INT datatype for output
parameters?

   This contradicts some of the output parameter examples that I have
seen that supposedly return characters as output parameters.

   Can anyone shed some light on this problem?

   Any and all help is greatly appreciated.

jeff alerta
j...@nestworks.com

 

Re:MSSQL 7 + D4 C/S + Output parameters


I just created the floowing procedure under SQL7 (Desktop),
NT4 SP4 (workstation) and Delphi 4.0 Update 2:

-------------------------------------------------

CREATE PROCEDURE TestString
  @InParam varchar(40),
  @OutParam varchar(40) OUTPUT
as
select @OutParam=@InParam

-------------------------------------------------

I placed a TDatabase component and a TStoredProc component on the
form and ran the following code:

-------------------------------------------------

procedure TForm1.Button1Click(Sender: TObject);
var
  S             : String;
begin
StoredProc1.ParamByName('@InParam').AsString := 'Testing';
StoredProc1.ExecProc;
S := StoredProc1.ParamByName('@OutParam').AsString;
ShowMessageFmt('OutParam = %s',[S]);
end;

-------------------------------------------------

This is using the ODBC drivers not the "native" client/server driver.
I believe that there is a new version of the SQL Links driver on the
Borland/Inprise/borland.com website.

My 2 cents,

Erik Turner
Microgistics, Inc

Quote
jeff alerta wrote in message <36C9D231.44556...@earthlink.net>...
>Hi All,

>   I am having problems with SQL Server 7 stored procedures and output
>parameters.

>   I am using  D4 C/S to call stored procedures that have output
>parameters assigned and for some reason I cannot get the output
>parameters to work correctly.

>   If the output parameter is defined as an INT datatype in the stored
>procedure it will return an assigned value properly, however, if the
>output parameter is defined as a VARCHAR datatype it will give an access
>violation.

>   Does this mean that you can only use the INT datatype for output
>parameters?

>   This contradicts some of the output parameter examples that I have
>seen that supposedly return characters as output parameters.

>   Can anyone shed some light on this problem?

>   Any and all help is greatly appreciated.

>jeff alerta
>j...@nestworks.com

Other Threads