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:  Writing Pl/SQL function

Answer: Write a PL/SQL fuction named say TRUN, which does the same work as the oracle predefined function "TRUNCATE".


July 07, 2008 01:01:14 #1
 sgbang   Member Since: July 2008    Total Comments: 2 

RE: Writing Pl/SQL function
 
Hi,

Please check out this function:

create or replace function trun(p_table_name varchar2) return number as
begin
execute immediate ' truncate table '|| p_table_name;
return 0 ;
end;
 /

How to execute example:


declare
return_int number;
begin
return_int:=trun('emp');                                      --emp is a dummy table i used
dbms_output.put_line('return is :'||return_int);  --return_int should return 0
end;
/

Hope this is helpful
     

 

Back To Question