what is mean by forward declaration and where we'll use it.

Answers were Sorted based on User's Feedback



what is mean by forward declaration and where we'll use it...

Answer / venkat

A forward declaration looks like the package definition
part but is inside the bode.

e.g.

procedure A is
begin
B;
end A;

procedure B is
begin
null;
end B;

will not work, because during call to B B is still unknown
(1 Step compiler) therefore we need a forward declaration:

procedure B;

procedure A is
begin
B;
end A;

procedure B is
begin
null;
end B;


now we can compile

Is This Answer Correct ?    30 Yes 2 No

what is mean by forward declaration and where we'll use it...

Answer / 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

what is mean by forward declaration and where we'll use it...

Answer / 6/8/07

Forward declaration is used in declaring subprograms that
can be used in packages.

eg: procedure query_emp(empno number,empname varchar);
--procedure is declared.
we should define the procedure next..

the basic idea is :declaration first and definition later.

Is This Answer Correct ?    8 Yes 1 No

what is mean by forward declaration and where we'll use it...

Answer / suresh somayajula

Procedure which allows for Special Sub-program declaration
is nothingbut " Forward Declaration".

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What are the operators used in select statements?

0 Answers  


Can function return multiple values in sql?

0 Answers  


what is index? : Sql dba

0 Answers  


What is RAC in oracle?

7 Answers   MCN Solutions,


Name Salary Abc 50000 Abc 50000 xyz 20000 find the max salary using aggregate function?

2 Answers   CTS,






Any attempt to navigate programmatically to disabled form in a call_form stack is allowed?

0 Answers  


How do you sort in sql?

0 Answers  


What is aggregate function in sql?

0 Answers  


how can I make a script that can be bi-language (supports english, german)? : Sql dba

0 Answers  


What is set serveroutput on?

0 Answers  


in sql table follw columns r their vehicle_no|servicetype|date|location| 1234 |1FS |1-JAN|PUNE| 4561 |2FS |5-JAN|PUNE| 1234 |PS |7-JAN|PUNE| 1234 |PS |15-JAN|MUMB| i want o/p below vehicleno|1fs|1fsdate|1fslocation|1ps|1PSDATE|1PSLOC|2PS|2PS DATE|2PSLOCA e.g 1234|1FS|1JAN|PUNE|1PS|7JAN|PUNE|2PS|15JAN|MUMBAI PLS help me out to execute using sql query

1 Answers  


I want to know last five transactions or records from emp table, from now?

11 Answers   Wells Fargo,


Categories