Search code examples
sap-asetoad

How do I get the return code from a stored procedure in Toad?


I have a test procedure:

CREATE PROCEDURE bfmsp_testproc(@test CHAR(32) = NULL)
AS
BEGIN
  IF @test IS NULL
    RETURN

  IF @test = 'BadReturnCode'
    RETURN 1

  /* Bad test, should probably do something */
  PRINT 'Invalid test code'
  RETURN 1
END

However, I cannot get the return code when I run it in Toad for Sybase.

bfmsp_testproc

bfmsp_testproc 'invalid'

bfmsp_testproc 'BadReturnCode'

There are no results sets (obviously). I see the PRINT output in the Messages tab of the results. However, I cannot find the return code anywhere in the output. The return code is available in my application code, so I know it is coming from Sybase OK.

Ideas? Is there a setting somewhere I am missing to show this? Or does Toad lack this feature?


Solution

  • I'm assuming you're using Adaptive Server 12.5 or greater.

    DECLARE @ret_val INT
    EXECUTE @ret_val=bfmsp_testproc 'BadReturnCode'
    SELECT @ret_val