How to load date column using sql loader
Hi,
I am trying to load a file using sql loader. my date value in the file is '2/24/2009 8:23:05 pm',
In control file for this column i specified like this
rec_date date ''mm/dd/yyyy hh:mi:ss pm"
But i am getting following error
not avalid month.
Thanks
sudheer
Hi,
Use this example as reference:
CTL file:
LOAD DATA
INFILE 'test.txt'
BADFILE 'test.bad'
truncate INTO TABLE T3
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '|' TRAILING NULLCOLS
dt_date DATE "mm/dd/yyyy hh:mi:ss pm")DAT file:
2/24/2009 8:23:05 pm
C:\ext_files>sqlldr hr/hr control=test.ctl
SQL*Loader: Release 10.2.0.1.0 - Production on Wed Jul 1 20:35:35 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Commit point reached - logical record count 1
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> desc t3;
Name Type Nullable Default Comments
DT_DATE DATE Y
SQL> select to_char(dt_date, 'mm/dd/yyyy hh24:mi:ss') from t3;
TO_CHAR(DT_DATE,'MM/DD/YYYYHH2
02/24/2009 20:23:05
SQL> Regards,
Edited by: Walter Fernández on Jul 1, 2009 8:35 PM - Adding example...
Edited by: Walter Fernández on Jul 1, 2009 8:38 PM
Edited by: Walter Fernández on Jul 1, 2009 8:41 PM - Fixing some information...
Similar Messages
-
Problem when loading xml file using sql loader
I am trying to load data into table test_xml (xmldata XMLType)
i have an xml file and i want whole file to be loaded into a single column
when i use the following control file and executed from command prompt as follows
sqlldr $1@$TWO_TASK control=$XXTOP/bin/LOAD_XML.ctl direct=true;:
LOAD DATA
INFILE *
TRUNCATE INTO TABLE test_xml
xmltype(xmldata)
FIELDS
ext_fname filler char(100),
xmldata LOBFILE (ext_fname) TERMINATED BY EOF
BEGIN DATA
/u01/APPL/apps/apps_st/appl/xxtop/12.0.0/bin/file.xml
the file is being loaded into table perfectly.
unfortunatley i cant hardcode file name as file name will be changed dynamically.
so i removed the block
BEGIN DATA
/u01/APPL/apps/apps_st/appl/xxtop/12.0.0/bin/file.xml
from control file and tried to execute by giving file path from command line as follows
sqlldr $1@$TWO_TASK control=$XXTOP/bin/LOAD_XML.ctl data=/u01/APPL/apps/apps_st/appl/xxtop/12.0.0/bin/file.xml direct=true;
but strangely it's trying to load each line of xml file into table instead of whole file
Please find the log of the program with error
Loading of XML through SQL*Loader Starts
SQL*Loader-502: unable to open data file '<?xml version="1.0"?>' for field XMLDATA table TEST_XML
SQL*Loader-553: file not found
SQL*Loader-509: System error: No such file or directory
SQL*Loader-502: unable to open data file '<Root>' for field XMLDATA table TEST_XML
SQL*Loader-553: file not found
SQL*Loader-509: System error: No such file or directory
SQL*Loader-502: unable to open data file '<ScriptFileType>' for field XMLDATA table TEST_XML
SQL*Loader-553: file not found
SQL*Loader-509: System error: No such file or directory
SQL*Loader-502: unable to open data file '<Type>Forms</Type>' for field XMLDATA table TEST_XML
SQL*Loader-553: file not found
SQL*Loader-509: System error: No such file or directory
SQL*Loader-502: unable to open data file '</ScriptFileType>' for field XMLDATA table TEST_XML
SQL*Loader-553: file not found
SQL*Loader-509: System error: No such file or directory
SQL*Loader-502: unable to open data file '<ScriptFileType>' for field XMLDATA table TEST_XML
SQL*Loader-553: file not found
SQL*Loader-509: System error: No such file or directory
SQL*Loader-502: unable to open data file '<Type>PLL</Type>' for field XMLDATA table TEST_XML
SQL*Loader-553: file not found
SQL*Loader-509: System error: No such file or directory
SQL*Loader-502: unable to open data file '</ScriptFileType>' for field XMLDATA table TEST_XML
SQL*Loader-553: file not found
SQL*Loader-509: System error: No such file or directory
SQL*Loader-502: unable to open data file '<ScriptFileType>' for field XMLDATA table TEST_XML
please help me how can i load full xml into single column using command line without hardcoding in control file
Edited by: 907010 on Jan 10, 2012 2:24 AMbut strangely it's trying to load each line of xml file into table instead of whole fileNothing strange, the data parameter specifies the file containing the data to load.
If you use the XML filename here, the control file will try to interpret each line of the XML as being separate file paths.
The traditional approach to this is to have the filename stored in another file, say filelist.txt and use, for example :
echo "/u01/APPL/apps/apps_st/appl/xxtop/12.0.0/bin/file.xml" > filelist.txt
sqlldr $1@$TWO_TASK control=$XXTOP/bin/LOAD_XML.ctl data=filelist.txt direct=true; -
Loading XML file using sql*loader (10g)
Hi Everyone....
I have a major problem. I have a 10g database and I need to use sql loader to load a large XML file into the database. This file contains records for many, many customers. This will be done several times and the number of records will vary. I want to use sql loader and load to a staging table, BUT SPLIT THE RECORDS OUT and add a sequence. I am having 2 problems.
In the 10g documentation, when you want to split the records you use the BEGINDATA clause and indicate something (like a 0) for each instance of a record. Well my first file has 3,722 records in it. How do I know the number of records in each XML file?
The second problem is that because this is XML, I thought that I could use ENCLOSED BY. But the start tag has an attribute /counter in it, sql*loader doesnt recognize the starting tag. (i.e.: start tag is: </CustomerRec number=1>
end tag is: </CustomerRec> )
So, I used TERMINATED BY '</CustomerRec>'. This will split out the records, but it will NOT include the ending tag of </CustomerRec> and when I use extract, I receive an XML parsing error.
I have tried to get the ending tag using CONTINUEIF and SKIP. But those options are for "records" and not lines.
Does anyone have any ideas for the 2 problems above. I am at my wits end and I need to finish this ASAP. Any help would be appreciated.
Thank you!Sorry.... here is an example of what my control file looks like. At the end, I have 92 "0", but remember, I have 3722 records in this first file.
LOAD DATA (SKIP 1)
INFILE *
INTO TABLE RETURN_DATA_STG
TRUNCATE
XMLType(xmldata)
FIELDS
(fill FILLER CHAR(1),
loadseq SEQUENCE(MAX,1),
xmldata LOBFILE (CONSTANT F001AB.XML)
TERMINATED BY '</ExtractObject>'
------ ":xmldata||'</ExtractObject>'"
BEGINDATA
0
0
0
0
0
0 -
Problem loading XML-file using SQL*Loader
Hello,
I'm using 9.2 and tryin to load a XML-file using SQL*Loader.
Loader control-file:
LOAD DATA
INFILE *
INTO TABLE BATCH_TABLE TRUNCATE
FIELDS TERMINATED BY ','
FILENAME char(255),
XML_DATA LOBFILE (FILENAME) TERMINATED BY EOF
BEGINDATA
data.xml
The BATCH_TABLE is created as:
CREATE TABLE BATCH_TABLE (
FILENAME VARCHAR2 (50),
XML_DATA SYS.XMLTYPE ) ;
And the data.xml contains the following lines:
<?xml version="2.0" encoding="UTF-8"?>
<!DOCTYPE databatch SYSTEM "databatch.dtd">
<batch>
<record>
<data>
<type>10</type>
</data>
</record>
<record>
<data>
<type>20</type>
</data>
</record>
</batch>
However, the sqlldr gives me an error:
Record 1: Rejected - Error on table BATCH_TABLE, column XML_DATA.
ORA-21700: object does not exist or is marked for delete
ORA-06512: at "SYS.XMLTYPE", line 0
ORA-06512: at line 1
If I remove the first two lines
"<?xml version="2.0" encoding="UTF-8"?>"
and
"<!DOCTYPE databatch SYSTEM "databatch.dtd">"
from data.xml everything works, and the contentents of data.xml are loaded into the table.
Any idea what I'm missing here? Likely the problem is with special characters.
Thanks in advance,I'm able to load your file just by removing the second line <!DOCTYPE databatch SYSTEM "databatch.dtd">. I dont have your dtd file, so skipped that line. Can you check if it's problem with ur DTD?
-
Need suggestions on loading 5000+ files using sql loader
Hi Guys,
I'm writing a shell script to load more than 5000 files using sql loader.
My intention is to load the files in parallel. When I checked the maximum number of sessions in v$parameter, it is around 700.
Before starting the data load, programmatically I am getting the number of current sessions and maximum number of sessions and keeping free 200 sessions without using them (max. no. of sessions minus 200 ) and utilizing the remaining ~300 sessions to load the files in parallel.
Also I am using a "wait" option to make the shell to wait until the 300 concurrent sql loader process to complete and moving further.
Is there any way to make it more efficient? Also is it possible to reduce the wait time without hard coding the seconds (For Example: If any of those 300 sessions becomes free, assign the next file to the job queue and so on..)
Please share your thoughts on this.
Thanks.Manohar wrote:
I'm writing a shell script to load more than 5000 files using sql loader.
My intention is to load the files in parallel. When I checked the maximum number of sessions in v$parameter, it is around 700. Concurrent load you mean? Parallel processing implies take a workload, breaking that up into smaller workloads, and doing that in parallel. This is what the Parallel Query feature does in Oracle.
SQL*Loader does not do that for you. It uses a single session to load a single file. To make it run in parallel, requires manually starting multiple loader sessions and perform concurrent loads.
Have a look at Parallel Data Loading Models in the Oracle® Database Utilities guide. It goes into detail on how to perform concurrent loads. But you need to parallelise that workload yourself (as explained in the manual).
Before starting the data load, programmatically I am getting the number of current sessions and maximum number of sessions and keeping free 200 sessions without using them (max. no. of sessions minus 200 ) and utilizing the remaining ~300 sessions to load the files in parallel.
Also I am using a "wait" option to make the shell to wait until the 300 concurrent sql loader process to complete and moving further.
Is there any way to make it more efficient? Also is it possible to reduce the wait time without hard coding the seconds (For Example: If any of those 300 sessions becomes free, assign the next file to the job queue and so on..)Consider doing it the way that Parallel Query does (as I've mentioned above). Take the workload (all files). Break the workload up into smaller sub-workloads (e.g. 50 files to be loaded by a process). Start a 100 processes in parallel and provide each one with a sub-workload to do (100 processes each loading 50 odd files).
This is a lot easier to manage than starting for example a 5000 load processes and then trying some kind of delay method to ensure that not all hit the database at the same time.
I'm loading about 100+ files (3+ million rows) every 60 seconds 24x7 using SQL*Loader. Oracle is quite scalable and SQL*Loader quite capable. -
How to have a common value for a column using sql loader
Hi Have a sql loader file which looks like below. But I am not getting how insert the same value for the column in all rows.
id,
crt_user_id
BEGINDATA
1;"system"
2;"system"
3;"system"
So, instead of entering the crt_user_id as system in all rows, can we place the value at the top after the column name?Thanks Srini. your hint/suggestion helped me in finding the solution.
LOAD DATA
INFILE *
BADFILE './TEST.BAD'
DISCARDFILE './TEST.DSC'
APPEND INTO TABLE TEST_TABLE
Fields terminated by ";" Optionally enclosed by '"'
ID,
crt_user_id CONSTANT 'SOME CONSTANT VALUE'
BEGINDATA
1
2
3
so by using CONSTANT key word, we can avoid tying the same value in the data -
How to have more than one condition on same column --- using SQL Loader
Hi All,
I am stuck with SQL Loader..
How do I filter records before loading in the table using when clause..
i should load data only when
field1 = 'AC' or 'VC'
field2 is NULL
i used various combinations in when clause like
a) when field1='AC' or field1='VC' and field2 = BLANKS
b) when (field1='AC') and (field2 = BLANKS )
& similar...
In all the cases I tried I could not implement OR condition with field1 and null condition with field2
but my main concern is can we use OR or IS NULL things in when clause of SQL Loader..
is it possible to check this anywhere??
any alternate solution u could suggest??
Thanks
DikshitOk I'll try that, although I did try it earlier when I had iTunes 5.xx loaded, I think.
As to size of playlists, I have a master (900 songs) that defines what will fit onto the ipod , I then generate all the others as subsets of the master (not of the library)- hence I know they will all fit
Can you also clarify something for me: the dialogue box we are discussing is intended, I think, so that one can set the automatic synching of certain playlists between the PC & the ipod. Is that the only way one can select other playlists to go to the ipod - i.e. as static once-offs, not synchronised ?
Apple' docs, I think, are poor in this regard - they assume most ipods are bigger then the users song library and they gloss over the details of this alternate mode of playlist synching.
Thanks - Nick -
Extract Data from XML and Load into table using SQL*Loader
Hi All,
We have a XML file (sample.xml) which contains credit card transaction information. We have a standard SQL*Loader control file which loads the data from a flat file and the control file code is written as position based method. Our requirement is to use this control file as per our requirement(i.e) load the data into the table from our XML file), But we need help in converting the XML to a flat file or Extract the data from the XML tags and pass the information to the control file and in turn it loads the table.
Your suggestion is highly appreciated.
Thanks in advanceHi,
First of all go to PSA maintanance ( Where you will see PSA records ).
Goto list---> Save-> File---> Spreadsheet (Choose Radio Button)
> Give the proper file name where you want to download and then-----> Generate.
You will get ur PSA data in Excel Format.
Thanks
Mayank -
Dual Language Data upload using SQL*Loader
I have to load data consisting of English and Traditional Chinese characters into 8.1.5 from external files. These external files are in MS Excel.
Is there any way that I can user SQL*Loader for this ? If yes, how ? If not, is there any other way out.
The NLS in the database is currently AMERICAN.
nullORA-00604 error occurred at recursive SQL level string
Cause: An error occurred while processing a recursive SQL statement (a statement applying to internal dictionary tables).
Action: If the situation described in the next error on the stack can be corrected, do so; otherwise contact Oracle Support Services
This kind of error occurs when data dictionary is
query a lot.
Joel P�rez -
pls send ans for this
1b5595eb-fcfc-48cc-90d2-43ba913ea79f wrote:
pls send ans for this
use any text editor to eliminate the dot before loading -
How to load selected column with sql loader
Hi all
I want to load only few columns from a datafile not all columns and i don't know how to do from SQL LDR.
I know we can use position but the data is not fixed length.
I'm working with Oracle 11g and Linux OS.
Here is an example of my data file and table.
Data file is and the field is separated by | :
3418483|VOU|20120609090114|555208363|0|2858185502059|1000|0||
3418484|SR|20120609090124|551261956|0|4146314127759|200000|0||
SQL> desc TBL1
Name Null? Type
CTYPE VARCHAR2(5)
BDATE DATE
PARTNUM VARCHAR2(60)
SERIALNO NUMBER
FVALUE NUMBER
I want to have:
SQL> select * from TBL1
CTYPE BDATE PARTNUM SERIALNO FVALUE
VOU 09/06/2012 555208363 2858185502059 1000
SR 09/06/2012 551261956 4146314127759 200000Thank you.look at FILLER
http://www.orafaq.com/wiki/SQL*Loader_FAQ#Can_one_skip_certain_columns_while_loading_data.3F
--add sample
num1 FILLER,
ctype,
bdate "to_date(:bdate, 'YYYYMMDDHH24MISS')",
PARTNUM,
num2 FILLER,
SERIALNO,
FVALUE,
num3 FILLER
)Edited by: AlexAnd on Jun 9, 2012 4:29 AM -
How to update the columns using sql queries?
create table emp(eno number(5),ename varchar2(20),dno number(2),dname varchar2(20),loc_id number(3), location varchar2(10));
insert into emp(eno,ename,dno,loc_id) values(1,'tom1',10,1);
insert into emp(eno,ename,dno,loc_id) values(2,'tom2',20,2);
insert into emp(eno,ename,dno,loc_id) values(3,'tom3',30,3);
insert into emp(eno,ename,dno,loc_id) values(4,'tom4',40,4);
insert into emp(eno,ename,dno,loc_id) values(5,'tom5',50,5);
insert into emp(eno,ename,dno,loc_id) values(6,'tom6',60,6);
insert into emp(eno,ename,dno,loc_id) values(7,'tom7',70,7);
insert into emp(eno,ename,dno,loc_id) values(8,'tom8',80,8);
create table dept(dno number(3),dname varchar2(10));
insert into dept values(10,'RM');
insert into dept values(10,'DD');
insert into dept values(10,'TD');
create table location(loc_id number(3),location varchar2(20));
insert into location values(1,'palani');
insert into location values(1,'salem');
insert into location values(1,'kalpattu');
insert into location values(1,'thirukoyilur');
insert into location values(2,'thaeni');
insert into location values(2,'villupuram');
insert into location values(2,'yercaud');
insert into location values(3,'thiruvanamalai');
insert into location values(3,'trichy');
insert into location values(7,'tanjore');
insert into location values(4,'tirunelveli');
insert into location values(4,'namakal');
insert into location values(5,'bangalore');
insert into location values(6,'chennai');
insert into location values(6,'calcutta');
insert into location values(7,'tirupathy');
insert into location values(7,'bombay');
insert into location values(7,'kumbokonam');
My requirement is to update the department name and location of toms present in employee table without using cursors, loops.
The column department number and loc_id are used for joins.
I am in a situation to deliver my code on time.try this
update emp tt
set (dname,location ) = (
select res,res1 from (select a.eno,a.ename,a.dno,b.dname,a.loc_id,c.location
from emp a,
dept b,
location c
where a.dno = b.dno
and a.loc_id = c.loc_id
) t
where tt.eno = t.eno
model
return updated rows
partition by (eno)
dimension by (row_number() over (order by eno) as rn)
measures(cast (dname as varchar2(50)) as res,cast (location as varchar2(300)) as res1)
rules
upsert
iterate(1000)
until(presentv(res[iteration_number + 2],1,0) = 0)
res[0] = res[0] ||','|| res[iteration_number + 1],
res1[0] = res1[0] ||','|| res1[iteration_number + 1]))
;output
1 tom1 10 ,RM,RM,RM,RM,DD,TD,DD,DD,TD,TD,TD,DD 1 ,palani,salem,kalpattu,thirukoyilur,palani,thirukoyilur,kalpattu,thirukoyilur,palani,salem,kalpattu,salem
2 tom2 20 2
3 tom3 30 3
4 tom4 40 4
5 tom5 50 5
6 tom6 60 6
7 tom7 70 7
8 tom8 80 8 -
How to load date with time zone using sql loader???
Hi All,
How to load following value in the table using SQL loader.
[11/Jan/2006:15:20:14 -0800]
What should be the datatype of the column in the table. I have tried with "timestamp with local time zone", but unable to load the record using sql loader. What should be the format string in the loader control file to load this type of record.
Any help in this regard is highly appreciated.
SameerTry something like this in your control file:
mycol char "TO_TIMESTAMP_TZ(mycol, 'DD/MON/YYYY:HH24:MI:SS TZH:TZM')"
[pre]
Message was edited by:
Jens Petersen -
Error in loading data using SQL loader
I am getting a error like ‘SQL*Loader -350 syntax error of illegal combination of non-alphanumeric characters’ while loading a file using SQL loader in RHEL. The command used to run SQL*Loader is:
Sqlldr userid=<username>/<password> control =data.ctl
The control file, data.ctl is :
LOAD data
infile '/home/oraprod/data.txt'
append into table test
empid terminated by ',',
fname terminated by ',',
lname terminated by ',',
salary terminated by whitespace
The data.txt file is:
1,Kaushal,halani,5000
2,Chetan,halani,1000
I hope, my question is clear.
Please revert with the reply to my query.
RegardsReplace ''{" by "(" in your control file
LOAD data
infile 'c:\data.txt'
append into table emp_t
empid terminated by ',',
fname terminated by ',',
lname terminated by ',',
salary terminated by whitespace
C:\>sqlldr user/pwd@database control=c.ctl
SQL*Loader: Release 10.2.0.3.0 - Production on Wed Nov 13 10:10:24 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Commit point reached - logical record count 1
Commit point reached - logical record count 2
SQL> select * from emp_t;
EMPID FNAME LNAME SALARY
1 Kaushal halani 5000
2 Chetan halani 1000
Best regards
Mohamed Houri -
Hi All,
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
I am working on Loading a file using SQL Loader.
I have loaded all the records (20Million) in to a table which has 30 columns.
Issue : Now i got a new layout for same Data file, Which already has 5 new columns at the end which we didn't loaded.
I have created the CTL file with New columns but can i update only those 5 new columns into the table. Is that Possible?
Or should i truncate and do it from the scratch....Please suggest me...
ThanksSQL*Loader does not update; It only inserts. You could load the data into a staging table, then use SQL to update, but that would be slower than just starting over. So, you should just reload the whole file, including the new columns, using the REPLACE in the SQL*Loader control file, instead of APPEND. That will overwrite any existing data.
Maybe you are looking for
-
Selecting from a list to a table
need help.i have items in a list and combo box in which i want it in such away that when item is selected from the list and combo box it goes to the table i have in a panel.i want to discard the text area i used.thanks in advance my code: '\n' import
-
Submit button no longer working
We have been using Adobe Forms and submitting responses for approx. 5 months now. Recently, we are no longer able to submit and all our computers are up to date with PDF and Adobe software. When trying to submit we get the error message "An error occ
-
Dynamic Communication Channel in Receiver Agreement
Hi Experts, I have the situation: one Receiver System with one Inbound Interface. This Receiver System is able to receive messages on this interface through different Communication Channels. I want to have a possobility, based on message content, to
-
ok.. i have a vacancies page, each vacancy has a link next to it called "edit" when you click on the link it does this: <a href="vacancyedit.cfm?ID=#ID#"> on vacancyedit.cfm there is a form. the fields on the form are populated with this query: <cfqu
-
USB 8451 no timer / counter ?
Hi all, i´m not sure if i´m in the right topic now, but i found no answer with the search function. I tried to generate an digital pulse using timer/counter functions with Labview 8.5 and an USB 8451, but it didn´t work. Is it possible that the USB 8