给我的场景如下。创建具有以下列的员工;
· EmpId
· EmpName
· EmpEmail
· EmpDate
在 OLTP 中,我需要一次输入一条记录,并且要在后端完成以下验证;
· EmpId should have a sequence generator
· No numeric values allowed in EmpName
· EmpDate should be in format mm/dd/yyyy
· Email Id should have following validations
o Should contain ‘@’ sign and it should be only one
o Should end with ‘.com’
o Email id should have more than 3 characters
为此,我创建了一个像这样的表和序列
create table emp_316599
(EmpId number(6),
EmpName varchar2(15)CONSTRAINT chk_EmpName
check(regexp_like(EmpName,'![0-9]+')),
EmpEmail varchar2(15) CONSTRAINT chk_EmpEmail
check((length(EmpEmail)>3) and
substr(EmpEmail,-4)='.com' and
instr(EmpEmail,'@',1,2)=0),
EmpDate varchar2(15)
CONSTRAINT chek_EmpDate
check(EmpDate=to_char(EmpDate,'mm-dd-yyyy')));
Table created.
create sequence Emp_SEQ
increment by 1
start with 1
maxvalue 1000
cache 20
sequence created.
问题来了。当我尝试使用以下命令插入时,它给了我错误。
insert into emp_316599 values(Emp_SEQ.NEXTVAL,'&EmpName','&EmpEmail','&EmpDate');
ORA-01722无效号码
请帮帮我。
工作环境如下 DB:Oracle 11g,工具:plsql developer
谢谢库马尔