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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Pls...I can't understand what s the problem in this procedure..

Pls...I can't understand what s the problem in this procedure..

Scheduled Pinned Locked Moved Database
helpdatabasemysqlquestion
3 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.
  • P Offline
    P Offline
    PeriyasamyRamachandran
    wrote on last edited by
    #1

    Hi Everyone, I used the below stored procedure to delete a single record in a table in MySql. Procedure: DELIMITER $$ DROP PROCEDURE IF EXISTS `healthtour`.`USP_User_DeleteUserRole`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `USP_User_DeleteUserRole` ( IN UserRoleID INT ) BEGIN DELETE FROM HT_UserRole WHERE UserRoleID = UserRoleID; END$$ DELIMITER ; Problem: I run this procedure as below, CALL USP_User_DeleteUserRole(2); I have the records in my table for the UserRoleID 10. And i don't have the records for the UserRoleID 2. If I give the input(UserRoleID 2) then the record 10 is deleted. It should not be deleted. Because i gave the input 2 and not 10. Please can anybody help me?. Thanks, -Periyasamy Ramachandiran

    S 1 Reply Last reply
    0
    • P PeriyasamyRamachandran

      Hi Everyone, I used the below stored procedure to delete a single record in a table in MySql. Procedure: DELIMITER $$ DROP PROCEDURE IF EXISTS `healthtour`.`USP_User_DeleteUserRole`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `USP_User_DeleteUserRole` ( IN UserRoleID INT ) BEGIN DELETE FROM HT_UserRole WHERE UserRoleID = UserRoleID; END$$ DELIMITER ; Problem: I run this procedure as below, CALL USP_User_DeleteUserRole(2); I have the records in my table for the UserRoleID 10. And i don't have the records for the UserRoleID 2. If I give the input(UserRoleID 2) then the record 10 is deleted. It should not be deleted. Because i gave the input 2 and not 10. Please can anybody help me?. Thanks, -Periyasamy Ramachandiran

      S Offline
      S Offline
      scottgp
      wrote on last edited by
      #2

      It looks like you need to read up on what to do when a parameter name is the same as the name of a column in one of the tables (which obviously sounds dangerous). For example, http://stackoverflow.com/questions/715229/mysql-stored-procedures-parameter-with-the-same-name-as-affectings-column-is-i[^] Scott

      P 1 Reply Last reply
      0
      • S scottgp

        It looks like you need to read up on what to do when a parameter name is the same as the name of a column in one of the tables (which obviously sounds dangerous). For example, http://stackoverflow.com/questions/715229/mysql-stored-procedures-parameter-with-the-same-name-as-affectings-column-is-i[^] Scott

        P Offline
        P Offline
        PeriyasamyRamachandran
        wrote on last edited by
        #3

        Hi, Yes I found the error that i have used the same name for both table column name and the variable name. Just i changed the variable name. Now it works fine. Thank u very much. -Periyasamy Ramachandiran.

        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