! ! Copyright 1998, Ray Ontko and Co, Richmond, IN, US. ! ! This file may only be used and distributed under the ! terms of the GNU General Public License. See COPYING.TXT ! included with this file for specific terms of the license. ! !++ ! ! Name ! ! csv_export.sqr ! ! Description ! ! This is a sample program which extracts data from a database table ! and write it to a comma-separated, variable-length (.csv) file. ! This program is intended as a template; modify to suit your needs. ! !-- ! ! Author ! ! Ray Ontko ! Ray Ontko & Co ! rayo@ontko.com ! ! Modification History ! ! Name Date Comment ! ---------------- ---------- ---------------------------------------- ! Ray Ontko 1998/06/27 Created ! #include 'csv.sqh' #define OUT_FILE 1 #define OUT_MAX 500 begin-program do main end-program begin-procedure main input $out_name 'Output .CSV file' open $out_name as {OUT_FILE} for-writing record={OUT_MAX}:vary status=#status if #status show 'error: unable to open "' $out_name '" for output' stop quiet end-if begin-select empno &empno ename &ename sal &sal do csv_set_number( &empno , '888888888' , $line ) do csv_add_string( &ename , $line ) do csv_add_number( &sal , '8888888.88' , $line ) write {OUT_FILE} from $line from emp order by empno end-select close {OUT_FILE} end-procedure ! main