can we call a procedure from a function?
Answers were Sorted based on User's Feedback
Answer / karan
ya it is possible.we could call any sub program in another
sub program.
| Is This Answer Correct ? | 27 Yes | 8 No |
Answer / vivek nagarajan
It is possible to call a function from a procedure.
| Is This Answer Correct ? | 17 Yes | 3 No |
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 |
Answer / yaswanth
Procedures cannot be called from functions where functions can be called from procedures.
| Is This Answer Correct ? | 7 Yes | 1 No |
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 |
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 |
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 |
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 |
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 |
when normalization is required
What are the two parts of a procedure ?
can we use out parameter in a function?Give an example.
What are the advantages of sql? Explain
write a query to remove null following table are id name 101 dinesh null jyothi null bharathi 102 suresh null shilpha 103 prakesh null suma i want the output format like id name 101 dinesh 102 suresh 103 prakesh
What action do you have to perform before retrieving data from the next result set of a stored procedure ?
What are local and global variables and their differences?
what is transaction? : Sql dba
What is sql*loader and what is it used for?
What is data type in database?
Any attempt to navigate programmatically to disabled form in a call_form stack is allowed?
What is the difference between the implicit and explicit cursors?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)