首页 > 解决方案 > 是否可以在存储过程中为参数数据类型传入 auto_increment?

问题描述

创建过程 add_fighter( 在 p_fighter_id int auto_increment , 在 p_fighter_name varchar(50) , 在 p_country_of_origin varchar(2) , 在 p_fighter_age int , 在 p_UFC_debut int ) 开始声明混乱 varchar(70);

-- check if fighter_id is empty
if p_fighter_id = '' then
set mess = 'please enter the fighter_id';
end if;
-- check if fighter_name is empty
if p_fighter_name = '' then
set mess = 'please enter the figher_name';
end if;

if p_country_of_origin = '' then
set mess = 'please enter the fighter''''s country_of_origin';
end if;

if p_fighter_age = '' then
set mess = 'please enter the fighter''s'' age';
end if;

if p_UFC_debut = '' then
set mess = 'please enter the fighter''''s UFC_debut year';
end if;

if p_fighter_name not like '% %' then
set mess = 'please enter the fighter''''s full name';
end if;

if counrty_of_origin not like '%__%' then
set mess = 'please use the 2 letter abbreviation of the country';
end if;


insert into fighters(
     fighter_id 
    ,fighter_name 
    ,country_of_origin
    ,fighter_age 
    ,UFC_debut 
    )
    values(
        p_fighter_id 
        ,p_fighter_name 
        ,p_country_of_origin
        ,p_fighter_age 
        ,p_UFC_debut 
        );

标签: mysql

解决方案


推荐阅读