PLSQL子程序如何传送表参数
CREATE OR REPLACE PROCEDURE AUDIT_TABLES_PUSH(V_TABLES VARCHAR2) AS
V_I NUMBER(10);
V_TABLES VARCHAR2(100);
BEGIN
V_TABLES:='';--表名
SELECT COUNT(*) INTO V_I FROM BANKINFODM@CClink;
IF V_I>0 THEN
EXECSQL('DELETE FROM BANKINFODM@CClink');
COMMIT;
END IF;
INSERT INTO BANKINFODM@CClink(TIMESTAMPS,BANKID,BANKCODE,BANKNAME,
BANKSNAME)
SYSTEMDATE,XXID,GGDM,OOMC,BSNAME FROM V_TABLES;
END;
/
麻烦大牛可以修改下,我其实想把表通过过程传递进去,实现插到另外一个库里去
,目前我这样写,直接报错了,唉!
------解决方案--------------------传送表?插入库? insert table select * from table@link ?
楼主,详细描述一下需求
------解决方案--------------------INSERT INTO BANKINFODM@CClink(TIMESTAMPS,BANKID,BANKCODE,BANKNAME,
BANKSNAME)SYSTEMDATE,XXID,GGDM,OOMC,BSNAME FROM V_TABLES;
缺少select了,在SYSTEMDATE前加select
------解决方案--------------------因为表名是变量,这时该使用动态sql了
CREATE OR REPLACE PROCEDURE AUDIT_TABLES_PUSH(V_TABLES VARCHAR2) AS
V_I NUMBER(10);
BEGIN
SELECT COUNT(*) INTO V_I FROM BANKINFODM@CClink;
IF V_I > 0 THEN
DELETE FROM BANKINFODM@CClink;
COMMIT;
END IF;
execute immediate
'INSERT INTO BANKINFODM@CClink(TIMESTAMPS,BANKID,BANKCODE,BANKNAME, BANKSNAME) SELECT SYSTEMDATE,XXID,GGDM,OOMC,BSNAME FROM '
------解决方案--------------------
V_TABLES;
COMMIT;
END;
/