Function Return inside Store Procedure

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel Caetano

    #1

    Function Return inside Store Procedure

    Hi all, i have a store procedure that i use the return function . Ex.
    create procedute XX as
    (statement...)
    if @@error <> 0
    return 1
    else
    return 0 .

    Inside the vb net i wnat to call that procedure and retrieve that value
    returned. I´m using command. Is that possible? How can i do it? Or i must to
    create an output variable in my sp?
    Thanks


  • Neil Woodvine

    #2
    Re: Function Return inside Store Procedure

    Daniel,

    You could use an Output variable, or use RAISERROR keyword within Stored
    Procedure along with a custom error (see sp_addmessage in Books Online) and
    catch the error in your application (see ADODB.Errors Collection).

    Cheers,
    Neil

    "Daniel Caetano" <dcaetano@ig.co m.br> wrote in message
    news:OzzbgXjdEH A.212@TK2MSFTNG P12.phx.gbl...[color=blue]
    > Hi all, i have a store procedure that i use the return function . Ex.
    > create procedute XX as
    > (statement...)
    > if @@error <> 0
    > return 1
    > else
    > return 0 .
    >
    > Inside the vb net i wnat to call that procedure and retrieve that value
    > returned. I´m using command. Is that possible? How can i do it? Or i must[/color]
    to[color=blue]
    > create an output variable in my sp?
    > Thanks
    >
    >[/color]


    Comment

    • Erik Tamminga

      #3
      Re: Function Return inside Store Procedure

      Hi,

      IIRC, you can add a parameter with ParameterDirect ion.Return to the command
      that's calling the storedprocedure . Retrieving the return value can then be
      done by reading the value of the passed parameter.

      Erik

      "Daniel Caetano" <dcaetano@ig.co m.br> wrote in message
      news:OzzbgXjdEH A.212@TK2MSFTNG P12.phx.gbl...[color=blue]
      > Hi all, i have a store procedure that i use the return function . Ex.
      > create procedute XX as
      > (statement...)
      > if @@error <> 0
      > return 1
      > else
      > return 0 .
      >
      > Inside the vb net i wnat to call that procedure and retrieve that value
      > returned. I´m using command. Is that possible? How can i do it? Or i must[/color]
      to[color=blue]
      > create an output variable in my sp?
      > Thanks
      >
      >[/color]


      Comment

      • Sunny

        #4
        Re: Function Return inside Store Procedure

        In article <ceid42$6b9$1@n ews3.tilbu1.nb. home.nl>,
        newsgroups@NeOt ammiSnPgAaM.nl says...[color=blue]
        > Hi,
        >
        > IIRC, you can add a parameter with ParameterDirect ion.Return to the command
        > that's calling the storedprocedure . Retrieving the return value can then be
        > done by reading the value of the passed parameter.
        >
        > Erik
        >[/color]


        Hi,
        and do you know a way to get the output of the PRINT statements from the
        SP?

        Thanks
        Sunny

        Comment

        • Erik Tamminga

          #5
          Re: Function Return inside Store Procedure

          Hi,

          Capturing the output from print statements will be somewhat more difficult.
          IIRC ADO had a special collection that contains these messages in its
          command object. Can't find (or overlooked) that same functionality in .NET.
          As the output gets to stdout when you call the sp from the console, you
          might want to try to redirect standard output to a stream and read the
          results from there.
          You'll have to do some more digging work on this !

          Erik

          "Sunny" <sunny@newsgrou ps.nospam> wrote in message
          news:eUZrPGkeEH A.2908@TK2MSFTN GP10.phx.gbl...[color=blue]
          > In article <ceid42$6b9$1@n ews3.tilbu1.nb. home.nl>,
          > newsgroups@NeOt ammiSnPgAaM.nl says...[color=green]
          > > Hi,
          > >
          > > IIRC, you can add a parameter with ParameterDirect ion.Return to the[/color][/color]
          command[color=blue][color=green]
          > > that's calling the storedprocedure . Retrieving the return value can then[/color][/color]
          be[color=blue][color=green]
          > > done by reading the value of the passed parameter.
          > >
          > > Erik
          > >[/color]
          >
          >
          > Hi,
          > and do you know a way to get the output of the PRINT statements from the
          > SP?
          >
          > Thanks
          > Sunny[/color]


          Comment

          Working...