1

I am uploading the data with SQL Loader, in the file.txt file I have 3 fields and I want to load the field UPLOAD_DATE with sysdate and FILE_NAME with 'archivo.txt'

I tried to do something like this with SQL Loader, for example:

UPLOAD_DATE DATE TERMINATED BY "|" sysdate,
FILE_NAME CHAR(200) TERMINATED BY "|" "archivo.txt"

but this does not work, there is another way to load this information

Error

SQL*Loader-350: Syntax error at line 14.
Expecting "," or ")", found keyword sysdate.
UPLOAD_DATE DATE TERMINATED BY "|" SYSDATE,

ControlFile.ctl

OPTIONS (SILENT=(ALL, HEADER))
load data
infile file.txt
badfile file.bad
discardfile file.dis
append
into table TABLE_INFO
fields terminated by '|'
TRAILING NULLCOLS (
  SUB_ID INTEGER EXTERNAL TERMINATED BY "|",
  SUB_PROPERTY CHAR(4000) TERMINATED BY "|",
  MODIFY_TIME DATE TERMINATED BY "|" "to_date(:MODIFY_TIME, 'MM/DD/YYYY HH:MI:SS PM')",
  UPLOAD_DATE DATE TERMINATED BY "|" "to_date(:UPLOAD_DATE, 'MM/DD/YYYY HH:MI:SS PM')",
  FILE_NAME CHAR(200) TERMINATED BY "|"
)

Table

create table TABLE_INFO
(
  sub_id       NUMBER(20) not null,
  sub_property VARCHAR2(4000),
  modify_time  DATE,
  upload_date  DATE,
  file_name    VARCHAR2(200)
)

file.txt

11|campo2|09/13/2017 11:36:11 PM
12|campo1|09/22/2017 02:41:38 PM
sqlldr userbd/passbd control=ControlFile.ctl log=log_file.log rows=10000 direct=true
4
  • 2
    What does, "this does not work" mean? Please post errors Commented Nov 24, 2020 at 21:46
  • @OldProgrammer Errors ``` SQL*Loader-350: Syntax error at line 14. Expecting "," or ")", found keyword sysdate. UPLOAD_DATE DATE TERMINATED BY "|" SYSDATE, ``` Commented Nov 24, 2020 at 22:09
  • What are you expecting the terminated by clause to do when you're supplying a value from the control file - when there is no field in the data file to be terminated? And is there a reason you're specifying it again for each field anyway, when you've set it as the default fields setting? Commented Nov 24, 2020 at 23:02
  • @AlexPoole How should I configure the control file? Commented Nov 25, 2020 at 0:26

1 Answer 1

2

You have already used the trailing null cols, you can now use the constant value as follows:

UPLOAD_DATE DATE sysdate,
FILE_NAME constant "archivo.txt"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.