Friday, May 22, 2009

Getting the Source Code from database using Query

-- ---------------------------------------------------------------------------------
-- Purpose : Get the Source Code from database without junck characters using Query
-- Date      : 22.May.2009
-- Created by : Chaitanya
-- .....
-- ----------------------------------------------------------------------------------


SELECT
decode(rownum ,1,'CREATE OR REPLACE '||rTRIM(rTRIM(t.text,CHR(10))),rTRIM(rTRIM(t.text,CHR(10)))) text
from dba_source t
Where type = 'PACKAGE BODY'
and name = &Package_name



-- ---------------------------------------------------------------------------------
-- Purpose : Anonoumos block to Get the Source Code from database
-- Date : 22.May.2009
-- Created by : Chaitanya
-- .....
-- ----------------------------------------------------------------------------------


DECLARE
x varchar2(200);
n number;
cursor c_rec is
select text,line,name,type from all_source
where name = &Package_name
and type like 'PACKAGE';
begin
dbms_output.put_line('================================================ ');
dbms_output.put_line('============ Package Specifications============= ');
dbms_output.put_line('================================================ ');
dbms_output.put_line(' ');
for c in c_rec
loop
n:= c.line;
select rtrim(ltrim(text,chr(10)),chr(10))
into x
from all_source
where name = c.name
and type = c.type
--and type <> 'PACKAGE'
and line = c.line;
dbms_output.put_line(x);
end loop;
exception
when others then
dbms_output.put_line('Error at '|| n || ' '|| 'line, ' || sqlerrm);
end;

-- ---------------------------------------------------------------------------------

1 comment:

Anonymous said...

Vint Ceramic Art | TITNIA & TECHNOLOGY
Explore an all new “Vint jancasino Ceramic deccasino Art” project https://septcasino.com/review/merit-casino/ on TITNIA & TECHNOLOGY. Our team of sculptors and artists have created new titanium ring and wooricasinos.info