CREATE OR REPLACE PROCEDURE USP_table_row_count
AS
v_id NUMBER :=0;
v_table_name VARCHAR2(100);
v_owner VARCHAR2(100);
v_count NUMBER;
v_row_count NUMBER;
CURSOR c_tables IS
SELECT fld_id ,fld_owner, fld_table_name,fld_row_count_new FROM tbl_table_row_count;
BEGIN
OPEN c_tables;
LOOP
FETCH c_tables INTO v_id,v_owner, v_table_name, v_row_count;
EXIT WHEN c_tables%notfound;
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM '||v_owner||'.'||v_table_name INTO v_count;
DBMS_OUTPUT.PUT_LINE(v_owner || ' '|| v_table_name ||' '|| v_count);
UPDATE TBL_TABLE_ROW_COUNT SET FLD_ROW_COUNT_OLD=V_ROW_COUNT WHERE FLD_id=v_id;
UPDATE TBL_TABLE_ROW_COUNT SET FLD_ROW_COUNT_NEW=V_COUNT WHERE FLD_id=v_id;
UPDATE TBL_TABLE_ROW_COUNT SET FLD_row_DIF=V_COUNT-v_ROW_COUNT WHERE FLD_id=v_id;
END LOOP;
CLOSE c_tables;
END;
/
所以我有上面的程序。我有一张表,其中包含DB中所有模式的所有表。在这个过程中,我尝试将每个表行插入到表中。问题是我收到此错误: 00933。 00000 - " SQL命令未正确结束" 。奇怪的是DBMS_OUPUT输出完善了每个表的数据。如果我做了一个例外,并且只为我没有登录的用户尝试立即执行,则可以正常工作。