Using When clause in datafile witch have FIELDS TERMINATED BY ';' option
Dear all
For example if my datafile is the following :
E;11;
D;14;16;
Is'it possible to me having the following control file to load data in a table:
If yes? What is the correct syntax? If no what can i do to obtain my goal.
Thx for help!!!
LOAD DATA
TRUNCATE
INTO TABLE Tab1
when (1) ='E'
FIELDS TERMINATED BY ';' TRAILING NULLCOLS
(Type_Ligne CHAR,
Nombre INTEGER EXTERNAL)
INTO TABLE Tab1
when (1) ='D'
FIELDS TERMINATED BY ';' TRAILING NULLCOLS
(Type_Ligne CHAR,
Nombre INTEGER EXTERNAL,
Nombre2 INTEGER EXTERNAL)
@OP,
You missed specifying POSITION for Type_Ligne in the second WHEN. This is describe well in the following documentation.
SQL*Loader Control File Reference
VERBATIM from the documentation...
The POSITION parameter in the second INTO TABLE clause is necessary to load this data correctly. It causes field scanning to start over at column 1 when checking for data that matches the second format. Without it, SQL*Loader would look for the recid field after dname.
I tried your control file and it worked fine loading the first record but not the second.
create table Tab1
(Type_Ligne char(1),Nombre int, Nombre2 int);
LOAD DATA
INFILE *
TRUNCATE
INTO TABLE Tab1
when (1) ='E'
FIELDS TERMINATED BY ';' TRAILING NULLCOLS
(Type_Ligne CHAR,
Nombre INTEGER EXTERNAL)
INTO TABLE Tab1
when (1) ='D'
FIELDS TERMINATED BY ';' TRAILING NULLCOLS
(Type_Ligne POSITION(1) CHAR, ---- <<<<<<<<<<< I added POISTION(1) for this field
Nombre INTEGER EXTERNAL,
Nombre2 INTEGER EXTERNAL)
BEGINDATA
E;11;
D;14;16;
ENDDATA
Run SQLLDR...
C:\TEMP>sqlldr control=sqlloader.sql userid=hr/hr
SQL*Loader: Release 12.1.0.1.0 - Production on Sun Dec 29 12:45:01 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Path used: Conventional
Commit point reached - logical record count 2
Commit point reached - logical record count 3
Table TAB1:
1 Row successfully loaded.
Table TAB1:
1 Row successfully loaded.
Check the log file:
sqlloader.log
for more information about the load.
C:\TEMP>
The data got loaded.
> select * from tab1
TYPE_LIGNE NOMBRE NOMBRE2
E 11
D 14 16
Hope this helps.
vr,
Sudhakar
Similar Messages
-
SQL Loader error on Fields terminated and optionally enclosed
When you have fields terminated and optionally enclosed, you should be able to have the enclosure characters within the data by doubling them.
So if I have fields terminated by '|' optionally enclosed by '"' and my data has a double quote in it, I can get SQL Loader to take it by replacing the double quote with two double quotes.
But this doesn't always work. For some reason the following string gets the error "no terminator found after TERMINATED and ENCLOSED field"
|"TRO2 ldj?=)(/&%ç*""aàéè_:;!àèé,jpdjbdbd"|
Apparently having the double quote immediately after an asterisk makes SQL Loader not see the second double quote. If I edit it and remove the two double quotes it loads OK. Also if I change the string to
|"TRO2 ldj?=)(/&%ç*aà""éè_:;!àèé,jpdjbdbd"|
Moving the double quote away from the asterisk it loads OK.
Anybody encounter this problem before?Oracle version is 11.1.0.7.0
OS is Windows 6.1.7601
I can't remove the "optionally enclosed by" clause because we're getting the data from another system. Fortunately this is test data and this particular combination of characters is unlikely to occur in production data. -
I am using xp and I don't have the wpa2 personnel option to set it up.
I have a wrt54g3g. I have it set up using security wpa2 personnel with aes. I have the password set and eveything. I can't get my lap top set up to connect. I am using xp and I don't have the wpa2 personnel option to set it up. I need some help on this? Thanks
Message Edited by ewoolwine on 04-06-200702:46 PMMake sure you have Windows XP service pack 2 (SP2) installed.
Also, WPA2 is the same as WPA with AES.
Hope this helps.
Message Edited by toomanydonuts on 04-07-200702:50 AM -
How to use WHEN clause in sqlldr
I want to insert RECORDS in table which are having orgno column values greater then 100 in my datafile using sqlldr.
In WHEN clause in my control file if i mention WHEN (orgno > '100')
it gives me error :
Illegal combination of non-alphanumeric characters
WHEN (orgno < '500')
^
I am able to insert records when i use WHEN (orgno = '100') but not when i use > or < sign.
what to do???Hello user8531525.
"The supported operators are equal (=) and not equal (!= or ne)"; replace the ne with less than and greater than signs. (http://www.mcs.csueastbay.edu/support/oracle/doc/10.2/server.102/b14215/ldr_control_file.htm)
Your filtering will need to be performed on the file itself or on the records after they are loaded. If your file is local to your database, consider using External Tables.
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.
Edited by: Luke Mackey on Aug 5, 2010 2:58 PM -
Multiproviders can be used when it is key to have a view on key figures?
Hello experts, maybe a easy one:
I have to create an object which allowes me to have a view on a master data and on a DSO.
an attribute of the master data is common with a characteristic of the DSO, therefore it is possible to join the two objects.
In this case what is best an infosource or a multiprovider?
What are the main drawbacks and the strengths of the two solutions?
Thank you in advanceHi Marco,
multiprovider is not useful in this case.
You have to create an InfoSet making a join on the fields in common between the object and the DSO.
hope it helps
cs -
Need help to use 'When' clause in CTL file
Hi,
I have a requirement
in ctl file while loading file names in to a table we need to ignore if the filename already exist in the table
eg:
load infile.txt
into a
when filename not in (select filename from a) append
filename varchar(1000)
is it possible?? any way to achieve this?? Pleas help..
Thanks in advance..user3647602 wrote:
Hi,
I have a requirement
in ctl file while loading file names in to a table we need to ignore if the filename already exist in the table
eg:
load infile.txt
into a
when filename not in (select filename from a) append
filename varchar(1000)
is it possible?? any way to achieve this?? Pleas help..
Thanks in advance..Easiest method i can think of would be to use an EXTERNAL TABLE instead of SQL LOADER.
Much more flexible.
Cheers, -
I have a Power Mac 5 WITHOUT an intel processer/ I have updated my computer to snow lepord which is as far as I can go. I am unable to use the cloud. I used to have a Mobileme account and used it when I traveled to foreign countries yo read email. I do not know how to acess my email when traveling now. My email address is through mac.com. Please advise as there must be a way. We are traveling to South America soon for about a month and I need to know how to access my email from afar.
Thanks!Hi Margaret,
I have a Power Mac 5 WITHOUT an intel processer/ I have updated my computer to snow lepord which is as far as I can go.
I think you updated to Leopard/10.5.x, Snow Leopard/10.6 is Intel only.
Actually you're in luck, you can still use iCloud for eMail on PPC using 10.4.11 or 10.5.8, but it must be IMAP, not POP...
iCloud Mail setup...
IMAP (Incoming Mail Server) information:
Server name: imap.mail.me.com
SSL Required: Yes
Port: 993
Username: [email protected] (use your @me.com address from your iCloud account)
Password: Your iCloud password
SMTP (outgoing mail server) information:
Server name: smtp.mail.me.com
SSL Required: Yes
Port: 587
SMTP Authentication Required: Yes
Username: [email protected] (use your @me.com address from your iCloud account)
Password: Your iCloud password
One secret I think is when setting it up don't choose the .me/.mac type, it'll auto fill in .mac as the server which won't work, go back afterwards & change the servers. -
how do i update the software on an iphone 3gs when the software update option is not in the settings on the phone?
The option to update without the computer (Over the air) was made available with iOS 5. If your iDevice is using a version of iOS lower than 5, you will need to use iTunes on your syncing computer to perform the upgrade. Use the Apple link below as a guide for the upgrade.
http://support.apple.com/kb/HT4972
Also read the instructions from the section entitled "Update your device using iTunes" at the link below.
http://support.apple.com/kb/HT4623
Information regarding transferring purchases from your iDevice to iTunes on your syncing computer can be found at the link below.
http://support.apple.com/kb/ht1848 -
SQL*LOADER, the WHEN clause and WILDCARDS
has anybody ever used wildcards in a WHEN clause in the SQL*LOADER control file?
WHEN string_2_load = 'GOOD' , all 'good' rows load
WHEN string_2_load = 'GO%', all rows fail the WHEN clause and end up in the discard file.
thanks in advance - if i don't go crazy first
burtI have also faced a similar problem like this. Try this control file
LOAD DATA
INFILE 'DATA.dat'
BADFILE 'MLIMA.bad'
INTO TABLE Brok_Gl_Interface
APPEND
WHEN record_type = '10'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
record_type CHAR ,
currency CHAR ,
entity CHAR ,
cost_centre CHAR ,
usd_account CHAR ,
amount CHAR
INTO TABLE Brok_Gl_Interface
WHEN record_type = '99'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
record_type POSITION(1) CHAR ,
record_count CHAR
INTO TABLE Brok_Gl_Interface
WHEN record_type = '00'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
record_type POSITION(1) CHAR,
run_date CHAR,
effective_date CHAR
)Regards,
Mohana -
Error with When Clause SQL Loader
I´'m trying to use WHEN clause in a control file, I'm following the documentation but it doesn't work still.
This is my control file:
LOAD DATA
CHARACTERSET UTF8
INTO TABLE DM08_CONDICIONADA
WHEN (STATUS_DESC='A')
APPEND
REENABLE DISABLED_CONSTRAINTS
FIELDS
TERMINATED BY '|'
"ID_COND" POSITION (1) INTEGER EXTERNAL ,
"DESC_COND" CHAR,
"STATUS_DESC" CHAR
I have the follow error:
SQL*Loader-350: Syntax error at line 26.
Expecting "(", found keyword append.
APPEND
^
I have tried with
WHEN STATUS_DESC='A'
but the error is the same. Do you have any ideas why is that?? I'm working with oracle 9i.
Greetings
Oscarwith:
LOAD DATA
CHARACTERSET UTF8
INTO TABLE DM08_CONDICIONADA
APPEND
WHEN STATUS_DESC='A' --->with (STATUS_DESC='A') neither
REENABLE DISABLED_CONSTRAINTS
FIELDSTERMINATED BY '|'
I have:
SQL*Loader-350: Syntax error at line 27.
Expecting "(", found keyword reenable.
REENABLE DISABLED_CONSTRAINTS
With:
LOAD DATA
CHARACTERSET UTF8
INTO TABLE DM08_CONDICIONADA
APPEND
REENABLE DISABLED_CONSTRAINTS
WHEN (STATUS_DESC ='A')
i have:
SQL*Loader-403: Referenced column STATUS_DESC not present in table DM08_CONDICIONADA.
I´m using the documentation...
-->full_fieldname or pos_spec-->operator--> char_string or Blanks --->
but it doesn't tell me where the when clause goes... i'm probing too with the forum information but i don't know what happens.
Thanks Jens -
Regarding Sql Loader(All WHEN Clause Failed)
Below is my control file
LOAD DATA
INFILE 'DATA.dat'
BADFILE 'MLIMA.bad'
INTO TABLE Brok_Gl_Interface
APPEND
WHEN record_type = '10'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
record_type CHAR ,
currency CHAR ,
entity CHAR ,
cost_centre CHAR ,
usd_account CHAR ,
amount CHAR
INTO TABLE Brok_Gl_Interface
WHEN record_type = '99'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
record_type CHAR ,
record_count CHAR
INTO TABLE Brok_Gl_Interface
WHEN record_type = '00'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
record_type CHAR,
run_date CHAR,
effective_date CHAR
below is my data file
00,05062006,02062006,
10,EUR,82G,82GE00,46005AA600,78827.41,
10,GBP,82G,82GE00,46005AA600,-2820955.63,
10,GBP,82G,82GE00,46005AA600,340252.39,
10,GBP,82G,82GE00,46007AB100,-1665483.26,
10,EUR,82G,82GE38,46007AB100,-38924.00,
99,95,
At the time of execution the condition which is 1st is only working for others i am getting the error message 'All When Clause Failed'
pl'z help me out.I have also faced a similar problem like this. Try this control file
LOAD DATA
INFILE 'DATA.dat'
BADFILE 'MLIMA.bad'
INTO TABLE Brok_Gl_Interface
APPEND
WHEN record_type = '10'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
record_type CHAR ,
currency CHAR ,
entity CHAR ,
cost_centre CHAR ,
usd_account CHAR ,
amount CHAR
INTO TABLE Brok_Gl_Interface
WHEN record_type = '99'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
record_type POSITION(1) CHAR ,
record_count CHAR
INTO TABLE Brok_Gl_Interface
WHEN record_type = '00'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
record_type POSITION(1) CHAR,
run_date CHAR,
effective_date CHAR
)Regards,
Mohana -
Sqlloader:only 1st when clause works for comma separated data file
LOAD DATA
INFILE 'XXMI_SUPPLIER_DATA.dat'
REPLACE
INTO TABLE APPS.XXMI_AP_SUPPLIERS_STG
when interface_record_type = '01'
Fields terminated by "," Optionally enclosed by '"'
TRAILING NULLCOLS
and
INTO TABLE APPS.XXMI_AP_SUPPLIER_SITES_STG
when interface_record_type = '02'
Fields terminated by "," Optionally enclosed by '"'
TRAILING NULLCOLS
always getting the error for second when clause:
4 Rows not loaded because all WHEN clauses were failed.
pls any one can throw some light on this?What's Oracle version.
What's your datafile looks like. Post a few sample line here.
when interface_record_type = '01'You didn't define interface_record_type in your when clause.
Sample,
INTO TABLE dept
WHEN recid = 1
(recid FILLER INTEGER EXTERNAL TERMINATED BY WHITESPACE,
deptno INTEGER EXTERNAL TERMINATED BY WHITESPACE,
dname CHAR TERMINATED BY WHITESPACE) check Oracle doc,
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_control_file.htm#i1004788 -
Control file - Fields terminated by ';' using SQLLOADER
Hi Guys,
Can we load data using semicolon data using sqlloader .(Fields terminated by ';')
Filename : test.csv
Example :
Firstname;secondname;address;address2
hi;abc;Atlanta;GA
ABc;ABC;Atlantal;GA
I would appreicate your help.Hi, yes you can.
Your control file will look like (adjust to your own table)
load data
infile test.csv'
into table example
fields terminated by ';' optionally enclosed by '"'
(firstname char(5),
secondname char(7),
address char(100),
address2 char(100)
Filename : test.csv
Example :
Firstname;secondname;address;address2
hi;abc;Atlanta;GA
ABc;ABC;Atlantal;GA -
SQL Loader to append data in same table but using differnet WHEN clauses
In my data file i have a header record and a detail record identified by Record_type = 1 and 2 respectively.
The Database table has all the columns to capture detail records but i want to capture jus one column of header record now also in my existing table. So i have added that column (DATA_DATE)in my table but how to capture that value ?
im writing my control file using two WHEN clauses, something like -
load data
into table t_bdn
append
when RECORD_TYPE = '2'
FIELDS TERMINATED BY "|" TRAILING NULLCOLS
SEQUENCE_NO
, RECORD_TYPE
, DISTRIBUTOR_CODE
, SUPPLIER_CODE
, SUPPLIER_DISTRIBUTOR_CODE
, DISTRIBUTOR_SKU
, SUPPLIER_SKU
when RECORD_TYPE = '1'
FIELDS TERMINATED BY "|" TRAILING NULLCOLS
SEQUENCE_NO FILLER
, RECORD_TYPE FILLER
, CREATE_DATE FILLER
, DATA_DATE "NVL(to_date(:DATA_DATE, 'YYYY/MM/DD'),to_date('9999/12/31', 'YYYY/MM/DD'))"
im getting error " expecting INTO and foung WHEN RECORD_TYPE = '1' "
if i give iNTO second time it will append a new row altogether in my table but i want the same row to be updated with this DATA_DATE value coming from RECORD_TYPE =1 and header record has 4 delimited data text fields only and i am interested in fetching just the 4th column..
KIndly suggest what to do ?Ravneek, I could be wrong but sqlldr is a 'load' program, that is, it inserts data. I am unaware of any ability to update existing rows as you seem to want. What you appear to want to do is more the job of a merge statement.
I would look at writing a pro* language, a .net, or a java program to perform inserts where some or all of the newly inserted rows are also to be updated.
From the manual: (Oracle® Database Utilities 10g Release 2 (10.2) Part Number B14215-01)
Updating Existing Rows
The REPLACE method is a table replacement, not a replacement of individual rows. SQL*Loader does not update existing records, even if they have null columns. To update existing rows, use the following procedure:
1. Load your data into a work table.
2. Use the SQL language UPDATE statement with correlated subqueries.
3. Drop the work table.
HTH -- Mark D Powell -- -
It is using the track number and not the sort order field. The reason I have multiple cds in one alumn is because they are books on cd.
Sorry for the typo my "b" key was not working correctly.
The sort field is not used when ordering multiple cds in one albumn folder, how do I correct this? It is using the track number and not the sort order field. The reason I have multiple cds in one albumn is because they are books on cd.
Maybe you are looking for
-
I have a bit of software that I really need to work "TrueflowClient" trouble is its not working think its a java thing but any help would be greatly appreciated. think its a system issue going from Snow leopard to yosemite
-
Reports Server Process gets crashed in 10.1.2.3.0
Hi, We have 5 standalone production reports servers (10.1.2.3) load balanced through netscalar. We observed that the reports server process gets crashed intermittently which kills the reports jobs in the queue. Error as below is seen in the ipm.log u
-
hi guys, please any one would like to let me know is there a way to get to know about all possible elements and attributes of a root without visualizing them. In case if we have a large xml file then it is very hard to pick all possible elements. For
-
What to do with Palm Desktop data when I upgrade to Mac OS 10.6 Snow Leopard
I have an old Tungsten handheld device but only use Palm Desktop on my Mac. I have a lot of data stored in this format and do not want to lose this functionality when I upgrade to Snow Leopard, which, I understand, does not support Palm Desktop. Id
-
I cannot record or do anything. No sound at all for some reason. Originally it was telling me that I would be using windows audio and so I switched to Asio drivers. I couldn't get any sound before and I can't now. I'm so confused..