Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can stored procedures return values?
Message
 
 
To
13/02/2004 02:10:52
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00876879
Message ID:
00877037
Views:
36
You're welcome.

>Thanks very much Sergey.
>
>>First, the SQLEXEC() returns -1 in case of failure, not 0.
>>
>>There're three ways to return value(s) from stored procedure:
>>1. The RETURN statement. Only one integer value can be returned and it ususally used to indicate success(0) or error code (non 0).
>>2. The OUTPUT parameter(s). Can be of ony type allowed for stored procedure parameters
>>3. The Record set.
>>For example,
* VFP
>>lnRetval = 0
>>lcStr = ""
>>lnResult = SQLEXEC(lnConn ,[{?@lnRetval=CALL Proc_test(1,2, ?@lcStr)}], "crsTemp" )
>>IF lnResult < 0
>>  * Use AERROR() function to get ODBC error info
>>  * Process error
>>ENDIF
>>
>>? lnRetval, lcStr, crsTemp.col1, crsTemp.col2
>>--------------------------------------------------------------------
>>-- SQL Server
>>if exists (select * from dbo.sysobjects
>>	where id = object_id(N'[dbo].[proc_test]') )
>>drop procedure [dbo].[proc_test]
>>GO
>>CREATE PROCEDURE proc_test
>>	@p1 int,
>>	@p2 int,
>>	@c3 varchar(36) OUTPUT
>>AS
>>        -- Output parameter
>>	SET @c3 = CAST(getdate() AS varchar(36))
>>        -- Recordset
>>	SELECT 'proc_test completed' AS col1, getdate() AS col2
>>-- Return value
>>RETURN 123
>>GO
>>
>>
>>
>>
>>>Hi all!
>>>
>>>Is it possible to return values from a stored procedure?
>>>
>>>I'm connection to the SQL-Server either by VFP (7, 8) and VB.NET.
>>>AFAIK the VFP SqlExecute() returns only 0 in case of failure and 1 in case of success.
>>>
>>>Thanks for advice.
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform