Sunday, 30 November 2014

MySQL Stored Procedure Tutorial

MySQL Stored Procedure Tutorial

I am sharing an example of MySQL stored procedure.

DELIMITER $$

USE `company`$$

DROP PROCEDURE IF EXISTS `update_t`$$

CREATE DEFINER=`root`@`%` PROCEDURE `update_t`(OUT last_id INT(11),OUT last_url 
VARCHAR(200))
BEGIN    
    SELECT company_id,company_url INTO last_id,last_url FROM company 
    ORDER BY id ASC LIMIT 0,1 LOCK IN SHARE MODE;
    UPDATE company SET cc=1 WHERE company_id = last_id;
    END$$

DELIMITER ;

No comments:

Post a Comment

Create .ICS file using PHP code

Recently worked on creating a .ics file in PHP after a very long time, code so thought to share with everybody. Please find below the comple...