Re: Return value in stored procedure



What if I use TAdoStoredProcedure?

CREATE PROCEDURE dbo.gt_IsAddressOnHold (@Address varchar(40), @City
varchar(40), @State varchar(15), @PostalCode varchar(5), @CtryID
varchar(2))
AS

SET NOCOUNT ON /* Suppressed the " Rows affected" message */

DECLARE
@Result Integer

SET @Result = 0 -- Default value
-- Your exectuting code

Return @Result
-------------------------

In Delphi (you can use TADOStoredProc, TADOQuery, but I would use
TADOCommand)

Using the TADOCommand component, setting the appropriate properties (at
design time), in particular change the CommandType to cmdStoredProc (the
CommandText property will changed to a drop-down of stored procedures
(selecting the stored procedure of choice)

To make sure, select the Parameters property and verify Delphi 'filled in'
the Parameters collection with the stored procedure parameters, in
particular RETURN_VALUE

In Delphi code (datamodule/form method). Disclaimer, code is off the top
of my head, there are probably syntax errors:

function TdmData.IsAddressOnHold (const Address, City, State, PostalCode,
CtryID :String) : Boolean;
begin
with gt_IsAddressOnHold do
begin { Start of with ADO command do }
try { Start of try...except block }
//Set the corresponding properties
Execute();
Result := (Parameters.ParamByName('@RETURN_VALUE').Value =
1);
except
on e: Exception do
begin
Result := False;
//Raise a more meaningful/user-friendly error, log the
error, set a property, etc
end;
end; { End of try...except block }
end; { End of with ado command do }
end;


.



Relevant Pages

  • Re: Return value in stored procedure
    ... In Delphi (you can use TADOStoredProc, TADOQuery, but I would use ... (selecting the stored procedure of choice) ... select the Parameters property and verify Delphi 'filled in' ... begin {Start of with ADO command do} ...
    (borland.public.delphi.database.ado)
  • Re: Windows 2000 Server OS/MDAC Update Causes Applications Containing TADOCommand Objects To Fail
    ... > Are you using the delphi 5 ADO update? ... >> My company is experiencing a very odd problem at a client site. ... > server running Windows 2000 Server. ... > application that uses TADOCommand objects fails. ...
    (borland.public.delphi.database.ado)
  • Single (real) parameters types problem
    ... I'm trying to fill a MS-Access 97 table from a Delphi 7 program using a TADOCommand. ... I've set the command to a SQL "insert" statement with parameters. ...
    (borland.public.delphi.database.ado)
  • Timeout Expired /Index
    ... I am using Delphi 6 and ADO command. ... Prev by Date: ...
    (borland.public.delphi.database.ado)