Skip to Main Content
  • Questions
  • SQL*Loader-350: Syntax error When Clause syntax failure

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question.

Asked: March 19, 2021 - 3:56 am UTC

Last updated: March 24, 2021 - 9:04 am UTC

Version: 12.1.0.2.0

Viewed 10K+ times! This question is

You Asked

Hi,

I have browsed few websites but could not find solution to problem though it looks silly.

Error SQL*Loader-350: Syntax error is thrown while sqlldr command is run from a shell script. All the columns are of fixed length and each record in flat file has 204 characters.

1. I have a shell script that call sqlldr. below is the command in script
$SQLLDR USERID=usernm/passwd@instancenm CONTROL=filename.ctl DATA=DATAFILE 

2. Below is the control file content
LOAD DATA
APPEND
INTO TABLE SDITBL
WHEH src_code = 'S'
(
 batch_num "session_number.nextval",
 seq_num "tech_key.nextval",
 lvl_number POSITION(1:18) char,
 xref_from POSITION(<b>30:34</b>) char,
 xref_to POSITION(<b>35:39</b>) char,
 src_code POSITION(29:29) char,
 name_full POSITION(40:74) char,
 quantity POSITION(75:81) char,
 date_created POSITION(82:89) date "YYYYMMDD",
 og_lvl_number POSITION(90:97) char,
 pmg_number POSITION(198:204) char
) 
WHEH src_code = 'D'
(
 batch_num "session_number.nextval",
 seq_num "tech_key.nextval",
 lvl_number POSITION(1:18) char,
 xref_from POSITION(<b>19:23</b>) char,
 xref_to POSITION(<b>24:28</b>) char,
 src_code POSITION(29:29) char,
 name_full POSITION(40:74) char,
 quantity POSITION(75:81) char,
 date_created POSITION(82:89) date "YYYYMMDD",
 og_lvl_number POSITION(90:97) char,
 pmg_number POSITION(198:204) char
) 


sample line below from input flat file
1006356                     S     441  Inter Test1                        4      20210611441                                                                                                                


Please let me know where I am going wrong.

Imran

and Chris said...

You need to put

INTO TABLE ...

Before each WHEN clause. While you're doing this, check the spelling of the keywords carefully.

Also: I'm assuming the B tags are a formatting issue not present in your source file.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Resolved!!

A reader, March 24, 2021 - 4:35 am UTC

Thank you Chris.

Yes issue is resolved and the B tags were added to highlight them not part of the script though.

Thanks again for all the support.
Chris Saxon
March 24, 2021 - 9:04 am UTC

Glad we could help