Hello Chris/Connor,
I am sure I am missing something obvious but can't seem to figure it out.
How to capture and store file name, along with its contents when file name is dynamic?
Borrowing an example from MOS note 549856.1:
- XML documents to be loaded::
doc1.xml contains: <planet>venus</planet>
doc2.xml contains: <planet>mercury</planet>
- Table specifications:
create table planets
(pl_id number(4), pl_name varchar2(20), xml_doc SYS.XMLTYPE);
SQL*Loader control file called load_xml.ctl contains:
LOAD DATA
INFILE *
INTO TABLE planets
REPLACE
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
(pl_id,
pl_name,
fname FILLER CHAR,
xml_doc LOBFILE(fname) TERMINATED BY EOF
)
BEGINDATA
1,Mercury,doc1.xml
2,Venus,doc2.xml
Run SQL*Loader using the controlfile:
sqlldr scott/tiger control=load_xml.ctl
Results seen in table planets:
PL_ID PL_NAME XML_DOC
---------- -------------------- ----------------------------------------
1 Mercury <planet>venus</planet>
2 Venus <planet>mercury</planet>
In the above example, how can I capture the file names (doc1.xml and doc2.xml) in order to populate them in a column of the table (say in pl_name in this example)
Thanks in advance