Home » SQL & PL/SQL » SQL & PL/SQL » Calling function in a procedure (Oracle 9i)
Calling function in a procedure [message #313266] Fri, 11 April 2008 05:03 Go to next message
virmahi
Messages: 266
Registered: April 2008
Location: India
Senior Member
Hi,
I am new to oracle.
Please let me know how to call a function in a procedure. I know calling procedure within procedure just by giving the procedure name along with arguement values.

I have a function that will take values from the procedure and will return a numeric value to a variable defined in the procedure.
CREATE OR REPLACE PROCEDURE proc1(p_tab IN VARCHAR2, p_col IN VARCHAR2) IS
BEGIN
p_tab VARCHAR2(50):= 'employee';
p_col VARCHAR2(50):= 'sal';
retval := CALL FUNCTION fun(p_tab, p_col);--PLEASE CORRECT THIS.
END proc1;


I have to pass two values to the function fun and get its value in retval for further calculation in procedure.
The above code is only a pseudocode, please correct the calling function statement in the above procedure.

Thanks,
Mahi

[Updated on: Fri, 11 April 2008 05:05]

Report message to a moderator

Re: Calling function in a procedure [message #313271 is a reply to message #313266] Fri, 11 April 2008 05:07 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
OK, forget about your custom function for a moment. How would you populate a variable with the return from a 'normal' function i.e. an Oracle supplied function (say Length or Instr)
Re: Calling function in a procedure [message #313275 is a reply to message #313266] Fri, 11 April 2008 05:15 Go to previous messageGo to next message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
Why don't you study some basics before posting it on the forum.

I think this is just a simple thing you can easily find on net.

Have you used google for it??


retval := CALL FUNCTION fun(p_tab, p_col);--Please use Google
Re: Calling function in a procedure [message #313276 is a reply to message #313271] Fri, 11 April 2008 05:16 Go to previous messageGo to next message
virmahi
Messages: 266
Registered: April 2008
Location: India
Senior Member
anyvar := functionname(arg1,arg2);

Is this correct?
Re: Calling function in a procedure [message #313277 is a reply to message #313276] Fri, 11 April 2008 05:20 Go to previous message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Perfect! Now just apply that to your custom function call. Show us your code.

[Updated on: Fri, 11 April 2008 05:21]

Report message to a moderator

Previous Topic: Get last 5 dates
Next Topic: Compiling all Views Using a Job
Goto Forum:
  


Current Time: Mon Dec 05 21:09:42 CST 2016

Total time taken to generate the page: 0.10667 seconds