Friday, January 03, 2014

creating a stored procedure in mysql

DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `ins_shout`(aname varchar(200), ntext text, ipadd varchar(100))
BEGIN
    declare spam_t text;
    declare spam_n text;
    set spam_t='m';
    set spam_n ='m';
   
    select atext into spam_t from anti_spam where match (atext) against (ntext in boolean mode);
    select atext into spam_n from anti_spam where match (atext) against (aname in boolean mode);
    /*select spam_t;*/
   
    if spam_t= 'm' and spam_n='m'
    then
        insert into shouts(name, shout_msg, ip_address) values (aname,ntext, ipadd);
    end if;
   
    /*if strcmp(spam_t,'m') = -1
    then
        insert into shouts(name, shout_msg) values (spam_t,ntext);
    end if;
    */
END

No comments: