what is mean by forward declaration and where we'll use it.
Answer Posted / guru
Forward Declaration means.. If you are defining a package
body having two procedures , If u want to use second
procedure in the definition of first procedure.. You have to
declare the second package with its arguments (if have)
before using in the definition of first procedure. It’s
labeled as forward declaration
OR
EX1:
DECLARE
PROCEDURE P1 IS
BEGIN
dbms_output.put_line('From procedure p1');
p2;
END P1;
PROCEDURE P2 IS
BEGIN
dbms_output.put_line('From procedure p2');
p3;
END P2;
PROCEDURE P3 IS
BEGIN
dbms_output.put_line('From procedure p3');
END P3;
BEGIN
p1;
END;
Output:
p2;
*
ERROR at line 5:
ORA-06550: line 5, column 1:
PLS-00313: 'P2' not declared in this scope
ORA-06550: line 5, column 1:
PL/SQL: Statement ignored
ORA-06550: line 10, column 1:
PLS-00313: 'P3' not declared in this scope
ORA-06550: line 10, column 1:
PL/SQL: Statement ignored
Ex2:
DECLARE
PROCEDURE P2; -- forward declaration
PROCEDURE P3;
PROCEDURE P1 IS
BEGIN
dbms_output.put_line('From procedure p1');
p2;
END P1;
PROCEDURE P2 IS
BEGIN
dbms_output.put_line('From procedure p2');
p3;
END P2;
PROCEDURE P3 IS
BEGIN
dbms_output.put_line('From procedure p3');
END P3;
BEGIN
p1;
END;
Output:
From procedure p1
From procedure p2
From procedure p3
Thanks
Guru
| Is This Answer Correct ? | 22 Yes | 1 No |
Post New Answer View All Answers
how to get @@error and @@rowcount at the same time? : Sql dba
What is difference between sql and oracle?
what is myisam? : Sql dba
what is the difference between ereg_replace() and eregi_replace()? : Sql dba
name 3 ways to get an accurate count of the number of records in a table? : Sql dba
How do I find duplicates in two columns?
Why are aggregate functions called so?
How does sql*loader handles newline characters in a record? : aql loader
difference between anonymous blocks and sub-programs.
what are the types of join and explain each? : Sql dba
What is anonymous block in sql?
What are local and global variables and their differences?
What are the usages of sql?
Can 2 queries be executed simultaneously in a distributed database system?
How to fetch values from testtable1 that are not in testtable2 without using not keyword?