Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reg- pl sql conditional compilation

795356Feb 14 2012 — edited Feb 14 2012
Version details
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
NLSRTL Version 10.2.0.4.0 - Production
create or replace package r_dummy_pkg
is
	procedure proc_table_doesnt_exist;
	procedure proc_valid;
end;
/

show err;

create or replace package body r_dummy_pkg
is
	procedure proc_table_doesnt_exist
	is
		l_count number;
	begin
		select count(*)
		into l_count
		from doesnt_exist_tbl;
	
	end proc_table_doesnt_exist;
	
	procedure proc_valid
	is
	begin
		dbms_output.put_line('Fine');
	end proc_valid;
end;
/

show err;
SQL> @"H:\Raghu\INDEX\cc.sql"

Package created.

No errors.

Warning: Package Body created with compilation errors.

Errors for PACKAGE BODY R_DUMMY_PKG:
7/3      PL/SQL: SQL Statement ignored
9/8      PL/SQL: ORA-00942: table or view does not exist
SQL>
Modified my code using Conditional Compilation and it got compiled fine
create or replace package r_dummy_pkg
is
	$if $$rgh_cc $then
	procedure proc_table_doesnt_exist;
	$end
	procedure proc_valid;

end;
/

show err;

create or replace package body r_dummy_pkg
is
	$if $$rgh_cc $then
	procedure proc_table_doesnt_exist
	is
		l_count number;
	begin
		select count(*)
		into l_count
		from doesnt_exist_tbl;
	
	end proc_table_doesnt_exist;
	$end
	
	procedure proc_valid
	is
	begin
		dbms_output.put_line('Fine');
	end proc_valid;
end;
/

show err;
SQL> @"H:\Raghu\INDEX\cc.sql"

Package created.

No errors.

Package body created.

No errors.
SQL>
I tried enabling conditioned block, but I'm not understanding how to do that
SQL> alter package r_dummy_pkg compile plsql_ccflags='rgh_cc:true';

Warning: Package altered with compilation errors.

SQL> show err
ERROR:
ORA-00907: missing right parenthesis


SQL> alter package r_dummy_pkg compile body plsql_ccflags='rgh_cc:true';

Warning: Package Body altered with compilation errors.

SQL> show err
ERROR:
ORA-00907: missing right parenthesis
Is something wrong with the alter statement I issued? How to make that part of code compiled?
This post has been answered by Solomon Yakobson on Feb 14 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 13 2012
Added on Feb 14 2012
1 comment
416 views