GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Oracle  >  PL/SQL

 Print  |  
Question:  Package Function

Answer: You have a package called A and one function in that packgae called XYZ.
If you need to call that function in second packaged B, How will you call?


March 03, 2009 15:33:08 #1
 ananth.oracle   Member Since: March 2009    Total Comments: 3 

RE: Package Function
 
Yes, we can call a packaged function in another package.

Example
CREATE OR REPLACE package VISION_SURGERY.test_a isfunction call_func(enter_date date) return varchar2;


end;

/


CREATE OR REPLACE package body VISION_SURGERY.test_a is

function call_func(enter_date in date) return varchar2 is

v_date
varchar2(100);



begin

v_date:=to_char(enter_date,'Ddspth-Month-Year');

return
v_date;

end;

end;

/
Package A is created

create or replace package test_b isprocedure

call_func_a;

end;

/

create or replace package body test_b is

procedure call_func_a is


v_date date;

v_date_mod varchar2(100);


begin

v_date := to_date('10/03/2009','dd/mm/yyyy');

v_date_mod:=test_a.call_func(v_date);


dbms_output.put_line('Date before modificaion is : '|| v_date);

dbms_output.put_line
('Date after modificaion is : '|| v_date_mod);


end;

end;

/

Now execute the packaged procedure by
exec test_b.CALL_FUNC_A

     

 

Back To Question