SELECT SEQ_TEST.NEXTVAL INTO :NEW.ID FROM DUAL是什么意思
SQL>CREATETABLETEST_TRG(IDNUMBER,NAMEVARCHAR2(20));SQL>CREATESEQUENCESEQ_TEST;SQL>CRE...
SQL> CREATE TABLE TEST_TRG
(ID NUMBER, NAME VARCHAR2(20));
SQL> CREATE SEQUENCE SEQ_TEST;
SQL> CREATE OR REPLACE TRIGGER BI_TEST_TRG
BEFORE INSERT OR UPDATE OF ID
ON TEST_TRG
FOR EACH ROW
BEGIN
IF INSERTING THEN
SELECT SEQ_TEST.NEXTVAL INTO :NEW.ID FROM DUAL;
ELSE
RAISE_APPLICATION_ERROR(-20020, '不允许更新ID值!');
END IF;
END; 展开
(ID NUMBER, NAME VARCHAR2(20));
SQL> CREATE SEQUENCE SEQ_TEST;
SQL> CREATE OR REPLACE TRIGGER BI_TEST_TRG
BEFORE INSERT OR UPDATE OF ID
ON TEST_TRG
FOR EACH ROW
BEGIN
IF INSERTING THEN
SELECT SEQ_TEST.NEXTVAL INTO :NEW.ID FROM DUAL;
ELSE
RAISE_APPLICATION_ERROR(-20020, '不允许更新ID值!');
END IF;
END; 展开
1个回答
展开全部
将序列SEQ_TEST的下一个值 赋给新插入数据的id
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询