I seem to be having an issue whenever I add the preprocessor clause into my external tables statement. Without the preprocessor line it all works fine but as soon as I add it I get assorted errors depending on where I put it in the access parameters block, do they have to be in a particular order? I can't find any similar issues online.
Edit: Also as a side note, I know you can use preprocessor to feed in a zipped file to the external table. If I want to read a zipped file AND append the filename is it as easy as just putting it all in the one shell file?
CREATE TABLE (
column1 VARCHAR2(40),
column2 VARCHAR2(40)
)
ORGANIZATION EXTERNAL
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY DMPDIR
ACCESS PARAMETERS(
RECORDS DELIMITED BY NEWLINE
LOGFILE DMPDIR:'test.log'
BADFILE DMPDIR:'test.bad'
fields terminated by '^'
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
preprocessor DMPDIR: 'append_filename.sh'
)
LOCATION (DMPDIR: 'testfile.dat')
);
append_filename.sh
#!/bin/bash
sed -e 's!$!,'"${1##*/}"'!' $1