--监控某个表,当数据插入到表后,执行触发。
CREATE trigger tri_ins_UB_ORGINFO
after INSERT ON UB_ORGINFO
--for insert
REFERENCING NEW AS n
FOR EACH ROW --MODE DB2SQL
BEGIN ATOMIC
delete from UB_ORGINFO_HK;
insert into UB_ORGINFO_HK (
SELECT I_ID as ibankid, S_DISPLAYNAME as SBANKNAME,PBCBIGAREABANK as sbanktype
FROM UB_ORGINFO
WHERE -- BUSINESSCATEGORY !='1' AND
I_STATUS=1
AND S_DN IS NULL AND PBCBIGAREABANK=276
AND PBCBIGAREABANK IS not NULL) ;
end
---------------------
相关推荐
CREATE TRIGGER OVERDRAFT_TRIGGER BEFORE UPDATE OF CheckingBalance ON accttable FOR EACH ROW WHEN (new.CheckingBalance ) BEGIN ATOMIC IF (new.CheckingBalance ) THEN ROLLBACK WORK; END ``` 此触发器的...
创建触发器使用CREATE TRIGGER语句,例如:CREATE TRIGGER zjt_tables_del AFTER DELETE ON zjt_tables REFERENCING OLD AS O FOR EACH ROW MODE DB2SQL Insert into zjt_tables1 values(substr(o.tabschema,1,8),...
7. 建立触发器:CREATE TRIGGER命令用于创建一个新的触发器,例如:CREATE TRIGGER zjt_tables_del AFTER DELETE ON zjt_tables REFERENCING OLD AS O FOR EACH ROW MODE DB2SQL Insert into zjt_tables1 values...
- **示例**:`db2=createtrigger emp_insert_trigger` - **列出表空间**:`db2=listtablespace [showdetail]` - **功能**:列出所有表空间及其详细信息。 - **参数**:`showdetail`可选参数,显示更多细节。 - ...
CREATE TRIGGER zjt_tables_del AFTER DELETE ON zjt_tables REFERENCING OLD AS O FOR EACH ROW MODE DB2SQL INSERT INTO zjt_tables1 VALUES (SUBSTR(O.tabSchema, 1, 8), SUBSTR(O.tabName, 1, 10)); ``` #### ...
CREATE OR REPLACE TRIGGER connect_audit_trg BEFORE INSERT ON connect_audit FOR EACH ROW BEGIN :new.timestamp := SYSDATE; END; ``` **DB2:** ```sql CREATE TRIGGER connect_audit_trg NO CASCADE BEFORE ...
- `create trigger triggername` 定义数据库触发器,用于在特定事件发生时执行操作。 12. **表空间管理**: - `list tablespace[show detail]` 获取表空间的基本或详细信息。 - `list tablespace containers for...
CREATE OR REPLACE TRIGGER user_insert_trigger BEFORE INSERT ON user REFERENCING NEW AS new FOR EACH ROW BEGIN ATOMIC SET (new.id) = (NEXT VALUE FOR user_id_sequence); END; ``` #### 四、Identity与...
CREATE DATABASE DB2_GCB ON G: ALIAS DB2_GCB USING CODE SET GBK TERRITORY CN COLLATE USING SYSTEM DFT_EXTENT_SZ 32 ``` **解释:** 该命令用于创建一个新的DB2数据库实例。具体参数解析如下: - `CREATE ...
`CREATE TRIGGER zjt_tables_del AFTER DELETE ON zjt_tables REFERENCING OLD AS OF FOR EACH ROW MODE DB2SQL INSERT INTO zjt_tables1 VALUES(substr(o.tabschema,1,8),substr(o.tabname,1,10))` 当从zjt_...
1. **数据定义语言(DDL)**:包括创建数据库、表、视图、索引等对象的语句,如`CREATE DATABASE`,`CREATE TABLE`,`CREATE INDEX`等。 2. **数据操作语言(DML)**:涉及插入、更新、删除数据的语句,如`INSERT ...
* 655:为 CREATE 或 ALTER STOGROUP 语句指定特定或者非特定的卷 ID,在 DB2 较新发布的版本中(版本 6 以后)将不再支持他们 * 658:当建立目录索引时,不能指定 SUBPAGES 语句,SUBPAGES 语句将被忽略 这些错误...
- **创建触发器**:`CREATE TRIGGER`定义触发器,如在删除`zjt_tables`后执行操作。 - **建立唯一性索引**:`CREATE UNIQUE INDEX`创建唯一索引,防止重复数据,如`CREATE UNIQUE INDEX I_ztables_tabname ON zjt_...
CREATE TRIGGER zjt_tables_del AFTER DELETE ON zjt_tables REFERENCING OLD AS O FOR EACH ROW MODE DB2 SQL INSERT INTO zjt_tables1 VALUES (SUBSTR(O.tabSchema, 1, 8), SUBSTR(O.tabName, 1, 10)); -- 创建...
DB2是一种广泛应用于...创建触发器的语句如 `CREATE TRIGGER trigger_name FOR INSERT ON table_name AS ...`。 通过深入学习和实践这些DB2 SQL语句,开发者可以更高效地管理和操作数据库,实现复杂的数据处理任务。
CREATE TRIGGER connect_audit_trg NO CASCADE BEFORE INSERT ON connect_audit REFERRING NEW AS n FOR EACH ROW MODE DB2SQL BEGIN ATOMIC SET n.timestamp = CURRENT_TIMESTAMP; END ``` - 注意点: 在DB2中,...
触发器则是在特定数据库事件发生时自动执行的程序,如数据插入、更新或删除,用`CREATE TRIGGER`语句创建。 七、安全性与权限管理 DB2 UDB提供了丰富的权限和角色机制,用于控制用户对数据库对象的访问。`GRANT`和`...
- **语法**: `CREATE TRIGGER <触发器名> AFTER DELETE ON <表名> REFERENCING OLD AS <旧记录别名> FOR EACH ROW MODE DB2SQL INSERT INTO <目标表> VALUES(...);` - **示例**: ```sql CREATE TRIGGER ZJT_...
CREATE TRIGGER trg_name AFTER INSERT ON table_name FOR EACH ROW BEGIN -- SQL 语句 END; ``` - **触发时机**: - `BEFORE`:在数据插入前触发。 - `AFTER`:在数据插入后触发。 触发器可以用于确保...
CREATE TRIGGER ZJT_TABLES_DEL AFTER DELETE ON ZJT_TABLES REFERENCING OLD AS O FOR EACH ROW MODE DB2SQL INSERT INTO ZJT_TABLES1 VALUES(SUBSTR(O.TABSCHEMA, 1, 8), SUBSTR(O.TABNAME, 1, 10)); ``` **说明*...