我的查询正在运行,但它是硬编码的,所以我使用了绑定变量,以便它可以向用户询问值,但在使用绑定变量后它无法正常工作。
SET serveroutput ON;
VARIABLE v_owner VARCHAR2(14);
DECLARE
v_count NUMBER;
CURSOR c2
IS
SELECT Column_name FROM all_tab_columns WHERE table_name= '&table_name_in_Capital';
BEGIN
:v_owner:='&v_owner';
FOR r1 IN c2
LOOP
EXECUTE immediate 'SELECT COUNT('||r1.column_name||') FROM'||:v_owner||'.'||'A' INTO v_count ;
IF v_count =0 THEN
dbms_output.put_line('Column'||' '||r1.column_name||' '||'is'||' '||v_count);
END IF;
END LOOP;
END;
答案 0 :(得分:0)
尝试这个:
DECLARE
v_count NUMBER;
CURSOR c2
IS
SELECT Column_name FROM all_tab_columns WHERE table_name= '&table_name_in_Capital';
BEGIN
:v_owner:='&v_owner';
FOR r1 IN c2
LOOP
EXECUTE immediate 'SELECT COUNT('||r1.column_name||') FROM '||:v_owner||'.'||'A' INTO v_count ;
IF v_count =0 THEN
dbms_output.put_line('Column'||' '||r1.column_name||' '||'is'||' '||v_count);
END IF;
END LOOP;
END;
/
一些空间问题..