当前位置: 技术问答>linux和unix
写了个脚本,里面的function不知道怎么传参数,帮帮忙
来源: 互联网 发布时间:2015-11-23
本文导语: function 是对数据库的一些表的处理,declare ...begin ...end 之类的,现在希望可以在function中写参数到procedure中去,因为几个表做相似的处理,所以想写一个function完成之,请教怎么写 function runSQL{ SET SERVEROUTPUT ON; DECLARE ...
function 是对数据库的一些表的处理,declare ...begin ...end 之类的,现在希望可以在function中写参数到procedure中去,因为几个表做相似的处理,所以想写一个function完成之,请教怎么写
function runSQL{
SET SERVEROUTPUT ON;
DECLARE
n_del_total NUMBER;
n_count NUMBER;
n_del_num NUMBER;
d_strt_date DATE;
d_end_date DATE;
v_chk_pt VARCHAR2 (20) := '0000';
on_rtn_val NUMBER;
v_errmsg VARCHAR2 (2000) := NULL;
ov_errmsg VARCHAR2 (2000);
e_fail EXCEPTION;
BEGIN
SELECT COUNT (*)
INTO n_count
FROM spr_system_parameter
WHERE spr_class = v_short_table_name AND spr_name = v_para_name;
IF n_count > 0
THEN
SELECT NVL (spr_val, 90)
INTO n_del_num
FROM spr_system_parameter
WHERE spr_class = v_short_table_name AND spr_name = v_para_name;
ELSE
INSERT INTO spr_system_parameter
(para_id, app_appl_id, spr_type,
descrp, spr_class,
spr_name, spr_val, upd_cnt, creation_date, created_by,
last_upd_date, last_upd_by
)
VALUES (spr_seq.NEXTVAL, 1, 'C',
REPLACE (v_table_name, '_', ' '), v_short_table_name,
v_para_name, '90', 0, SYSDATE, 2654,
SYSDATE, 2654
);
n_del_num := 90;
END IF;
---begin clear obr
SELECT COUNT (*)
INTO n_del_total
FROM v_table_name a
WHERE TRUNC (a.eff_end_date)
function runSQL{
SET SERVEROUTPUT ON;
DECLARE
n_del_total NUMBER;
n_count NUMBER;
n_del_num NUMBER;
d_strt_date DATE;
d_end_date DATE;
v_chk_pt VARCHAR2 (20) := '0000';
on_rtn_val NUMBER;
v_errmsg VARCHAR2 (2000) := NULL;
ov_errmsg VARCHAR2 (2000);
e_fail EXCEPTION;
BEGIN
SELECT COUNT (*)
INTO n_count
FROM spr_system_parameter
WHERE spr_class = v_short_table_name AND spr_name = v_para_name;
IF n_count > 0
THEN
SELECT NVL (spr_val, 90)
INTO n_del_num
FROM spr_system_parameter
WHERE spr_class = v_short_table_name AND spr_name = v_para_name;
ELSE
INSERT INTO spr_system_parameter
(para_id, app_appl_id, spr_type,
descrp, spr_class,
spr_name, spr_val, upd_cnt, creation_date, created_by,
last_upd_date, last_upd_by
)
VALUES (spr_seq.NEXTVAL, 1, 'C',
REPLACE (v_table_name, '_', ' '), v_short_table_name,
v_para_name, '90', 0, SYSDATE, 2654,
SYSDATE, 2654
);
n_del_num := 90;
END IF;
---begin clear obr
SELECT COUNT (*)
INTO n_del_total
FROM v_table_name a
WHERE TRUNC (a.eff_end_date)