can we call a procedure from a function?

Answers were Sorted based on User's Feedback



can we call a procedure from a function?..

Answer / karan

ya it is possible.we could call any sub program in another
sub program.

Is This Answer Correct ?    27 Yes 8 No

can we call a procedure from a function?..

Answer / vivek nagarajan

It is possible to call a function from a procedure.

Is This Answer Correct ?    17 Yes 3 No

can we call a procedure from a function?..

Answer / rat

Yes i am aggree with all three answers but there are
diffrent Scenarios.

you can not call a procedure in which dml ,ddl statement or
transaction controling statement is used.

you can all a procedure in which only select statement is
used.

please chekc if you dont have trust.

Is This Answer Correct ?    14 Yes 2 No

can we call a procedure from a function?..

Answer / yaswanth

Procedures cannot be called from functions where functions can be called from procedures.

Is This Answer Correct ?    7 Yes 1 No

can we call a procedure from a function?..

Answer / rakesh

Surely we can call.
if the procedure is using dml,then mark that procedure as
PRAGMA AUTONOMOUS_TRANSACTION.

then use that procedure in function.

Is This Answer Correct ?    5 Yes 2 No

can we call a procedure from a function?..

Answer / karthi

it is possible to call a function from Procedure but its
not possible to call a Procedure from a function..

Is This Answer Correct ?    7 Yes 6 No

can we call a procedure from a function?..

Answer / abhishekjaiswal

DECLARE
  FUNCTION my_func RETURN NUMBER IS
  BEGIN
    RETURN 2;
  END my_func;




  PROCEDURE my_proc IS
  BEGIN
    DBMS_OUTPUT.PUT_LINE(my_func + 1);
  END my_proc;




BEGIN  -- main
  my_proc;
END;    -- main
As shown above, with the function declared first you can call the function from the procedure. However, if you try something like the following (function declared before procedure, and function calls procedure):




DECLARE
  FUNCTION my_func RETURN NUMBER IS
  BEGIN
    my_proc;
    RETURN 2;
  END my_func;




  PROCEDURE my_proc IS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('22');
  END my_proc;




BEGIN  -- main
  DBMS_OUTPUT.PUT_LINE(my_func);
END;    -- main
the compile will fail, because my_func cannot 'see' my_proc. To make it work you need to put in a 'prototype' declaration of my_proc, as follows:




DECLARE
  PROCEDURE my_proc;




  FUNCTION my_func RETURN NUMBER IS
  BEGIN
    my_proc;
    RETURN 2;
  END my_func;




  PROCEDURE my_proc IS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('22');
  END my_proc;




BEGIN  -- main
  DBMS_OUTPUT.PUT_LINE(my_func);
END;    -- main

Is This Answer Correct ?    0 Yes 0 No

can we call a procedure from a function?..

Answer / rohini g

It is possible to call a function from Procedure but its
not possible to call a Procedure from a function..

Is This Answer Correct ?    0 Yes 1 No

can we call a procedure from a function?..

Answer / alok mbbs

I disagree with Karan and Vivek , i guess they are moving
away from the path .... answer is not upto the mark reason
being :::


Function cannot change the value in table.

Anyone disagree call me @

02267802321
i will explain in detail .....

Any appreciations call me for that

Is This Answer Correct ?    5 Yes 10 No

Post New Answer

More SQL PLSQL Interview Questions

full outer join syntax

5 Answers  


Why do we use triggers?

0 Answers  


2. Select A.A from ( select 1 as from dual Union select 1 as from dual)A Full outer join ( select 1 B from dual Union select 2 B from dual)B On A.A=B.B

2 Answers   Fintellix,


Can a commit statement be executed as part of a trigger?

0 Answers  


How many types of cursors supported in pl/sql?

0 Answers  






How to call a javascript function from pl sql?

0 Answers  


How can get second highest salary in sql?

0 Answers  


How do I run pl sql in sql developer?

0 Answers  


a. Can you delete data from a View. b. If Yes, can you delete it if there are multiple tables c. If No, can you delete if there is single source table which is joining.

4 Answers   CGI, IBM,


what is myisam? : Sql dba

0 Answers  


What is TABLE SPACE?

4 Answers   ABB, TCS,


how view used for security purposes?

3 Answers   Glam India,


Categories