xml - Oracle - Automate Export/Unload of Data -


oracle sql developer has option export contents of query result various formats (csv/fixed width/excel/xml). there way automate it?

if not, free tools available let me automate exports same formats sql developer capable of exporting to?

i don't know of way automate sql developer exports, no.

however, it's easy enough generate csv and/or fixed width files pl/sql (using utl_file package). tom kyte has example of programs generate csv or fixed width files using either pl/sql or pro*c. either can relatively automated using favorite scheduler.

xml outputs can automated in same way depending on how control need on xml generated. if need valid xml , don't care format of xml, can using dbms_xmlgen package (this example straight documentation).

declare   qryctx dbms_xmlgen.ctxhandle;   result clob; begin   qryctx := dbms_xmlgen.newcontext('select * hr.employees');   -- set row header employee   dbms_xmlgen.setrowtag(qryctx, 'employee');   -- result   result := dbms_xmlgen.getxml(qryctx);   insert temp_clob_tab values(result);   --close context   dbms_xmlgen.closecontext(qryctx); end; / 

you write result clob file using utl_file and, again, use favorite scheduler schedule it.

if need generate file excel can open, need create csv or tab-delimited file. excel can open either type of file relatively though step of being prompted accept delimiter found (it detects delimiter correctly).

generating native excel output bit more challenging. there pl/sql apis generating excel files such jason bennett's exceldoctypeutils. i've gone java stored procedure used either jexcelapi or apache poi generate excel file. this, obviously, requires bit more work implement. once have stored procedure can write excel file, other options, can automate calling procedure using favorite scheduler.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -