I am importing text file through SQL*Loader into an Oracle table but i don't want to give the specific name of the file, I want to import only the .txt file extensions file. look the below code :
create or replace
PROCEDURE EXT_TABLE
AS
A1 NUMBER ;
L_QUERY VARCHAR2(1000) := NULL;
L_DROP VARCHAR2(10000) := NULL;
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE IMPORT_TEST
( EMP_ID NUMBER (10)
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY IMPORT
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY '',''
MISSING FIELD VALUES ARE NULL
)
LOCATION ('file with .txt extension')
)reject limit unlimited';
L_QUERY:= 'INSERT INTO MPRN SELECT * FROM IMPORT_TEST';
EXECUTE IMMEDIATE L_QUERY;
L_DROP := 'drop table IMPORT_TEST ';
execute immediate L_DROP;
--execute immediate 'DROP IMPORT_TEST';
commit;
END EXT_TABLE;
At the location, LOCATION ('file with .txt extension')
, I don't want to give the name of the file as in the directory only one txt file is there. I don't want to use the IN
parameter. I want to search from the directory only. The user will run the procedure and it will import the txt file automatically without selecting manually.