如何在oracle数据库中创建TRIGGER column id auto increment with string?
How to create TRIGGER column id auto increment with string in oracle database?
我想要的列 id 中的结果:S-1、S-2、S-3
CREATE OR REPLACE TRIGGER auto_id
BEFORE INSERT ON login
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
:NEW.id := :NEW.id || to_char('"S-"',to_char(seq_log.nextval));
END login;
但是当我插入数据时出现错误
ORA-06502: PL/SQL: 数字或值错误: 字符到数字的转换错误
ORA-06512: 在“WKSP_WORKSPACE0089.AUTO_ID”,第 3 行
ORA-04088: 触发器执行期间出错 'WKSP_WORKSPACE0089.AUTO_ID'
ORA-06512: 在“SYS.DBMS_SQL”,第 1721 行
应该是
:NEW.id := :NEW.id || 'S-' || to_char(seq_log.nextval);
我想要的列 id 中的结果:S-1、S-2、S-3
CREATE OR REPLACE TRIGGER auto_id
BEFORE INSERT ON login
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
:NEW.id := :NEW.id || to_char('"S-"',to_char(seq_log.nextval));
END login;
但是当我插入数据时出现错误 ORA-06502: PL/SQL: 数字或值错误: 字符到数字的转换错误 ORA-06512: 在“WKSP_WORKSPACE0089.AUTO_ID”,第 3 行 ORA-04088: 触发器执行期间出错 'WKSP_WORKSPACE0089.AUTO_ID' ORA-06512: 在“SYS.DBMS_SQL”,第 1721 行
应该是
:NEW.id := :NEW.id || 'S-' || to_char(seq_log.nextval);