Evidently I am a novice at this.
I have written the following procedure which gives compilation errors. The intention is to continue the cursor loop even when I come across tables that I do not have access to. I am sure it will be easy to tell for any one of you experts... help!
PROCEDURE
-------------------------
CREATE OR REPLACE PROCEDURE A1
AS
CURSOR c1 is
select distinct table_name from all_tab_columns where TABLE_NAME not in
(select table_name from all_tab_columns where data_type='DATE' ) and
TABLE_NAME not like '%$%' and OWNER='N1_DBA';
v_tname all_tab_columns.table_name%type;
FUNCTION countit(tn VARCHAR2)
RETURN NUMBER
IS
return_value NUMBER(10);
strsql VARCHAR2(255);
BEGIN
strsql := 'select count(1) from ' || tn;
EXECUTE IMMEDIATE strsql into return_value;
RETURN return_value;
END;
BEGIN
open c1;
loop
fetch c1 into v_tname;
exit when c1%notfound;
dbms_output.put_line(v_tname || ' '|| TO_CHAR(countit(v_tname)));
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(v_tname || ' == could not count');
END;
end loop;
close c1;
END;
ERRORS:
------------------
Errors for PROCEDURE A1:
LINE/COL ERROR
-------- -----------------------------------------------------------------
26/3 PLS-00103: Encountered the symbol "EXCEPTION" when expecting one
of the following:
begin declare end exit for goto if loop mod null pragma raise
return select update while <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall
<a single-quoted SQL string>
30/2 PLS-00103: Encountered the symbol "END" when expecting one of the
following:
begin function package pragma procedure form
I have written the following procedure which gives compilation errors. The intention is to continue the cursor loop even when I come across tables that I do not have access to. I am sure it will be easy to tell for any one of you experts... help!
PROCEDURE
-------------------------
CREATE OR REPLACE PROCEDURE A1
AS
CURSOR c1 is
select distinct table_name from all_tab_columns where TABLE_NAME not in
(select table_name from all_tab_columns where data_type='DATE' ) and
TABLE_NAME not like '%$%' and OWNER='N1_DBA';
v_tname all_tab_columns.table_name%type;
FUNCTION countit(tn VARCHAR2)
RETURN NUMBER
IS
return_value NUMBER(10);
strsql VARCHAR2(255);
BEGIN
strsql := 'select count(1) from ' || tn;
EXECUTE IMMEDIATE strsql into return_value;
RETURN return_value;
END;
BEGIN
open c1;
loop
fetch c1 into v_tname;
exit when c1%notfound;
dbms_output.put_line(v_tname || ' '|| TO_CHAR(countit(v_tname)));
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(v_tname || ' == could not count');
END;
end loop;
close c1;
END;
ERRORS:
------------------
Errors for PROCEDURE A1:
LINE/COL ERROR
-------- -----------------------------------------------------------------
26/3 PLS-00103: Encountered the symbol "EXCEPTION" when expecting one
of the following:
begin declare end exit for goto if loop mod null pragma raise
return select update while <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall
<a single-quoted SQL string>
30/2 PLS-00103: Encountered the symbol "END" when expecting one of the
following:
begin function package pragma procedure form