Re: Return value in stored procedure
- From: "Man T" <alanpltse_NOSPAM@xxxxxxxxxxxx>
- Date: Wed, 14 May 2008 15:14:14 +1000
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;
.
- Follow-Ups:
- Re: Return value in stored procedure
- From: Kevin Frevert
- Re: Return value in stored procedure
- References:
- Return value in stored procedure
- From: Man T
- Re: Return value in stored procedure
- From: Kevin Frevert
- Return value in stored procedure
- Prev by Date: Re: How do I work with Recordset in ExecuteComplete event?
- Next by Date: how to determine the name of the constraint (Foreign Key, Primary Key) when i have an exception
- Previous by thread: Re: Return value in stored procedure
- Next by thread: Re: Return value in stored procedure
- Index(es):
Relevant Pages
|