MySQL create stored procedure syntax with delimiter

后端 未结 5 738
不思量自难忘°
不思量自难忘° 2020-11-27 02:36

I am trying to create a stored procedure in MySQL using a delimiter like this:

use am;

DELIMITER $$

CREATE PROCEDURE addfields()
BEGIN
  DECLARE done INT D         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 03:24

    Here is the sample MYSQL Stored Procedure with delimiter and how to call..

    DELIMITER $$
    
    DROP PROCEDURE IF EXISTS `sp_user_login` $$
    CREATE DEFINER=`root`@`%` PROCEDURE `sp_user_login`(
      IN loc_username VARCHAR(255),
      IN loc_password VARCHAR(255)
    )
    BEGIN
    
      SELECT user_id,
             user_name,
             user_emailid,
             user_profileimage,
             last_update
        FROM tbl_user
       WHERE user_name = loc_username
         AND password = loc_password
         AND status = 1;
    
    END $$
    
    DELIMITER ;
    

    and call by, mysql_connection specification and

    $loginCheck="call sp_user_login('".$username."','".$password."');";
    

    it will return the result from the procedure.

提交回复
热议问题