MYSQL触发器的问题,请高手解答
fetchpaper表中有num字段,添加触发器的目的就是让num自动填入到数据库中,利用触发器自动增加并且不能重复,这是我根据oracle数据库触发器写的,大侠们看看错再哪里?
CREATE TRIGGER TIB_FETCHPAPER BEFORE
INSERT ON FETCHPAPER FOR EACH ROW
declare @row_count int(10),
declare @max_num char(100),
declare @zero_today char(100),
begin
case
when inserting then
@zero_today =select CONCAT('0391',DATE_FORMAT(curdate(),'%Y%m%d'),RPAD('0',4,'0'))
select @row_count=count(*) from fetchpaper
if @row_count = 0 then
@max_num=@zero_today
else
select @max_num=max(num)from fetchpaper
end if
if @max_num <@zero_today then
@max_num=@zero_today
end if
if NEW.num is null then
NEW.num=select rpad((@max_num)+1),14,'0')
end if
when updating('num') then
if NEW.num!=OLD.num then
NEW.num=OLD.num
end if
end case
end;
create table FETCHPAPER
(
ID int not null auto_increment comment '实名制领料单ID',
WAREHOUSEID int
相关问答:
String SQL="insert into 学生信息表 values(StudentNumber,StudentName,StudentAge)";其中StudentNumber,StudentName,StudentAge都是变量。这样写不对……到底该咋写啊
万分感谢!
String SQL=&q ......
表
CREATE TABLE `ch1` (
`id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
`no` int(10) unsigned DEFAULT NULL,
`dtime` datetime DEFAULT NULL,
PRIMARY KEY (`id ......
有一个js文件,是实现文字滚动的,其中的变量需要到mysql数据库中读取,那么怎样实现数据库连接而读取数据?
我是菜鸟,最好有完整的代码和解释,谢谢各位大虾啊啊啊啊啊啊!!!
http://blog.csdn.net/jemlee2002 ......
本人想知道MySql怎么在数据安装的时候就能自动去生成一些默认的用户和权限呢(用户:Client,密码:12345)?
比如是不是需要写自动安装脚本阿?等等,谢谢!
MySQL的标准安装,或者非安装版本中不会帮你创建这些 ......