Date datatype in SQL*LOADER
Hi guys,
How do we use DATE datatype in SQL*LOADER
Hi,
I was just wondering if you've resolved this error. I want to know because we're experiencing the exact same error right now.
Thanks.
Regards,
_lilim
Similar Messages
-
How to handle Multiple date formats for the same date field in SQL*Loader
Dear All,
I got a requirement where I need to get data from a text file and insert the same into oracle table.
I am using SQL*Loader to populate the data from the text file into my table.
The file has one field where I am expecting date date data in multiple formats, like dd/mon/yyyy, yyyy/dd/mon, yyyy/mon/dd, ,mm/dd/yyyy, mon/dd/yyyy.
While using SQL*Loader, I can see Loading is failing for records where we have formats like yyyy/dd/mon, yyyy/mon/dd, mon/dd/yyyy.
Is there any way in SQL*Loader where we can mention all these date formats so that this date data should go smoothly into the underlying date column in the table.
Appreciate your response on this.
Thanks,
Madhu K.The point being made was, are you sure that you can uniquely identify a date format from the value you receieve? Are you sure that the data stored is only of a particular limited set of formats?
e.g. if you had a value of '07/08/03' how do you know what format that is?
It could be...
7th August 2003 (thus assuming it's DD/MM/RR format)
or
8th July 2003 (thus assuming it's MM/DD/RR format)
or
3rd August 2007 (thus assuming it's RR/MM/DD format)
or
8th March 2007 (thus assuming it's RR/DD/MM format)
or even more obscurely...
3rd July 2008 (MM/RR/DD)
or
7th March 2008 (DD/RR/MM)
Do you have any information to tell you what formats are valid that would allow you to be specific and know what date format is meant?
This is a classic example of why dates should be stored on the database using DATE datatype and not VARCHAR2. It can lead to corruption of data, especially if the date can be entered in any format a user wishes. -
Need to Skip the fields duaring the data upload by SQL*Loader.
Hi all,
I am not able to get how to skip some fileds in the file while uploading it thru SQL*Loader. Let us have a look the below scenario.
The table has 4 columns. but in the input file came up with 6 fields. Let us assume the four fields came as first in the order. Then, we can populate the data into the 4 columns of the table. At the same time we want to skip the remaining fields. Even those fields/columns are no longer available in the database table.
For example:
create table data_temp(sno number,name varchar2(10 char),sex char(1),loc varchar2(20 char));
Data file
sno,name,sex,loc,organization,contact
1,ram,M,India,HP,998976789
2,Shesha,M,India,IBM,7890808098
Control_file
OPTIONS(SKIP=1)
LOAD DATA
INFILE *
APPEND INTO TABLE data_temp
FIELDS TERMINATED BY ',' optionally enclosed by '"'
TRAILING NULLCOLS
sno "trim(:sno)",
name "SUBSTR(trim(:name),1,20)" ,
sex "SUBSTR(trim(:sex),1,1)",
loc "SUBSTR(trim(:loc),1,20)" ,
Please suggest me how to implement the above scenario in the control file.
Thanks in Advance!!
Regards,
Vissu.....Use FILLER. Control file:
OPTIONS(SKIP=1)
LOAD DATA
INFILE *
APPEND INTO TABLE data_temp
FIELDS TERMINATED BY ',' optionally enclosed by '"'
TRAILING NULLCOLS
sno "trim(:sno)",
name "SUBSTR(trim(:name),1,20)" ,
sex "SUBSTR(trim(:sex),1,1)",
loc "SUBSTR(trim(:loc),1,20)" ,
organization filler,
contact filler
begindata
sno,name,***,loc,organization,contact
1,ram,M,India,HP,998976789
2,Shesha,M,India,IBM,7890808098
{code}
Now:
{code}
SQL> create table data_temp(sno number,name varchar2(10 char),sex char(1),loc varchar2(20 char));
Table created.
SQL> host sqlldr scott/tiger control=c:\temp\vissu.ctl log=c:\temp\vissu.log
SQL> select * from data_temp
2 /
SNO NAME S LOC
1 ram M India
2 Shesha M India
SQL>
{code}
SY. -
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 -
Load Xml Data in oracle (SQL LOADER)
i have written a sql loader script given below....
load data
infile 'contact1.xml' "str '</CONTACT>'"
truncate
into table XmlTest
dummy filler terminated by ">",
Location_id enclosed by "<Location_id>" and "</Location_id>",
fname enclosed by "<fname>" and "</fname>",
lname enclosed by "<lname>" and "</lname>"
the content of the contact1.xml is given below.....
<CONTACT>
<Location_id>1</Location_id>
<fname>Robert</fname>
<lname>Jones</lname>
</CONTACT>
<CONTACT>
<Location_id>1</Location_id>
<fname>Robert</fname>
<lname>Jones</lname>
</CONTACT>
the script works fine for the given xml... but if one of the tag in the xml is changed to below syntax....
<CONTACT Location_id="1">
<fname>Robert</fname>
<lname>Jones</lname>
</CONTACT>
<CONTACT Location_id="1">
<fname>Robert</fname>
<lname>Jones</lname>
</CONTACT>
what modification is required in the script to read such xml...Kindly Help!!And in what way does this relate to SQL and PL/SQL?
There is a demo of loading XML in Morgan's Library under SQL*Loader.
But as your question is off-topic here ... if the demo does not help you please continue this by starting a thread in the correct forum: Database General.
Thanks. -
Export data ready for sql loader
Hi,
I need to export some data from my database ready to be used by sql loader ... what are tools can I use? Using sqlplus (i.e. spool file.csv select c1||";"||c2||";" from table; spool off) is the only tool I can use?Hello,
You have multiple choices depending upon your oracle version on both source and target.
*1. Conventional export/import (no need to generate csv)*
*2. Datapump (10g)*
*3. Extracting .csv file using sql and loading using sqlldr*
*4. External table unloading data using datapump.*
*5. External table using .csv file generated via sql script.*
Regards -
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
sudheerHi,
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... -
Filter data on GUI SQL Loader of 10g
I have a 10g and using the SQL developer to import data from an excel to a table.
after right click on the table and specify the file, i have to map the column, since there is no header info in the spreadsheet.
i then came into 2 problems
1) on column with data type, it will say the data is null or invalid format.
2) only a subset of the data in the sheet is needed, so, i like to place a where clause type criteria during the import.
how to i handle these two situations? is there step by step instructions to follow on each?
thanks.Your problem is most likely in decode - the return type in your expression will be character based on first search value ('null'), so it will be implicitly converted to character and then again implicitly converted to date by loading into date column. At some of this conversions you probably are loosing your time part. You can try instead use cast:
SQL> desc t
Name Null? Type
LASTWRITTEN DATE
CREATEDON DATE
LASTUPDATEDON DATE
SQL> select * from t;
no rows selected
SQL> !cat t.ctl
LOAD DATA
INFILE *
INTO TABLE T
TRUNCATE
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
LASTWRITTEN
"decode(:LASTWRITTEN,'null',cast(Null as date),
to_date(:LASTWRITTEN,'YYYY-MM-DD HH24:MI:SS'))",
CREATEDON
"decode(:CREATEDON,'null',cast(Null as date),
to_date(:CREATEDON,'YYYY-MM-DD HH24:MI:SS'))",
LASTUPDATEDON
"decode(:LASTUPDATEDON,'null',cast(Null as date),
to_date(:LASTUPDATEDON,'DD/MM/YYYY HH24:MI:SS'))"
BEGINDATA
2007-02-15 15:10:20,null,null
null,2007-02-15 15:10:20,null
null,null,15/02/2007 15:10:20
SQL> !sqlldr userid=scott/tiger control=t.ctl log=t.log
SQL*Loader: Release 10.2.0.3.0 - Production on Fri Feb 29 00:20:07 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Commit point reached - logical record count 3
SQL> select * from t;
LASTWRITTEN CREATEDON LASTUPDATEDON
15.02.2007 15:10:20
15.02.2007 15:10:20
15.02.2007 15:10:20Best regards
Maxim -
Converting 99999999 to date datatype through sql/ssis
Hi,
I am developing an ETL in which we get this column which holds the value 99999999 in one of the columnwhich is of numeric datatype. User wants that field to be date time in destination. Please help me on how to convert that value into date datatype in SSIS.
Please........Thank you Rajen,
But I have used Collasce to solve this issue.
COALESCE
(NULLIF(t1.dtetrm,
'99999999')
,'20991231') -
Dear All,
I have a table CMS_HO where I have defined different columns. One column is of date type STATUS_DATE. I want to upload one ASCII file where one field is in the format like below:
5/26/2008 12:41
5/26/2008 8:51
5/28/2008 9:01
5/28/2008 13:54
5/13/2008 10:45
4/6/2008 9:21
I want to upload file into Oracle database. Currently I am using following control file:
LOAD DATA
INTO TABLE CMS_HO TRUNCATE
FIELDS TERMINATED BY "\t"
TRAILING NULLCOLS
( ID,EXPIRYDATE, VER, SN, STATUS_DATE)
There seems error in the STATUS_DATE field in control file. Can any one help how to modify this Control file so that data against this field can be uploaded into date format please?
ThanksHere's an example i pulled from the web on specifying the date format in a control file.
http://infolab.stanford.edu/~ullman/fcdb/oracle/or-load.html#loading%20date%20data
Based on the sample data you provided, i think this is the format you're after.
ME_XE?select
2 to_date('5/13/2008 10:45', 'mm/dd/yyyy hh24:mi') as date_value_24_hours
3 from dual;
DATE_VALUE_24_HOURS
13-MAY-2008 10 45:00
1 row selected.
Elapsed: 00:00:00.89 -
New Line in data file for sql loader
Hi all,
I have a requirement to load a data file in which some of the rows are in new line as given in following example. If i put a '\n' character in control file, then it will load only those records which have newline in them ignoring non new line ones. please have a look at control fileand provide a solution to it :-
32 grand street ~NY~NY
42 riverdrive,
apt 1B ~PL~TX
Richardson road
apt 32~ SF ~CA
As you see there are newline characters in record 2 and 3, right now my control file looks like this -
LOAD DATA
INFILE 'example.txt' "STR '\r\n'"
INTO TABLE "temp_table"
INSERT
FIELDS TERMINATED BY '~'
TRAILING NULLCOLS
(ADDRESS1,
CITY,
STATE)
If i remove "STR '\r\n'" , then the data gets loaded into different rows like the third record looks like this -
ADDRESS CITY STATE
Richardson road null null
apt 32 SF CA
Please help.Your requirement is very unclear.
Is this your INPUT ?
--record 1
32 grand street ~NY~NY
--record 2
42 riverdrive, --"NL"
apt 1B ~PL~TX
--record 3
Richardson road --"NL"
apt 32~ SF ~CAIs this your OUTPUT?
ADDRESS CITY STATE
32 grand street NY NY
42 riverdrive, null null
apt 1B PL TX
Richardson road null null
apt 32 SF CAAre you using Linux or Windows platform?
You should have only one record terminator character.
*\r\n* is Windows The End of Line character (The Carriage Return + The Line Feed).
"STR '\r\n'" = "str X'0D0A'"
If there is no data after \r\n, columns will be null.
http://docs.oracle.com/cd/B28359_01/server.111/b28319/ldr_concepts.htm#i1005800 -
XSL transform question from XML date datatype to SQL date datatype
Just to give an idea, I am reading some employee information in a CSV format and I have created the fileadapter to read it and parse it into coherent information where each comma separated value corresponds to a column in an employee table. One of the columns is of the date object in the database.
So my my variable is created with a list of employees and then fed into the invoke that calls a dbadapter that does the insert. I am using a transformation to get the values from one variable into the other simply because of namespace conflicts. However the xml date will not match the sql date object as to be expected...but how do I work around it? I have a few ideas but I am not sure they are worth mentioning.
Any suggestions?@@Version : ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
May 14 2014 18:34:29
Copyright (c) Microsoft Corporation
Developer Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
(1 row(s) affected)
Compatibility level is set to 110 .
One of the limitation states - XML columns with a depth of more than 128 nested nodes
How do i verify this ? Thanks .
Rajkumar Yelugu -
How to get Dynamic data file in SQL*Loader?
Hi all,
I have a requirement that needs to import data everyday using background process. I have created a control file with the fixed datafile name and calling it through java. It is working fine.
The thing is data file name is not constant, it changes everyday (I mean the file name format is YearMonthDate_Clients.cvs). But the the data file location is fixed location.
How can I get the data file name dynamically?
Can someone has the answer?
Thanks in advance,
KalyogiI'm not a JAVA developer, but I've used this before
File folder = new File("c:/");
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles.isFile()) {
--Here the filename is printed, but I'm sure you can pass this to whatever/however you are invoking SqlLdr
System.out.println("File " + listOfFiles[i].getName()); -
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 -
SQL Loader: handling difference datatypes in data file and table column
Hi,
I am not sure if my question is valid but I am having this doubt.
I am trying to load data from my data file into a table with just a single column of FLOAT datatype using SQL Loader. But very few insertions take place, leaving a large number of record rejected for the same reason-
Record 7: Rejected - Error on table T1, column MSISDN.
ORA-01722: invalid number
The data in my datafile goes like this: (with a single space before every field)
233207332711<EOFD><EORD> 233208660745<EOFD><EORD> 233200767380<EOFD><EORD>
Here I want to know if there is any way to type cast the data read from the data file to suit my table column's datatype.
How do I handle this? I want to load all the data from my datafile into my table.Pl continue the discussion in your original post - Pls help: SQL Loader loads only one record
Maybe you are looking for
-
Ipod touch and Iphone no longer showing up in itunes...
I plugged in my ipod and it doesnt show up in the sidebar in itunes.
-
Create Table Temp As Select * from Table
What happens in the backend (performance point of view) when we create a table as follows: Create Table Temp As Select * from Table1; Suppose that the table Table1 has 10 million rows. How is this different from inserting 10 million rows using Insert
-
I am displaying line items in the script. I have total 20 line items and in each page i am displaying 5 line items with page wise totals . I am displaying 20 line items in 4 pages each page below i am displaying 5 line items amount totals , in the la
-
I have recently bought a LaCie Hard Drive,
I have recently bought a LaCie Hard Drive, it works fine, and I have formatted for use with Mac OS X. I share my iMac with other users, 3 others to be exact, and I want them to be able to use the external hard drive to store their files, music etc. H
-
What's the best way to...
What's the best way to remove footage and projects from my hard drive... I want to make sure I get rid of everything related to certain projects... Is there a step by step tutorial somewhere on how to remove projects and thier footage one by one? Tha