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
What is the example of procedure?
What is meant by truncate in sql?
What is a table partition?
What is trigger price?
How do you know if a relationship is 2nf?
What is an exception in pl/sql?
What is trigger and stored procedure in sql?
Is pl sql better than sql?
What is on delete set null?
Explain normalization and what are the advantages of it?
What is primary key and unique key?
How can you maintain the integrity of your database on instances where deleting an element in a table result in the deletion of the element(s) within another table?
What sql does db2 use?
How consistent is the view of the data between and within multiple sessions, transactions or statements ?
i have some prob lem to tell me about my self in interview first round ...