You Asked
Hi Tom,
I am getting error during the data load in the table.The requirement is before loading the data into the table,sal column should get multiply with the variable var.Please find the below steps which i am doing as follow:
1)Below is the table creation query:
create table emp_test_temp
(
empno number,
ename varchar2(30),
job varchar2(30),
sal number,
comm number
);
2)Below are the record in Datafile i.e employee.txt:
100,Thomas,Sales,5000,300
200,Jason,Technology,5500,500
300,Mayla,Technology,7000,100
400,Nisha,Marketing,9500,100
amit,Randy,Technology,6000,800
501,Ritu,Accounting,5400,900
3)Below is code which is written in the batch file i.e. test.bat for control file and sql loader command:
@ECHO ON
SET /p val=
echo load data >emp_test_input.ctl
echo infile 'E:\employee.txt' >>emp_test_input.ctl
echo truncate >>emp_test_input.ctl
echo into table emp_test_temp >>emp_test_input.ctl
echo fields terminated by "," >>emp_test_input.ctl
echo ( >>emp_test_input.ctl
echo empno, >>emp_test_input.ctl
echo ename, >>emp_test_input.ctl
echo job, >>emp_test_input.ctl
echo sal "to_number(:sal*val)", >>emp_test_input.ctl
echo comm "to_number(:sal+:comm)">>emp_test_input.ctl
echo )
sqlldr userid=amit/amit control=emp_test_input.ctl
When i am running the batch script then i am getting the following error:
E:\>test1.bat
2
)
sql loader will load the data
SQL*Loader: Release 11.2.0.2.0 - Production on Wed Apr 13 16:11:24 2016
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
SQL*Loader-350: Syntax error at line 11.
Expecting "," or ")", found end of file.
Please do the needful as earliest.
Thanks in advance.
and Connor said...
Two things
1) Your last echo needs to redirect to the file
2) When I run your batch file, the resulting ctl file is:
load data
infile 'c:\temp\employee.txt'
truncate
into table emp_test_temp
fields terminated by ","
(
empno,
ename,
job,
sal "to_number(:sal*val)",
comm "to_number(:sal+:comm)"
)
so you can see the "val" has not been replaced properly.
Try this instead for that line in the batch file:
echo sal "to_number(:sal*%val%)", >>c:\temp\emp_test_input.ctl
Rating
(1 rating)
Is this answer out of date? If it is, please let us know via a Comment