Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. RETURN; before END

RETURN; before END

Scheduled Pinned Locked Moved Database
questioncssdatabasetutorial
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Waldemar Sauer
    wrote on last edited by
    #1

    Hi all I have encountered a stored procedure template that we are supposed to use for our daily development work. The strange thing about this template (to me, at least) is that it has a RETURN statement just before the final END statement. Obviously if the proc is returning a value, this statement is necessary, but we are talking about a stored proc that returns no value. I do not understand why this convention exists, much less why someone would care to enforce it. It looks like it clutters the readability of the stored proc by appending code that does nothing. I don't recall seeing any C code like this: "void fx(void) { return; }", at least not on purpose. But I figure that this convention must have come from somewhere, and maybe at some point there were a perfectly valid and good reason for it. So my question is this: What good reason is there (if any) to have a RETURN; statement just prior to the final END statement in a stored proc that does not return a value? Here is an example:

    CREATE PROC fx
    AS
    BEGIN
    RETURN; -- Why is this here just before the END?
    END
    go

    J P 2 Replies Last reply
    0
    • W Waldemar Sauer

      Hi all I have encountered a stored procedure template that we are supposed to use for our daily development work. The strange thing about this template (to me, at least) is that it has a RETURN statement just before the final END statement. Obviously if the proc is returning a value, this statement is necessary, but we are talking about a stored proc that returns no value. I do not understand why this convention exists, much less why someone would care to enforce it. It looks like it clutters the readability of the stored proc by appending code that does nothing. I don't recall seeing any C code like this: "void fx(void) { return; }", at least not on purpose. But I figure that this convention must have come from somewhere, and maybe at some point there were a perfectly valid and good reason for it. So my question is this: What good reason is there (if any) to have a RETURN; statement just prior to the final END statement in a stored proc that does not return a value? Here is an example:

      CREATE PROC fx
      AS
      BEGIN
      RETURN; -- Why is this here just before the END?
      END
      go

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      No reason. For TSQL the only thing I find odd with return is the need to put one after raiserror. Seems like raiserror itself would be sufficient to say stop.

      L 1 Reply Last reply
      0
      • J jschell

        No reason. For TSQL the only thing I find odd with return is the need to put one after raiserror. Seems like raiserror itself would be sufficient to say stop.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Depends on the errorlevel; I use 'em also to send some intermediate messages to the layer above.

        Bastard Programmer from Hell :suss:

        1 Reply Last reply
        0
        • W Waldemar Sauer

          Hi all I have encountered a stored procedure template that we are supposed to use for our daily development work. The strange thing about this template (to me, at least) is that it has a RETURN statement just before the final END statement. Obviously if the proc is returning a value, this statement is necessary, but we are talking about a stored proc that returns no value. I do not understand why this convention exists, much less why someone would care to enforce it. It looks like it clutters the readability of the stored proc by appending code that does nothing. I don't recall seeing any C code like this: "void fx(void) { return; }", at least not on purpose. But I figure that this convention must have come from somewhere, and maybe at some point there were a perfectly valid and good reason for it. So my question is this: What good reason is there (if any) to have a RETURN; statement just prior to the final END statement in a stored proc that does not return a value? Here is an example:

          CREATE PROC fx
          AS
          BEGIN
          RETURN; -- Why is this here just before the END?
          END
          go

          P Online
          P Online
          PIEBALDconsult
          wrote on last edited by
          #4

          Because that's where it belongs.

          L 1 Reply Last reply
          0
          • P PIEBALDconsult

            Because that's where it belongs.

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            I think I recognize a Fortran voice... :)

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups