Skip to main content

Posts

Showing posts with the label Oracle simple function to create CSV.

Oracle simple function to create CSV.

This PL/SQL code function will quickly help to write CSV without having to code a single line. Just change the query argument to function. One will need a writable directory as a  utl_file_dir parameter from init.ora or pfile , or a stored directory object. Make sure you have read access to operating system directory you are supplying else it does not make much sense to run a program at all. You can create a database object as well just copy and replace function definition with create or replace function. --alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'; DECLARE cnt number ; function dump_csv( p_query in varchar2, p_separator in varchar2 default ',' , p_dir in varchar2 default '/non_edi_data', p_filename in varchar2 default 'temp1.csv' , qualify_with_quotes in boolean...