Omit characters in sql loader control file
How can I omit the characters "-" and "?" in the following control file without altering BEGINDATA part?
LOAD DATA
INTO TABLE CUSTOMER
FILEDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(CUST_ID,
CUST_FIRST,
CUST_LAST,
CUST_ADD,
ORDER_DATE
BEGINDATA
3948,ANDREW,WILLIS,-,?10/10/2005?
4520,MARY,PHILIPS,-,?12/10/2005?
Try this one:
LOAD DATA
INTO TABLE CUSTOMER
FILEDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(CUST_ID,
CUST_FIRST,
CUST_LAST,
CUST_ADD "TRIM('-' FROM :CUST_ADD)",
ORDER_DATE "TRIM('?' FROM :ORDER_DATE)"
BEGINDATA
3948,ANDREW,WILLIS,-,?10/10/2005?
4520,MARY,PHILIPS,-,?12/10/2005?
or
LOAD DATA
INTO TABLE CUSTOMER
FILEDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '?'
(CUST_ID,
CUST_FIRST,
CUST_LAST,
CUST_ADD "TRIM('-' FROM :CUST_ADD)",
ORDER_DATE
BEGINDATA
3948,ANDREW,WILLIS,-,?10/10/2005?
4520,MARY,PHILIPS,-,?12/10/2005?
Daniel Enchev
Similar Messages
-
Parameters / Variables in SQL Loader Control File
Here's my problem, I have created SQL Loader control file (ctl) to load a file of employees. This loader program is registered in Oracle Applications. What I want is to pass a parameter derived from the profile like the user name of the one who executed the loader program and pass it to the loader program so that the user name info is included in the loading
example
input data
123456,John,Smith
654321,Jane,Doe
loaded data
123456,John,Smith,03-JUL-2009,USER13
654321,Jane,Doe,03-JUL-2009,USER13
the sysdate is easy because it can be defined in the column but what I really want to achieve is a parameter passed to the ctl file.
Thanks in advance.Dear user!
Please have a look at this thread.
{thread:id=915277}
In the last three posts I explain how to use a shellscript with AWK and SED to pass parameters to a controlfile.
Please feel free to post again if you have some questions regarding my explanatory notes.
Yours sincerely
Florian W. -
Define variable in SQL Loader Control File
Hi,
I have an input file where the first line is the header record, followed by the detail records. For the processing, I do not need to store the fields of the header record but I need a date field from this header record and store in as part of the detail record in an oracle record row.
Is it possible to define a variable within the sql loader control file to store the value that I need in memory then use it when I do the sql insert by the sql loader?
Thanks for any advice.Not sure that you can. But if your on unix/linux/mac its easy enough to write a shell script to populates the variables in a template file that you can then use as the ctl file. The perl template toolkit could be an option for that as well
-
Add "Trailing Nullcolls" to sql loader control files generated by OWB
Hi gurus,
I've got a problem loading data with SQL Loader. I need to add the parameter "trailing nullcols" into the SQL Loader control file generated by OWB. I don't want to do this by saving the skript on my hard disk and run it manually, so any ideas where I can put this parameter? I am using OWB 10.1 on a windows 2000 machine.
Thanks
StephanHi,
I found the solution to problem.
1; Select the mapping where you map your source flat file to a table.
2; Right click on the mapping and select "configure"
3; Go Sources and Targets -> YOUR_TABLE_NAME -> SQL*Loader Parameters
4; Set Trailing Nullcols = true :-)
Thank you to anyone looking at this problem.
Greetings
Stephan -
Importing already-made SQL*Loader control files in OWB 10g
Hi all,
Suppose that I have a certain amount of already hand-made SQL*Loader control files, say 50 or so.
Each of these control files have a variable quantity of fields.
I feel really lazy, so I would like to know if it is possible to import directly these control files instead of re-typing them in the design center. That would save me a lot of time.
Thanks !
BurgyHi Burgy
One option is to use the sqlloader option to generate an external table from the SQLLoader control file (search for generate_only in the sqlloader documentation). If you define the external table in the database you can reverse engineer this into OWB.
Cheers
David -
SQL Loader control file script - INFILE
Hi,
The data stored in the file "c:/test_<yyyy>_<mm>_<dd>". The <yyyy>, <mm> and <dd> has to be from sysdate. The infile gets generated on daily basis.
LOAD DATA
INFILE 'c:/test_'||to_char(sysdate,'yyyy')||'_'||to_char(sysdate,'mm')||'_'||to_char(sysdate,'dd').txt'
BADFILE 'c:/test_' || to_char(sysdate,'yyyy') || '_' || to_char(sysdate,'mm') || '_' || to_char(sysdate,'dd').bad'
I ran the above ctl from cmd prompt, it is giving an error. It is not recognizing the || symbol as concatenation.
How can I achieve this?
Thanks in advance.Thanks Hussein.
I placed the control script in GL_TOP directory in unix OS. I created an executable (for the control script) and scheduled this concurrent program.
OS :- HP Tru64 UNIX - 5.1b
Database : 9.2.0.5
Application: Oracle General Ledger (Ver 11.5.9).
The error I am getting if I run the command "sqlldr ...." from cmd prompt is:
sql*Loader: Release 8.1.7.0.0
Illegal combination of non-alphanumeric characters
INFILE 'c:/test_' || to_char(sysdate,'yyyy'.......'
Thanks again. -
SQL Loader Control File configuration
Hi,
I'm writing loader scripts for a Consulting team to use to load standard format files for customers. I want to be able to support different field separators without having to create copies of the control files for each separator variant.
e.g.
LOAD DATA
INFILE "%IMPPATH%\BaseProd.txt"
BADFILE "%IMPPATH%\BaseProd.bad"
DISCARDFILE "%IMPPATH%\\BaseProd.dsc"
INSERT INTO TABLE
IMPORT_PRODUCT
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
( PROD_CD "UPPER(:PROD_CD)",
PROD_DESCRP,
SELL_PRICE)
I'd like to be able to specify a %variable% for the FILEDS TERMINATED BY value. (The %IMPPATH% works a treat for the location of the file.)
Anyone know how to achieve this?
Thanks in advance.I have tried
SET MYSEPARATOR=,
and
FIELDS TERMINATED BY '%MYSEPARATOR%'
I then get the message in the LOG file
Column Name Position Len Term Encl Datatype
PROD_CD FIRST * O(") CHARACTER
Terminator string : '%MYSEPARATOR%'
It appears to be looking for the complete string %MYSEPARATOR% as the separator!
I have also tried
SET MYSEPARATOR=','
and
FIELDS TERMINATED BY %MYSEPARATOR%
which gives the error
SQL*Loader-350: Syntax error at line 9.
Illegal combination of non-alphanumeric characters
FIELDS TERMINATED BY %MYSEPARATOR%
^ -
SQL Loader Control file WHEN clause
LOAD DATA
REPLACE
INTO TABLE IDL_Investments
WHEN average_balance < '100.00'
FIELDS TERMINATED BY X'9'
TRAILING NULLCOLS
Borrower_Id,
Account_No,
customer_No,
cptype_id "GETID(:cptype_id)",
customer_name,
average_balance,
CP_GroupName,
CP_type,
Account_Type,
Instrument_type,
DD_date "TO_DATE(:DD_date, 'dd/mm/yy')",
fac_Maturity_date "TO_DATE(:fac_Maturity_date, 'dd/mm/yy')"
above one is the control file. when i tried to load data i waas getting the following error.
SQL*Loader-350: Syntax error at line 4.
Illegal combination of non-alphanumeric characters
WHEN average_balance < '100.00'
^
instead of '<' symbol if i place an '=' symbol then its workig fine.
So how do I use <, <=, > or >= operators in a WHEN clause of a control file can any one help me?
Thanks in advance.Thanks for the suggestion but by searching in someother sites i found that
only equality operators ('=', '!=' or '<>') are permited in the WHEN clause expressions of a control file in SQL Loader.
So now i changed my logic.
thanks anyway. -
SQL Loader Control File Recoverable Option in Oracle 9i
We are migrating from Oracle 8 to Oracle 9i. We are running some of the SQL*Loader scripts. The control file uses "OPTIONS (UNRECOVERABLE)" option, which is working fine with Orace 8 whereas it is not working in
Oracle 9i. Are these options "RECOVERABLE/UNRECOVERABLE" removed from Oracle 9i. If yes, why ? Or do we have an alternate option for the same.
Thanks in advance.
Balaji974647 wrote:
my requirement is that for the remaining 2 columns, i want to insert text 'COLUMN_DROPPED' in backend table.Rest 8 columns should be populated as usual.First of all it is only possible if remaining 2 column datatype is string (char/nchar, varchar2/nvarchar2, clob/nclob) and are at least 14 characters. The rest is easy. Just modify last 2 fields in control file:
column9 constant 'COLUMN_DROPPED',
column10 constant 'COLUMN_DROPPED'SY. -
How to use Conditional statements in SQL Loader control file
Hi,
I am using sql loader to load a flat file to the table. I am using control file for this purpose as show below:
LOAD
INTO TABLE store_shrink
TRUNCATE
FIELDS TERMINATED BY " "
TRAILING NULLCOLS
SITE_ID char,
ST_SHRINK char,
ST_REVENUE char,
SHRINK_PR char ":ST_SHRINK/:ST_REVENUE"
My question is this. If in the flat file the value of 'ST_REVENUE' is '0', then I want 'SHRINK_PR' to be '0' as well, and skip the calculation (:st_shrink/:st_revenue).
How to achieve this with the conditional statement or using any Oracle function?
Any help or suggestion is greatly appreciated.
Thanks in advance.Hi there,
I tried the following in my above query and it doesn't work somehow. Anyone has an idea? I have been on internet throughout but to no avail. Please help:
LOAD
INTO TABLE store_shrink
TRUNCATE
FIELDS TERMINATED BY " "
TRAILING NULLCOLS
SITE_ID char,
ST_SHRINK char,
ST_REVENUE char,
SHRINK_PR char "case (when :st_revenue<>'0.00' then :SHRINK_PR=:ST_SHRINK/:ST_REVENUE else :SHRINK_PR='0.00') end"
) -
Use of WHEN in SQL Loader Control File
Does anyone know of a way, using the CTL file below, to NOT LOAD (i.e. discard) any record where field G is null -OR- substr(G,1,3)='CON'+ (the first 3 characters of field G are "CON")?
The WHEN clause seems very limited in what it can test and all my attempts to use a compound condition, much less the SUBSTR function, have failed. The documentation indicates that only very simple conditions can be specified.
(Oracle 10g, Unix)
Thanks
LOAD DATA
TRUNCATE
INTO TABLE TEST_TABLE
WHEN (G <> '')
FIELDS TERMINATED BY "^"
TRAILING NULLCOLS
A ,
B FILLER,
C FILLER,
D FILLER,
E FILLER,
F FILLER,
G "LTRIM(:G,'0')",
H FILLER,
I FILLER,
J FILLER,
K SYSDATE,
L CONSTANT "SQLLDR"
)Hello MTM.
The WHEN clause in SQL*Loader, despite what you might read, doesn't seem to evaluate the value of the column you specify after SQL clauses are processed. Therefore, the only way you can guarantee to NOT LOAD a record is by using a function to raise an application error when the column data meets your criteria. You'll need to do some basic comparisons between bad data and discarded data in the bad data file to isolate these.
You can still discard the null data using (replace ne with greater and less than)WHEN (g ne '')Hope this helps,
Luke
Please mark the answer as helpful or answered if it is so. If not, provide additional details.
Always try to provide create table and insert table statements to help the forum members help you better. -
URGENT HELP ON SQL LOADER CONTROL FILE
Dear All,
Please find my control file below. I need two leading zeros for the coulmn DDA_CLEARING_NUMBER. Presently its loading 18 characters. position is (0791:0808). Now i need this to be loaded with two leading zeros to the left. I need padding two zeros in front of the 18 characters. HOW CAN I DO THAT? PLEASE HELP ME IN IT.
OPTIONS (DIRECT=FALSE,
ROWS=30000,
BINDSIZE=3000000,
READSIZE=3000000,
SKIP_UNUSABLE_INDEXES=TRUE)
LOAD DATA
INFILE '/xxx/xxx/xxx.dat'
BADFILE '/xxx/xxx/xxx.bad'
DISCARDFILE '/dev/null'
APPEND
INTO TABLE AAA
WHEN MONTH_END_STATUS = 'O'
TIME_PERIOD POSITION (0079:0086) DATE "YYYYMMDD",
SERVICE_TYPE POSITION (0077:0078) CHAR,
ACCOUNT_NUMBER POSITION (0001:0020) CHAR,
MONTH_END_STATUS POSITION (0060:0060) CHAR,
CIF_BANK POSITION (0066:0069) CHAR,
CIF_BRANCH POSITION (0070:0074) CHAR,
PLAN_CODE POSITION (0075:0076) CHAR,
DDA_CLEARING_NUMBER POSITION (0791:0808) CHAR,
TAX_ID POSITION (0516:0524) CHAR)Dear peterson,
When i do what you said, its inserting nothing. not even space. Please help me in it what to do?
thanks and regards -
Using constant values in SQL Loader control file
Hi,
I have a requirement where I need to migrate the data of 6 tables from MS Access into Oracle data base. I have written SQL Loader scripts so that I can create CSV files based on MS Access data and then migrate into Oracle. But in Oracle tables we have 4 common columns like Create_By, Created_Date,Updated_By and Update_Date, and those fields should be taken care by system. So, basically system should update login user ID and sysdate values in respective columns. My question here is, I do not have above mentioned common columns in MS Access tables. So, can I hard code those values in control file by saying
Created_By CONSTANT user,
Create_Date CONSTANT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS'),
Updated_By CONSTANT user,
Updated_Date CONSTANT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS')
Please let me know your valuable suggestions.You do it without it constant
--sample data file
1,2,,
3,4,,
LOAD DATA
INFILE 'D:\d.csv'
INTO TABLE ABC
FIELDS TERMINATED BY ","
( A,
B,
C sysdate,
D "USER"
)Edited by: J99 on Jul 23, 2009 12:14 PM
OR use to avoid extra ',' in datafile.
--sample data file
1,2
3,4
LOAD DATA
INFILE 'D:\d.csv'
INTO TABLE ABC
FIELDS TERMINATED BY "," TRAILING NULLCOLS
( A,
B,
C sysdate,
D "USER"
) -
SQL-Loader Control file for Tab-delimited fields
i want to import a text-file with TAB-DELIMITED fields and a line-break + return at the end of each record.
a want to do this by sql-loader and a control file.
please, can someone give me the statement:
e.g.
load data
infile 'exaple.txt' .......
(...field1, field2,....)
thank you very muchCase Study 3: Loading a Delimited, Free-Format File
http://otn.oracle.com/pls/db92/db92.to_URL?urlname=http:%2F%2Fdownload-west.oracle.com%2Fdocs%2Fcd%2FB10501_01%2Fserver.920%2Fa96652%2Fch10.htm%231006907
Modify the example and use 'terminated by whitespace' instead
For more information on TERMINATED Fields see
http://otn.oracle.com/pls/db92/db92.to_URL?remark=drilldown&urlname=http:%2F%2Fdownload-west.oracle.com%2Fdocs%2Fcd%2FB10501_01%2Fserver.920%2Fa96652%2Fch06.htm%231013838 -
hi,
Can one call procedures and functions inside a control file in SQL Loader ...alternatively how can one use case inside a control file ...
How to implement the the following code in a control file:
SELECT CASE
WHEN INSTR(UPPER(returnname),'SCHEDULE') > 0 THEN 'S'
WHEN INSTR(UPPER(returnname),'RETURN') > 0 THEN 'R'
WHEN INSTR(UPPER(RETURNNAME),'BREAKDOWN') > 0 THEN 'B'
ELSE returnname
END
AS returns
FROM tableexample
Please let me know ..regarding your first question :
data_file TT.dat :
SCHEDULE
RETURN
BREAKDOWN
HOLIDAY
WEEKEND
schedule
return
breakdown
holiday
weekend
control_file TT.ctl :
load data
insert
into table dummy_test
(TEXT position(01:20) char
,TEXT_b position(01:20) char " decode(upper(:TEXT),'SCHEDULE','S','RETURN','R','BREAKDOWN','B',:TEXT) "
parameter_file TT.par :
userid=user/password
DATA=TT.dat
CONTROL=TT.ctl
ERRORS=99999
load file into table :
sqlldr parfile=TT.par
log-file TT.log :
SQL*Loader: Release 8.1.6.2.0 - Production on Thu Feb 26 16:01:23 2004
(c) Copyright 1999 Oracle Corporation. All rights reserved.
Control File: TT.ctl
Data File: TT.dat
Bad File: TT.bad
Discard File: none specified
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 99999
Bind array: 64 rows, maximum of 65536 bytes
Continuation: none specified
Path used: Conventional
Table DUMMY_TEST, loaded from every logical record.
Insert option in effect for this table: INSERT
Column Name Position Len Term Encl Datatype
TEXT 1:20 20 CHARACTER
TEXT_B 1:20 20 CHARACTER
SQL string for column : " decode(upper(:TEXT),'SCHEDULE','S','RETURN','R','BREAKDOWN','B',:TEXT) "
Table DUMMY_TEST:
10 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 2816 bytes(64 rows)
Space allocated for memory besides bind array: 0 bytes
Total logical records skipped: 0
Total logical records read: 10
Total logical records rejected: 0
Total logical records discarded: 0
Run began on Thu Feb 26 16:01:23 2004
Run ended on Thu Feb 26 16:01:23 2004
Elapsed time was: 00:00:00.58
CPU time was: 00:00:00.10
SQL > select * from dummy_test ;
TEXT TEXT_B
SCHEDULE S
RETURN R
BREAKDOWN B
HOLIDAY HOLIDAY
WEEKEND WEEKEND
schedule S
return R
breakdown B
holiday holiday
weekend weekend
10 rows selected.
SQL>
Does it solve your problem ?
Regards,
Rainer
Maybe you are looking for
-
Need help in Creating DB manually with OFA
Hi, I want to create database in 10g manually and for this purpose I need help. since we can use OFA for storing Control files, and redolog file and datafile by describing them in Create database command but how to store any instance related file lik
-
When i print to adobe pdf from word the document isn't saved anywhere
I have installed the trial version of adobe acrobat xi pro so that I can print to pdf. I have successfully done this from email etc but it will not work in word. I go to print document select adobe pdf as printer and it comes up with the save window
-
Connecting to an Oracle 8i Database
Hi Everyone, Has there been any successful ODI 11g connection (via Studio or Agent) to an Oracle 8i database? When I create a new Data Server, and select the Oracle JDBC driver in the list, I get this prompt message: Oracle JDBC Driver (Type 4 / Type
-
We're seeing people search for things in Dreamweaver Help -- simple things -- and coming up empty-handed. There are lots of reasons for this, one of them being the new google search engine that powers Web Help searches and the new Community Help. The
-
I am calculating rent increase schedules on property manager and i am stuck on two cases scenarion 1 Rent is 200K per year rent increase is 10% per year (compound) service charge is constatnt at 50K per year for the whole lease period. scenario 2 ren