create or replace trigger t_hepub_terminal
before insert on hepub_terminal
referencing new as new old as old
for each row
declare
-- local variables here a_terminalcode varchar2(200);
a_PK_TERMINAL_H varchar2(20);
begin
a_terminalcode:=:new.terminalcode;
a_PK_TERMINAL_H:=:new.PK_TERMINAL_H;
if length(trim(nvl(a_terminalcode,'')))=0 or a_terminalcode is null then --业务类型定义
--回复短信内容定义
---a_terminalcode:=zhongduandaima.nextval;
select cast(zhongduandaima.nextval as varchar2(5)) into a_terminalcode from dual;
update hepub_terminal set terminalcode=a_terminalcode where PK_TERMINAL_H=a_PK_TERMINAL_H;
---and terminalcode is null;
--任务
end if;
end T_hepub_terminal;
这个触发器有什么问题
新增后 自增量已经加1了 但是没有写入到hepub_terminal 表中
before insert on hepub_terminal
referencing new as new old as old
for each row
declare
-- local variables here a_terminalcode varchar2(200);
a_PK_TERMINAL_H varchar2(20);
begin
a_terminalcode:=:new.terminalcode;
a_PK_TERMINAL_H:=:new.PK_TERMINAL_H;
if length(trim(nvl(a_terminalcode,'')))=0 or a_terminalcode is null then --业务类型定义
--回复短信内容定义
---a_terminalcode:=zhongduandaima.nextval;
select cast(zhongduandaima.nextval as varchar2(5)) into a_terminalcode from dual;
update hepub_terminal set terminalcode=a_terminalcode where PK_TERMINAL_H=a_PK_TERMINAL_H;
---and terminalcode is null;
--任务
end if;
end T_hepub_terminal;
这个触发器有什么问题
新增后 自增量已经加1了 但是没有写入到hepub_terminal 表中
解决方案 »
- 急求,如何查找已删除的数据sql语句
- 工作问题!不得其解
- 存储过程,oracle插入数据,某列递增1
- 在vs2005利用sqlDataSource连接Oracle10g数据库服务器名怎么写的
- oracle9I服务器端怎么样才能连接上另一个电脑上的数据库?
- 初学oracle,请指教!
- 请问一个简单的问题
- 求一sql
- Short Circuit Logical Operators
- select 1 from dual where NVL(NULL,'') = NVL(NULL,'')为啥没结果啊?求助大神们~~
- SYS登录提示"connection as SYS should be as SYSDBA or SYSOPER"
- 请教PL/SQL如何查看执行计划 - 实例分析
我也不是很懂
如果要这样的话需要使用自治事务的你想要这个触发器实现什么功能?
将表中PK_TERMINAL与插入的新PK_TERMINAL相等的那些行的terminalcode改成新的terminalcode?
create or replace trigger t_hepub_terminal
before insert on hepub_terminal
for each row
declare
a_terminalcode varchar2(200);
begin
select to_char(zhongduandaima.nextval) into a_terminalcode from dual;
:new.terminalcode:=a_terminalcode;
end;
/
minvalue 1
maxvalue 9999999999999999
start with 1
increment by 1
cache 20
order;
------------------
create or replace trigger DATA_PRODUCT_ID
before insert on user.table for each row
declare
currentNum NUMBER(10);
begin
select HARD_SEQ.nextval into currentNum from dual;
:new.ID := currentNum;
end DATA_PRODUCT_ID;