Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2007
    Posts
    2

    Unanswered: Ignore output of stored procedure

    Hi,

    I have a stored procedure that must return the result of execution of a single query, but I have to call another procedure multiple times during execution of my procedure.
    The problem is the result of the second procedure is being returned in addition to mine.

    Here is my proc:

    WHILE (@@sqlstatus = 0)
    BEGIN

    exec ANOTHER_PROC 'param', @result output

    UPDATE #TMP SET param = @result WHERE CD = @cd

    FETCH data_cursor INTO @cd
    END

    CLOSE data_cursor
    DEALLOCATE CURSOR data_cursor

    SELECT * FROM #TMP

    Here is the called proc:

    CREATE PROCEDURE ANOTHER_PROC (@param char(5), @result Numeric(5,2) = 0 output) As
    Begin
    Select @PcILM = cilm.PcILM
    From VW cilm,

    Select PcILM = @PcILM
    End

    Do you know how to get only the @result value without getting the result of the last SELECT?

    Thank you

  2. #2
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    <code>
    CREATE PROCEDURE ANOTHER_PROC (@param char(5), @result Numeric(5,2) = 0 output) As
    Begin
    Select @PcILM = cilm.PcILM
    From VW cilm,

    Select PcILM = @PcILM
    End
    </code>
    Do you know how to get only the @result value without getting the result of the last SELECT?

    Thank you
    I dont see you using @result anywhere in the body... Thats your problem, I think or am I missing anything?!!...

  3. #3
    Join Date
    Nov 2007
    Posts
    2
    I dont see you using @result anywhere in the body... Thats your problem, I think or am I missing anything?!!...
    Actually @PcILM should be @result

    We solved adding a flag to the procedure to indicate whether we want the last select statement to be executed, like as follows:

    CREATE PROCEDURE ANOTHER_PROC (@param char(5), @result Numeric(5,2) = 0 output, @flag char(1) = 'Y') As
    Begin
    Select @result = cilm.PcILM From VW cilm

    if (@flag = 'Y')
    Select PcILM = @PcILM
    End

    We didn't find a way to ignore the result of the last SELECT statement though.

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •