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. Is it possible to fire message from Stored procedure?

Is it possible to fire message from Stored procedure?

Scheduled Pinned Locked Moved Database
databasequestion
7 Posts 2 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.
  • S Offline
    S Offline
    Sipder
    wrote on last edited by
    #1

    If i want to display message when user enters NULL for some field ,when I call stored procedure from the database?

    C 1 Reply Last reply
    0
    • S Sipder

      If i want to display message when user enters NULL for some field ,when I call stored procedure from the database?

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Master Mind'z wrote:

      If i want to display message when user enters NULL for some field ,when I call stored procedure from the database?

      Are you asking if a stored procedure can open up a message box to display a message to the user? If so, the answer is no. Well, I suppose you could if you hacked around a bit. However, it is not a good idea. SQL Server is a database engine, often it will reside on another machine and if you were to get it to open a message box, it would only do so on the machine in which the SQL Server was running - it would be absolutely useless to the person using your application as they wouldn't see it. Finally, the suggestion that SQL Server generates the message box is betrays somewhat a poor design. You are attempting to put presentation layer functionality in the database layer.

      Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

      S 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Master Mind'z wrote:

        If i want to display message when user enters NULL for some field ,when I call stored procedure from the database?

        Are you asking if a stored procedure can open up a message box to display a message to the user? If so, the answer is no. Well, I suppose you could if you hacked around a bit. However, it is not a good idea. SQL Server is a database engine, often it will reside on another machine and if you were to get it to open a message box, it would only do so on the machine in which the SQL Server was running - it would be absolutely useless to the person using your application as they wouldn't see it. Finally, the suggestion that SQL Server generates the message box is betrays somewhat a poor design. You are attempting to put presentation layer functionality in the database layer.

        Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

        S Offline
        S Offline
        Sipder
        wrote on last edited by
        #3

        Oh! I had heard that you can validate data in SQL stored procedure. I thought this might be the way. I always validate data at UI level only and take care that everything is validated before I call stored proc. Is this

        C 1 Reply Last reply
        0
        • S Sipder

          Oh! I had heard that you can validate data in SQL stored procedure. I thought this might be the way. I always validate data at UI level only and take care that everything is validated before I call stored proc. Is this

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Master Mind'z wrote:

          Oh! I had heard that you can validate data in SQL stored procedure.

          Yes, you can. But what does that have to do with putting messages to the user?

          Master Mind'z wrote:

          I always validate data at UI level only and take care that everything is validated before I call stored proc

          And for security you should also validate in the stored proc too. What if someone finds a different route to your database that isn't through your application? If you don't validate in the database too your system is vulnerable.

          Master Mind'z wrote:

          Is this

          Is this what? You didn't complete the question.

          Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

          S 1 Reply Last reply
          0
          • C Colin Angus Mackay

            Master Mind'z wrote:

            Oh! I had heard that you can validate data in SQL stored procedure.

            Yes, you can. But what does that have to do with putting messages to the user?

            Master Mind'z wrote:

            I always validate data at UI level only and take care that everything is validated before I call stored proc

            And for security you should also validate in the stored proc too. What if someone finds a different route to your database that isn't through your application? If you don't validate in the database too your system is vulnerable.

            Master Mind'z wrote:

            Is this

            Is this what? You didn't complete the question.

            Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

            S Offline
            S Offline
            Sipder
            wrote on last edited by
            #5

            Thank you for the right guidance.. and quick reply. I wanted to ask, Is this correct way to validate? Any ways, you have cleared my doubt. As you said we can also validate in stored Proc as well. how to do that?

            C 1 Reply Last reply
            0
            • S Sipder

              Thank you for the right guidance.. and quick reply. I wanted to ask, Is this correct way to validate? Any ways, you have cleared my doubt. As you said we can also validate in stored Proc as well. how to do that?

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              Master Mind'z wrote:

              As you said we can also validate in stored Proc as well. how to do that?

              Just like you validate anything else. You use conditional statements.

              IF @someValue > validRange
              BEGIN
              -- Put code here to handle invalid data.
              -- e.g. Could RAISEERROR
              -- Could return a value indicating an error
              END
              ELSE
              BEGIN
              -- The data is correct. Apply it to the database
              -- e.g. INSERT/UPDATE/DELETE
              END

              Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

              S 1 Reply Last reply
              0
              • C Colin Angus Mackay

                Master Mind'z wrote:

                As you said we can also validate in stored Proc as well. how to do that?

                Just like you validate anything else. You use conditional statements.

                IF @someValue > validRange
                BEGIN
                -- Put code here to handle invalid data.
                -- e.g. Could RAISEERROR
                -- Could return a value indicating an error
                END
                ELSE
                BEGIN
                -- The data is correct. Apply it to the database
                -- e.g. INSERT/UPDATE/DELETE
                END

                Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

                S Offline
                S Offline
                Sipder
                wrote on last edited by
                #7

                Thank you Colin Angus Mackay!

                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