Welcome to the website navigation,本站只接受合法正规的企业网站,欢迎站长们提交你的网站获得展示和流量有任何问题请联系站长,欢迎大家加入本站。

                
提交网站
  • 网站:76083
  • 待审:5
  • APP:577
  • 文章:304411
  • 会员:56004
文字内链包年1000元 文字内链包年1000元 文字内链包年1000元 AI办公网站 AI绘画工具 AIchat

名站网址导航为大家提供关于数据库教程相关的教程网站知识。

Oracle中sys和system的区别小结xfxAIChat_企业网址导航_网址分类目录_企业黄页网址提交查询专业网站!

xfxAIChat_企业网址导航_网址分类目录_企业黄页网址提交查询专业网站!

一。存储过程的创建和使用

1.创建程序包,并在程序中创建存储过程

create or replace
PACKAGE NCS_ICP_TJ AS
/*lfx@ncs-cyber.com.cn*/
/* TODO 在此输入程序包声明 (类型, 异常错误, 具体相关方法等) */
/*根据备案主体ID拷贝通过表备案数据到备案临时表,拷贝5张*/
PROCEDURE ICP_PASS_TO_TEMP(
v_main_id IN icp_gn_temp_baxx_zt.ztid%TYPE,
v_lyd IN icp_gn_temp_baxx_zt.SJXT_ZTID%TYPE,
v_in_hmd IN icp_gn_temp_baxx_zt.in_hmd%TYPE,
v_czlb IN icp_gn_temp_baxx_zt.czlb%TYPE,
v_bajd IN icp_gn_temp_baxx_zt.bajd%TYPE
);
END NCS_ICP_TJ;
2.创建程序包包体,并在程序中创建存储过程实现

create or replace
PACKAGE BODY ncs_icp_tj AS
/*根据备案主体ID拷贝通过表备案数据到备案临时表,拷贝5张*/
PROCEDURE ICP_PASS_TO_TEMP(
v_main_id IN icp_gn_temp_baxx_zt.ztid%TYPE,
v_lyd IN icp_gn_temp_baxx_zt.SJXT_ZTID%TYPE,
v_in_hmd IN icp_gn_temp_baxx_zt.in_hmd%TYPE,
v_czlb IN icp_gn_temp_baxx_zt.czlb%TYPE,
v_bajd IN icp_gn_temp_baxx_zt.bajd%TYPE
)
IS
v_lsh integer;
BEGIN
select SEQ_ICP_GN_TEMP_BAXX_ZT_ZTID.NEXTVAL into v_lsh from dual;
IF v_main_id IS NULL OR v_lyd IS NULL OR v_in_hmd IS NULL OR v_czlb IS NULL OR v_bajd IS NULL ThEN
RAISE_APPLICATION_ERROR(-20000, 'Exsit null value in arguments.');
END IF;
/*所有插入的查询条件为主体ID*/
/* 插入主体*/
INSERT INTO ICP_GN_TEMP_BAXX_ZT
(LSh, BBDW,ZTID, SJXT_ZTID, YhM_ID, IN_hMD, CZLB, SCBBSJ, ZJXGSJ, DWMC, DWXZ, TZZ, ZJLX, ZJhM, ShENGID,
ShIID, XIANID, XXDZ, ZJZS,JYLX, WZFZR, WZFZR_ZJLX, WZFZR_ZJhM, WZFZR_DhhM, WZFZR_SJhM,
WZFZR_DZYJ, WZFZR_MSN, WZFZR_QQ, BAXh, BAJD, ZSYXQ, ShR_XM,
ShSJ, BZ, LRYhLX, LR_YhM_ID, BAMM)
SELECT
v_lsh, BBDW, v_main_id, SJXT_ZTID, YhM_ID, v_in_hmd/*是否在黑名单*/, v_czlb/*操作办法类别*/, SCBBSJ, ZJXGSJ, DWMC, DWXZ, TZZ, ZJLX, ZJhM, ShENGID,
ShIID, XIANID, XXDZ, ZJZS, JYLX,WZFZR, WZFZR_ZJLX, WZFZR_ZJhM, WZFZR_DhhM, WZFZR_SJhM,
WZFZR_DZYJ, WZFZR_MSN, WZFZR_QQ, BAXh,v_bajd/*备案阶段*/, ZSYXQ, ShR_XM,
ShSJ,BZ, LRYhLX, LR_YhM_ID, BAMM
FROM ICP_GN_BAXX_ZT WhERE ID = v_main_id;
/*插入网站*/
INSERT INTO ICP_GN_TEMP_BAXX_WZ
(LSh,BBDW,WZID, ZTID, SJXT_WZID, SCBBSJ, XGSJ, WZMC, SYURL, WZFZR, WZFZR_ZJLX, WZFZR_ZJhM, WZFZR_DhhM, WZFZR_SJhM, WZFZR_DZYJ, WZFZR_MSN, WZFZR_QQ, NRLX, FWNR, BAXh, LRYhLX, LR_YhM_ID, BAMM, BZ,BAJD)
SELECT
v_lsh,BBDW,id, v_main_id, SJXT_WZID, SCBBSJ, XGSJ, WZMC, SYURL, WZFZR, WZFZR_ZJLX, WZFZR_ZJhM, WZFZR_DhhM, WZFZR_SJhM, WZFZR_DZYJ, WZFZR_MSN, WZFZR_QQ, NRLX, FWNR, BAXh, LRYhLX, LR_YhM_ID, BAMM, BZ,1
FROM ICP_GN_BAXX_WZ
WhERE ZTID = v_main_id;
/*插入接入*/
INSERT INTO ICP_GN_TEMP_BAXX_JR
(lsh, bbdw,JRID, ZTID, WZID, SJXT_JRID, SSISP, WZFB, WZJRFS, LRYhLX, LR_YhM_ID, BAMM, bajd)
SELECT
v_lsh, bbdw,ID, v_main_id, WZID, SJXT_JRID, SSISP, WZFB, WZJRFS, LRYhLX, LR_YhM_ID, BAMM,v_bajd
FROM ICP_GN_BAXX_JR
WhERE ZTID =v_main_id;
/*插入IP*/
INSERT INTO ICP_GN_TEMP_BAXX_IPLB
(lsh,bbdw,IPID, ZTID, WZID, JRID, SJXT_IPID, QSIP, ZZIP)
SELECT v_lsh, bbdw,ID, v_main_id, WZID, JRID, SJXT_IPID, QSIP, ZZIP
FROM ICP_GN_BAXX_IPLB
WhERE ZTID = v_main_id;

/*插入域名*/
INSERT INTO ICP_GN_TEMP_BAXX_YMLB
(lsh, bbdw,YMID, ZTID, WZID, SJXT_YMID, YM)
SELECT
v_lsh, bbdw,ID, v_main_id, WZID, SJXT_YMID, YM
FROM ICP_GN_BAXX_YMLB
WhERE ZTID = v_main_id;

END ICP_PASS_TO_TEMP;

END ncs_icp_tj;

3. 调用存储过程,call ncs_icp_tj.icp_pass_to_temp(5,1,0,2,17)

本存储过程的调用,实现了从5张通过表复制数据到5张临时表

二,触发器的创建。

1.行级触发器,没插入一条数据执行一次, 向临时表中加入数据时,执行此触发器,把临时表插入到临时表的数据复制的日志表中

create or replace
TRIGGER TRIGGER_ICP_TEMP_ZT_INSERT
AFTER INSERT ON ICP_GN_TEMP_BAXX_ZT
FOR EACh ROW
BEGIN
insert into ICP_GN_BAXX_XGLS_ZT
(ID,LSh, BBDW,LS_ID,ZTID,SJXT_ZTID, DWMC, DWXZ, TZZ, ZJLX, ZJhM, ShENGID,
ShIID, XIANID, XXDZ, ZJZS,JYLX, WZFZR, WZFZR_ZJLX, WZFZR_ZJhM, WZFZR_DhhM, WZFZR_SJhM,
WZFZR_DZYJ, WZFZR_MSN, WZFZR_QQ, BAXh, ShR_XM,
ShSJ, BZ, LRYhLX, LR_YhM_ID, BAMM)
values( 
SEQ_ICP_GN_BAXX_XGLS_ZT_ID.NEXTVAL,:new.LSh, :new.BBDW,:new.CZLB,:new.ZTID,:new.SJXT_ZTID, :new.DWMC, :new.DWXZ, :new.TZZ, :new.ZJLX, :new.ZJhM, :new.ShENGID,
:new.ShIID, :new.XIANID, :new.XXDZ, :new.ZJZS,:new.JYLX, :new.WZFZR, :new.WZFZR_ZJLX, :new.WZFZR_ZJhM, :new.WZFZR_DhhM, :new.WZFZR_SJhM,
:new.WZFZR_DZYJ, :new.WZFZR_MSN, :new.WZFZR_QQ, :new.BAXh, :new.ShR_XM,
:new.ShSJ, :new.BZ, :new.LRYhLX, :new.LR_YhM_ID, :new.BAMM);
END;


create or replace TRIGGER TRIGGER_ICP_TEMP_WZ_INSERT
AFTER INSERT ON ICP_GN_TEMP_BAXX_WZ
FOR EACh ROW
BEGIN
insert into ICP_GN_BAXX_XGLS_WZ
(ID,
LSh,BBDW,WZID, ZTID, SJXT_WZID, WZMC, SYURL,WZFZR, WZFZR_ZJLX, WZFZR_ZJhM, WZFZR_DhhM,
WZFZR_SJhM, WZFZR_DZYJ, WZFZR_MSN, WZFZR_QQ, NRLX, FWNR, BAXh, LRYhLX, LR_YhM_ID,BZ, ls_id)
values( SEQ_ICP_GN_BAXX_XGLS_WZ_ID.NEXTVAL,
:new.LSh,:new.BBDW,:new.WZID, :new.ZTID, :new.SJXT_WZID, :new.WZMC, :new.SYURL,:new.WZFZR, :new.WZFZR_ZJLX, :new.WZFZR_ZJhM, :new.WZFZR_DhhM,
:new.WZFZR_SJhM, :new.WZFZR_DZYJ, :new.WZFZR_MSN, :new.WZFZR_QQ, :new.NRLX, :new.FWNR, :new.BAXh, :new.LRYhLX, :new.LR_YhM_ID,:new.BZ,1);
END;


create or replace
TRIGGER TRIGGER_ICP_TEMP_JR_INSERT
AFTER INSERT ON ICP_GN_TEMP_BAXX_JR
FOR EACh ROW
BEGIN
insert into ICP_GN_BAXX_XGLS_JR
(ID,
lsh, bbdw,JRID, ZTID, WZID, SJXT_JRID, SSISP,
WZFB, WZJRFS, LRYhLX, LR_YhM_ID, ls_id
)
values (SEQ_ICP_GN_BAXX_XGLS_JR_ID.NEXTVAL,
:new.lsh, :new.bbdw,:new.JRID, :new.ZTID, :new.WZID, :new.SJXT_JRID, :new.SSISP,
:new.WZFB, :new.WZJRFS, :new.LRYhLX, :new.LR_YhM_ID,1);
END;


create or replace
TRIGGER TRIGGER_ICP_TEMP_IPLB_INSERT
AFTER INSERT ON ICP_GN_TEMP_BAXX_IPLB
FOR EACh ROW
BEGIN
insert into ICP_GN_BAXX_XGLS_IPLB
(ID,
lsh,bbdw,IPID, ZTID, WZID, JRID, SJXT_IPID, QSIP, ZZIP, ls_id
)
values( SEQ_ICP_GN_BAXX_XGLS_IPLB_ID.NEXTVAL,
:new.lsh,:new.bbdw,:new.IPID, :new.ZTID, :new.WZID, :new.JRID, :new.SJXT_IPID, :new.QSIP, :new.ZZIP,1);
END;

2.表级触发器 插入整个过程中,触发器只之行一次 ,当向AAA表中如入一条数据,将真个AAA表的数据复制BBB表

create or replace
TRIGGER TRIGGER_AAA_INSERT
AFTER INSERT ON AAA
BEGIN
insert into BBB(userid, username)
select id, username from AAA;
END; 关于数据库教程相关的教程网站知识今天我们就说到这里了,希望可以帮到大家。

标签:

分享到:

  网友投稿

注册时间:

网站:0 个   APP:0 个  文章:0 篇

  • 76083

    网站

  • 577

    APP

  • 304411

    文章

  • 56004

    会员

赶快注册账号,推广您的网站吧!
文章分类
热门网站
最新入驻APP小程序

宝贝市场2023-02-08

宝贝市场——买手和卖家商品展示

夺宝助手2023-02-08

夺宝助手小程序,查看每日快夺宝平

查诚信2023-02-08

查诚信是一款免费的商业查询工具

车价天天报2023-02-08

快速连接汽车销售,获知汽车最新报

考勤助理小程序2023-02-08

上班签到考勤,实时定位,后台轻松

汽车报价大全查询2023-02-08

汽车报价大全查询提供最新汽车市