CREATE PROCEDURE NewWeekPlan
@file_type numeric(1),
@file_department varchar(50),
@file_station varchar(50),
@file_owner numeric(9),
@weekplan_wk1plan varchar(255),
@weekplan_wk2plan varchar(255),
@weekplan_wk3plan varchar(255),
@weekplan_wk4plan varchar(255),
@weekplan_wk5plan varchar(255),
@weekplan_wk1result varchar(255),
@weekplan_wk2result varchar(255),
@weekplan_wk3result varchar(255),
@weekplan_wk4result varchar(255),
@weekplan_wk5result varchar(255),
@weekplan_wk1plannext varchar(255),
@weekplan_wk2plannext varchar(255),
@weekplan_wk3plannext varchar(255),
@weekplan_wk4plannext varchar(255),
@weekplan_wk5plannext varchar(255),
@weekplan_problem1 varchar(255),
@weekplan_problem2 varchar(255),
@weekplan_problem3 varchar(255),
@weekplan_suggest1 varchar(255),
@weekplan_suggest2 varchar(255),
@weekplan_suggest3 varchar(255)
AS INSERT INTO tb_file (file_type,file_department,file_station,file_owner) VALUES (@file_type,@file_department,@file_station,@file_owner)
if @@IDENTITY>0
INSERT INTO tb_file_weekplan (weekplan_file,weekplan_wk1plan,weekplan_wk2plan,weekplan_wk3plan,weekplan_wk4plan,weekplan_wk5plan) VALUES (@@IDENTITY,@weekplan_wk1plan,@weekplan_wk2plan,@weekplan_wk3plan,@weekplan_wk4plan,@weekplan_wk5plan)
GO
//———————-yemaosheng.com——————————–
用 last_insert_id() 函数这样来模拟一个 sequence 实现:
mysql> CREATE TABLE sequence (id INT NOT NULL);
mysql> INSERT INTO sequence VALUES (0);
mysql> UPDATE sequence SET id=LAST_INSERT_ID(id+1);