Hi
I need to pick some brains on exporting to a csv file.
As part of an automated routine, I need to be able to create a CSV file that contains not only my extracted data but also some file format rules to allow it to be uploaded by a process on a customers system.
The code I have is set echo offset verify offset termout onset heading offset pages 50000set feedback offset newpage noneset linesize 160 column dcol new_value myFile noprintSELECT DISTINCT PALLETS.FFSPORRECNO dcolfrom CUKLIVE.PALLETS, cloudspace1.PO_PALLETS@cukcloud,cuklive.itestowhere PALLETS.FFSPORRECNO = PO_PALLETS.PO_NUMBERand PALLETS.FFSPORRECNO = ITESTO.ISTPONOAND ITESTO.ISTSTKLOC = 2081AND PO_PALLETS.PROCESSED =‘Y’ AND PALLETS.FFSPORRECNO=88333;spool h:&myFile-Pallet.csv SELECT ‘#PO’||&myFile from dual;SELECT ‘TYP:RCV’ from dual;SELECT rtrim(nvl(PALLETS.SSCCPALNO,PALLETS.STOREPALNO))||’,’||’,’||PALLETS.QUANTITYfrom CUKLIVE.PALLETS, cloudspace1.PO_PALLETS@cukcloud,cuklive.itestowhere PALLETS.FFSPORRECNO = PO_PALLETS.PO_NUMBERand PALLETS.FFSPORRECNO = ITESTO.ISTPONOAND ITESTO.ISTSTKLOC = 2081AND PO_PALLETS.PROCESSED =‘Y’ AND PALLETS.FFSPORRECNO=88333;spool off;exit;
The header lines ‘#PO’ & ‘TYP:RCV’ must go at the top of each file before the data extracted in the select statement.
Also each file needs to have a unique referance number define by the value &myFile in the line spool h:&myFile-Pallet.csv
The value extracted by the line PALLETS.FFSPORRECNO=88333
change on each run of the automation script.
When I try and run this in toad for data analysts it error due to &myFile being a bind variable.
Does anyone have any ideas on how I can get this to run, or even an alternative solution.
Thanks in advance
Dave