locked
mysql error in query in sp RRS feed

  • Question

  • User-1722422105 posted

    Hi All

    i am useing Sp in Mysql below is my sp

    ////////// below is my code

    CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_newemp21`

    (
    in empid int,
    in empname varchar(500),
     
    in empaddress varchar(500),
     
    in emplocation varchar(500))

    BEGIN
     
    if (empid is  null)
     
    then
     INSERT INTO  newemp21(empname,empaddress,emplocation)
     VALUES(empname,empaddress,emplocation);
     
     
    else 
    update newemp21 set empname=empname, empaddress=empaddress, emplocation=emplocation where empid=empid;
     
    END IF;
     
     
    End

    CREATE TABLE `newemp21` (
    `empid` int(11) NOT NULL AUTO_INCREMENT,
    `empname` varchar(500) DEFAULT NULL,
    `empaddress` varchar(500) DEFAULT NULL,
    `emplocation` varchar(500) DEFAULT NULL,
    PRIMARY KEY (`empid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    Wednesday, July 11, 2018 3:31 AM

All replies

  • User36583972 posted

    Hi sidu,

    Hi All

    i am useing Sp in Mysql below is my sp

    ////////// below is my code

    CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_newemp21`

    <div>(</div> <div>in empid int,</div> <div>in empname varchar(500),</div> <div> </div> <div>in empaddress varchar(500),</div> <div> </div> <div>in emplocation varchar(500))</div>

    <div>BEGIN</div> <div> </div> <div>if (empid is  null)</div> <div> </div> <div>then</div> <div> INSERT INTO  newemp21(empname,empaddress,emplocation)</div> <div> VALUES(empname,empaddress,emplocation);</div> <div> </div> <div> </div> <div>else </div> <div></div> <div>update newemp21 set empname=empname, empaddress=empaddress, emplocation=emplocation where empid=empid;</div> <div> </div> <div>END IF;</div> <div> </div> <div> </div> <div>End</div>

    CREATE TABLE `newemp21` (
    `empid` int(11) NOT NULL AUTO_INCREMENT,
    `empname` varchar(500) DEFAULT NULL,
    `empaddress` varchar(500) DEFAULT NULL,
    `emplocation` varchar(500) DEFAULT NULL,
    PRIMARY KEY (`empid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    Accorrding to your description, I’m not sure what the problem you are experiencing.

    I suggest you could check step by step and detect the error. Maybe the system has an error message and will help you find the error.

    If the error is about the mysql database or Connector/NET and C#, Mono, .Net, I suggest that you could go to the Connector/NET and C#, Mono, .Net forum for getting suitable help.

    Thank you for your understading.

    Best Regards,

    Yong Lu

    Thursday, July 12, 2018 9:35 AM