set head off
set newp none
set recsep off
set echo off
set serveroutput off
set tab off
set line 500
set wrap off
set feedback off
set verify off

SELECT  'OPTIONS(DIRECT=TRUE,ROWS=1000000) LOAD DATA TRUNCATE INTO TABLE ' || upper('A2_&1') ||
        ' FIELDS TERMINATED BY ''\t''' ||
        ' TRAILING NULLCOLS (' || Listagg(Column_Name ||
          Decode(Data_Type, 'VARCHAR2', ' CHAR(' || data_length || ')', 'DATE', ' DATE "YYYY-MM-DD HH24:MI:SS"' ), ',') WITHIN GROUP (ORDER BY column_id) || ')'
FROM user_tab_columns WHERE table_name=upper('A2_&1');

quit;

set head off
set newp none
set recsep off
set echo off
set serveroutput off
set tab off
set line 500
set wrap off
set feedback off
set verify off

SELECT  'OPTIONS(DIRECT=TRUE,ROWS=1000000) LOAD DATA TRUNCATE INTO TABLE ' || upper('A2_&1') ||
        ' FIELDS TERMINATED BY ''\t''' ||
        ' TRAILING NULLCOLS (' || WM_CONCAT(Column_Name ||
          Decode(Data_Type, 'VARCHAR2', ' CHAR(' || data_length || ')', 'DATE', ' DATE "YYYY-MM-DD HH24:MI:SS"' )) || ')'
FROM user_tab_columns WHERE table_name=upper('A2_&1');

quit;

Use WM_CONCAT - exists in Oracle < 11.2
Use WM_CONCAT - exists in Oracle < 11.2

git-svn-id: 410459702e6123a874d92574e1336b0959d85891@13526 2913f559-6b04-0410-9a09-c530ee9f5186
