SQL Loader Case Studies
Hi All,
I need to load some CSV files using SQL Loader, and am looking for some examples describing how to do this. The documentation describes some "Case Studies", and case study 2 sounds like it is exactly what I need.
The case study files are not installed on my server, however. When I go to $ORACLE_HOME/rdbms/demo, there is only one file: aqxml.conf.
Is it possible to add these files to a server that is already setup and running? Is it possible to get the files from another source?
Any help greatly appreciated.
Thanks
Gavin
Hi Mithun,
This appears to be exactly what I need - Thanks!!
Gavin
Similar Messages
-
Can u give an detail examples or help on SQL- loader
Can u give an detail examples or help on SQL- loader
I need full details on this how to run and what are the pre requirements for this and what
Can u give an example with unix+sql loaderThe Oracle Utilities manual has a chapter on SQL*Loader Case Studies
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch10.htm#1656
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Looking for good pl/sql case studies/hands on exercises
Hi there,
I am new to plsql. Looking for some good pl/sql case studies/hands on exercises/small prototype project etc to learn the basic nitty-gritty.
Can anybody please help?
Many Thanks,
Avishekthis page http://itcareershift.com/blog1/2010/11/15/plsql-exercises/ contains different types of sql statements used inside pl/sql..when you say case studies do you mean examples for each and every concept of pl/sql starting from stored procedures , packages , functions, triggers , collections etc?
-
SQL Loader: Total number of record read
Hello,
When we use SQL loader to load a data file, the total number of records read is output to the SQL Loader log. Is there a way to output this number to an oracle table?
Regardsslsam01 wrote:
Thank you Hans.
Can you provide me more information about loading SQL loader log file (e.g., control file) and point me to an example of loading SQL loader log files to Oracle table?
Regards,Oh joy, oh bliss. A documentation request.
For Oracle 10g, http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/part_ldr.htm#i436326 provides a few pages (including examples called Case Studies) -
How can we tell if SQL*Loader is working on a TABLE?
We have a process that requires comparing batches with LDAP information. Instead of using an LDAP lookup tool, we get a nightly directory file, and import the two COLUMNs we want via SQL*Loader (REPLACE) into an IOT. Out of three cases, two just check the first COLUMN, and the third needs the second COLUMN as well.
We did not think of using External TABLEs, because we cannot store files on the DB server itself.
The question arises, what to do while the file is being imported. The file is just under 300M, so it takes a minute or so to replace all the data. We found SQL*Loader waits until a transaction is finished before starting, but a query against the TABLE only waits while it is actually importing the data. At the beginning of SQL*Loader's process, however, a query against the TABLE returns no rows.
The solution we are trying right now is, to have the process that starts SQL*Loader flip a flag in another TABLE denoting that it is unavailable. When it is done, it flips it back, and notes the date. Then, the process that queries the information, exits if the flag is currently 'N'.
The problem, is, what if SQL*Loader starts inbetween the check of the flag, and the query against the TABLE. How do we guarantee that it is still not being imported.
I can think of three solutions:
1) LOCK the ldap information TABLE before checking the flag.
2) LOCK the record that the process starting SQL*Loader flips.
3) Add a clause to the query against the TABLE checks that there are records in the TABLE (AND EXISTS(SELECT * FROM ldap_information).
The problem with 3) is that the process has already tagged the batches (via a COLUMN). It could, technically reset them afterwards, but that seems a bit backwards.Just out of curiosity, are you aware that Oracle supplies a DBMS_LDAP package for pulling information from LDAP sources? It would obviously be relatively easy to have a single transaction that deletes the existing data, loads the new data via DBMS_LDAP, and commits, which would get around the problem you're having with SQL*Loader truncating the table.
You could also have SQL*Loader load the data into a staging table and then have a second process either MERGE the changes from the staging table into the real table (again in a transactionally consistent manner) or just delete and insert the data.
Justin -
Decode Not working in sql loader
I had a requirement of loading flatfile into staging table using SQL Loader, One of the columns in the the Flat file is having values FALSE or TRUE and my requirement is that I load 0 for FALSE and 1 for TRUE which can be achieved by simple DECODE function...I did use decode and tried to load several times but did not work. What might be the problem
LOAD DATA
INFILE 'sql_4ODS.txt'
BADFILE 'SQL_4ODS.badtxt'
APPEND
INTO TABLE members
FIELDS TERMINATED BY "|"
( Person_ID,
FNAME,
LNAME,
Contact,
status "decode(:status, 'TRUE', '1','FALSE','0')"
I did try putting a trim as well as SUBSTR but did not work....the cloumn just doent get any values in the output (just null or say free space)
Any help would be great.....Hello user8937215.
Please provide a create table statement and a sample of data file contents. I would expect DECODE or CASE to work based on the information provided.
Cheers,
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. -
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 -
How can I load this XML with sql loader ?
Hi,
Im try to load a XML file into a XML table:
Create table TEST of XMLTYPE;
XML file is something like this:
<!DOCTYPE list SYSTEM "myfile.dtd">
<list>
<item id = 1> lot of tags an info here </item>
<item id = 9000> lot of tags an info here </item>
</list>
I dont know how to exactly create an appropriate control file to my XML. All examples I saw in documentation are similar to this one:
this is an example control file
LOAD DATA
INFILE *
INTO TABLE test
APPEND
XMLTYPE (xmldata)
FIELDS
I dont know how to complete this control file. Can anyone help me ?
thank you!
Message was edited by:
pollopoleaWell I found this working code
LOAD DATA
INFILE *
INTO TABLE test APPEND
xmltype(xmldata)
FIELDS
ext_fname filler char(30),
xmldata LOBFILE (ext_fname) TERMINATED BY EOF
BEGINDATA
mifile.xml
mifile2.xml
mifile3.xml
the main diference I found is that when i use:
Insert into test values (XMLType(bfilename('XMLDIR', 'swd_uC000025127.xml'),nls_charset_id('AL32UTF8')));
tag <!DOCTYPE list SYSTEM "myfile.dtd"> is expanded
(I explain at DTD insertion and errors with long DTD entities
Now using sql loader the tag is not modified.
I dont know if is there any difference, between each case. did I lost performance?
Message was edited by:
pollopolea -
Error while loading data using SQL*Loader
Hi All,
I am now in process of loading data from MS SQL to Oracle Database.
I am getting the data in excel format and i will convert them into csv.
Upto converting everything is working fine.
In MS SQL, table columns are case sensitive.
So i created those tables in oracle db as same.
There is one column "MaxNumber" which is of type float(49).
The column is case sensitive.
in the control file first i given as
"MaxNumber" "TO_NUMBER(:MaxNumber,'99,999.99')"
After executing the SQL*Loader i am getting the error
SQL*Loader-466: Column MAXNUMBER does not exist in table TABLEONE.
I changed the control file entry as
"MaxNumber" "TO_NUMBER(:"MaxNumber",'99,999.99')"
After the execution i got the error
SQL*Loader-350: Syntax error at line 13.
Expecting "," or ")", found "MaxDiscount".
"MaxNumber" "TO_NUMBER(:"MaxNumber",'99,999.99')"
Please Guide me in this issue.
Regards
Salih KMWhat I'm saying is, verify the column name. Dont post if not possible.
Example follows, with one table intentionally "hidden".
SQL> create table "tEsT" ("MaxNumber" float, "MaxnumbeR" number);
SQL> select table_name,column_name from user_tab_columns where table_name like 't%';
TABLE_NAME COLUMN_NAME
tEsT MaxNumber
tEsT MaxnumbeR
teST iD
teST MaxNumberHth,
Fredrik -
Hi,
Am using SQL Loader to insert rows in a table.
I have 5 cols in table A. But the data is not present in all cols always.
Have used TRAILING NULLCOLS but with no help.. few rows are inserted and for many others it throws "ORA-01841: (full) year must be between -4713 and +9999, and not be 0" error
(because the value is null in that particular column position)
How do I handle such cases.Please help asap.
FYI -
CONTROL FILE
load data
infile '/home/krkanth/test_spam_20070513.dat'
BADFILE 'sample.bad'
DISCARDFILE 'sample.dsc'
into table spam_rule_stats
fields terminated by "\t"
optionally enclosed by '"'
TRAILING NULLCOLS
(MAIL_DATE date 'yyyymmdd hh24:mi:ss', METRIC_TYPE, HEURISTIC_TYPE, HEURISTIC_VALUE, REJECTION_COUNT,
RULE_START_DATE DATE 'yyyymmdd hh24:mi:ss',
RULE_END_DATE date 'yyyymmdd hh24:mi:ss',SOURCE)
Am getting error Rejected - Error on table SPAM_RULE_STATS, column RULE_END_DATE.
ORA-01841: (full) year must be between -4713 and +9999, and not be 0
SAMPLE DATA
20070513 RULE SENDER [email protected] 534 20070214 22:02:56
SnA_ALERTS
20070513 RULE SENDER [email protected] 6 20070503 21:19:36 200
70518 21:19:36 RULE_EXTENSIONS
20070513 RULE SENDER [email protected] 519 20061105 05:40:44 SnA
_ALERTS
20070513 RULE SENDER [email protected] 332 20070509 02:44:51 20070524 02
:44:51 JASD_HP_AUTOREJECT
20070513 RULE SENDER [email protected] 928 20070512 14:49:14 20070527 14:49:14 JAS
D_HP_AUTOREJECT
20070513 RULE SENDER [email protected] 19875 20070507 22:30:01 20070522 22
:30:01 RULE_EXTENSIONS
20070513 RULE SENDER [email protected] 3 20070509 09:08:38 20070524 09:08:38
JASD_HP_AUTOREJECT
20070513 RULE SENDER [email protected] 10 20070503 21:19:36 200
70518 21:19:36 RULE_EXTENSIONS
20070513 RULE SENDER [email protected] 4 20070506 04:39:48 20070521 04
:39:48 JASD_HP_AUTOREJECT
Thanks.not sure if this will work but you may want to give it a try:
change from:
(MAIL_DATE date 'yyyymmdd hh24:mi:ss'
to:
(MAIL_DATE date 'yyyymmdd'since the first data on your file does not have the timestamps -
I'm setting up a sql*loader script and trying to use the decode function as referred to in 'Applying SQL Operators to Fields' I'm getting an error message ' Token longer than max allowable length of 258 chars'. Is there a limit to the size of the decode statement within sql*loader - or is it better to use a table trigger to handle this on insert? I ran the decode statement as a select through SQL*Plus and it works okay there. Oracle 8.0 Utilities shows example of decode in Ch. 5, but Oracle 9i Utilities Ch. 6 does not. Has anyone done this and what's the impact on performance of the load if I can get it to work? See my example below:
LOAD DATA
INFILE 'e2e_prod_cust_profile.csv'
APPEND
INTO TABLE APPS.RA_CUSTOMER_PROFILES_INTERFACE
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
(Insert_update_flag CHAR(1),
Orig_system_customer_ref CHAR(240),
customer_profile_class_name CHAR(30) NULLIF customer_profile_class=BLANKS
"decode(customer_profile_class_name,
'NORTHLAND Default','(MIA) Default',
'NORTHLAND Non Consolidated','(MIA) Non Cons',
'NORTHLAND Consolidated A','(MIA) Cons A',
'NORTHLAND Consolidated B','(MIA) Cons B',
'NORTHLAND Consolidated C','(MIA) Cons C',
'NORTHLAND Consolidated D','(MIA) Cons D',
'NORTHLAND Cons A NonZS','(MIA) Cons A NonZS',
'NORTHLAND Cons B NonZS','(MIA) Cons B NonZS',
'NORTHLAND Cons C NonZS','(MIA) Cons C NonZS',
'NORTHLAND Cons D NonZS','(MIA) Cons D NonZS',
'NORTHLAND International Billing','(MIA) International Billing',
customer_profile_class_name)",
credit_hold CHAR(1),
overall_credit_limit INTERGER EXTERNAL,
"e2e_cust_profile.ctl" 49 lines, 1855 characters
SQL*Loader-350: Syntax error at line 15.
Token longer than max allowable length of 258 chars
'NORTHLAND Consolidated D','(MIA) Cons D',
^Your controlfile is incomplete and has some typos, but you could try something like:
create or replace function decode_profile_class_name (p_longname IN VARCHAR2)
return VARCHAR2
is
begin
CASE p_longname
WHEN 'NORTHLAND Default' THEN RETURN '(MIA) Default';
WHEN 'NORTHLAND Non Consolidated' THEN RETURN '(MIA) Non Cons';
WHEN 'NORTHLAND Consolidated A' THEN RETURN '(MIA) Cons A';
WHEN 'NORTHLAND Consolidated B' THEN RETURN '(MIA) Cons B';
WHEN 'NORTHLAND Consolidated C' THEN RETURN '(MIA) Cons C';
WHEN 'NORTHLAND Consolidated D' THEN RETURN '(MIA) Cons D';
WHEN 'NORTHLAND Cons A NonZS' THEN RETURN '(MIA) Cons A NonZS';
WHEN 'NORTHLAND Cons B NonZS' THEN RETURN '(MIA) Cons B NonZS';
WHEN 'NORTHLAND Cons C NonZS' THEN RETURN '(MIA) Cons C NonZS';
WHEN 'NORTHLAND Cons D NonZS' THEN RETURN '(MIA) Cons D NonZS';
WHEN 'NORTHLAND International Billing' THEN RETURN '(MIA) International Billing';
ELSE RETURN p_longname;
END CASE;
end;
LOAD DATA
INFILE 'e2e_prod_cust_profile.csv'
APPEND
INTO TABLE APPS.RA_CUSTOMER_PROFILES_INTERFACE
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
Insert_update_flag CHAR(1),
Orig_system_customer_ref CHAR(240),
customer_profile_class_name CHAR(30) NULLIF customer_profile_class=BLANKS "decode_profile_class_name(:customer_profile_class_name)"
credit_hold CHAR(1),
overall_credit_limit INTEGER EXTERNAL -
SQL*Loader and HTMLDB_APPLICATION_FILES
Hello!
Can I use SQL*Loader for loading data from file stored in HTMLDB_APPLICATION_FILES as blob to tables in database? Files are always CSV in my case.
Best regards,
TomHello Maxim!
Of course files are stored in HTMLDB_APPLICATION_FILES as blobs and of course I can do 'select blob_content from htmldb.....' - BUT I have to get text from this blob, and copy certain words from this blob, NOT the blob itself.
Example: I have a file.csv. I upload it to HTMLDB_APPLICATION_FILES so it is stored there as a blob. Now I want copy data delimited by ';'(for example) to table in database.
Any ideas?
Best regards,
Tom -
i am trying to load binary data using SQL*Loader. given a table created a la:
create table oofa ( data raw(500) );
and a control file (running on x86 linux):
LOAD DATA
INFILE *
APPEND INTO TABLE OOFA
( DATA VARRAW(500) )
BEGINDATA
X'05003132333435'
i get an error "variable length field exceeds maximum length" and no record loaded. i tried using X'00053132333435' just in case i'd muffed the big- little-endian stuff, but the same thing happens.
anyone successfully loaded binary data as above? if so, how'd you do it?
also, is there a way to make SQL*Loader more verbose?
thanks.i am trying to load binary data using SQL*Loader. given a table created a la:
create table oofa ( data raw(500) );
and a control file (running on x86 linux):
LOAD DATA
INFILE *
APPEND INTO TABLE OOFA
( DATA VARRAW(500) )
BEGINDATA
X'05003132333435'
i get an error "variable length field exceeds maximum length" and no record loaded. i tried using X'00053132333435' just in case i'd muffed the big- little-endian stuff, but the same thing happens.
anyone successfully loaded binary data as above? if so, how'd you do it?
also, is there a way to make SQL*Loader more verbose?
thanks. -
I'm using SQL Loader to import data from a file, but I'm having trouble with numeric types.
I'm trying to import an amount into a table. The amount field in the table is of type NUMBER(11,2).
I suppose that Double is the correct type to use in the ctl-file definition. How do I use this type?
I've tried to use:
AMOUNT DOUBLE TERMINATED BY ";" NULLIF BELOP=BLANKS,
but the I get an error message because I'm using terminated by
I've also tried using:
BELOP DOUBLE NULLIF BELOP=BLANKS,
but then it isn't able to find the delimiter.
I've tried to search the net for examples using Double, but I haven't found anything of current interest yet.
So, my question is:
1. Is Double the correct type to use in this case?
2. How do I use Double?I hardly ever specify a data type in a SQL*Loader control file; I just let Oracle handle it. If it is not the correct datatype for the column Oracle will reject it anyway. The main exception is DATE columns, but even then only because most flat files don't have dates in the default format so the data type specifcation is essentially just a format mask.
Regards,
Steve Rooney -
SQL LOADER and SHELL SCRIPT ISSUE
Hello Guys,
I know this not the right forum but i am not sure where i should post this.
Pelase help
I am running a shell script which is giving me error
Username:SQL*Loader-128: unable to begin a session
ORA-01017: invalid username/password; logon denied
SQL*Loader: Release 10.2.0.4.0 - Production on Thu Nov 19 13:02:04 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Nov 19 13:02:06 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Enter user-name:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
0 rows updated.
Commit complete.
SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition
SQL> SQL> Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options Thu Nov 19 13:02:06 EST 2009In shell script i have used the same username and passwd which i am using from command line
the shell script is calling sql loader to load file
and for that also the username and passwd is same.
i am able to run sqlldr command from command line dont knw why here its giving error
here is my shell script
set -a
. $HOME/.edw.env
. $admlib/checklib.sh
LOGDIR=$admsrc/sigma6/ppadala/copg
LOGFILE=${LOGDIR}/log/test`date '+%m%d'`.xtr
DB_USER=copg
DB_PWD=copg
set +a
cd $LOGDIR
if test ! -f $admsrc/sigma6/ppadala/copg/DM_Daily_EFolderCloseCancel_Report_11192009.txt
then
echo "Error: DM_Daily_EFolderCloseCancel_Report_11192009.txt does not exist and/or is not a regular file." >> ${LOGFILE}
exit 1
fi
echo 'End of Checking for the existence of the file - Successful'>> ${LOGFILE}
sqlldr control=$admsrc/sigma6/ppadala/copg/Close_Cancle.ctl log=$admsrc/sigma6/ppadala/copg/Close_cancle.log
userid=${DB_USER}/${DB_PWD} silent=\(HEADER,FEEDBACK,DISCARDS\)>> ${LOGFILE} 2>&1
case $? in 0) :;;1|3) echo "Error: SQL Loader" >> ${LOGFILE}
exit 1;;
esac
sqlplus << EOD
${DB_USER}/${DB_PWD}
@Close_Cancle.sql
EOD
if [ $? -ne 0 ]
then
echo "Error: SQL Plus for script Processing" >> ${LOGFILE}
echo "Resi Unit Scheduling Report Refresh failed" >> ${LOGFILE}
fi
) > ${LOGFILE} 2>&1
echo `date` >> ${LOGFILE}
if [ -f ${LOGFILE} ]
then
mail -s "Resi Unit Scheduling" "[email protected]" < ${LOGFILE}
sleep 3
`ck_error ${LOGFILE}`
fiplease help guys
thanksThanks for the reply
In Close_cancle.log also its the same msg which i posted.
logon denied..............
and this is the log file contents when i do set - X on
+ cd /u2144009/src/sigma6/ppadala/copg
+ test ! -f
+ /u2144009/src/sigma6/ppadala/copg/DM_Daily_EFolderCloseCancel_Report_1
+ 1192009.txt echo End of Checking for the existence of the file -
+ Successful
+ 1>> /u2144009/src/sigma6/ppadala/copg/log/test1119.xtr
+ sqlldr control=/u2144009/src/sigma6/ppadala/copg/Close_Cancle.ctl
+ log=/u2144009/src/sigma6/ppadala/copg/Close_cancle.log
Username:SQL*Loader-128: unable to begin a session
ORA-01017: invalid username/password; logon denied
SQL*Loader: Release 10.2.0.4.0 - Production on Thu Nov 19 17:32:17 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
+ userid=copg/copg silent=(HEADER,FEEDBACK,DISCARDS)
+ 1>> /u2144009/src/sigma6/ppadala/copg/log/test1119.xtr 2>& 1
+ :
+ sqlplus
+ 0<<
copg/copg
@Close_Cancle.sql
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Nov 19 17:32:58 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Enter user-name:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
0 rows updated.
Commit complete.
SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition
SQL> SQL> Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
+ [ 0 -ne 0 ]
Thu Nov 19 17:32:59 EST 2009Edited by: user10647455 on Nov 19, 2009 2:35 PM
Maybe you are looking for
-
Error while Configuring ALBPM in weblogic
HI, I am trying to configure ALBPM 6 in weblogic 10 on RHEL 4 (IA64) OS. I am getting errors while deploying PAPI WS ear file. Following is the error shown on server logs <Error occurred while setting document root for "weblogic.servlet.internal.WebA
-
Authentication in Sender SOAP Adapter
Hi experts, We have a scenario were EP sends SOAP Message to XI. We have created the WSDL from XI and it has been consumed by EP. When EP tries to send the SOAP Request to XI we get UnAuthorized Exception. Below is the Exception #1.5#001372E937FC0067
-
Setting oracle apps appscontext (user/organization/responsibility) in ODI
Hi All - Is there anyway we can setup appscontext (used in oracle applications/ebs suite) (user id/organization id/responsibility) before executing any stored procedures from ODI. This can be achieved in BPEL. We can set these as properties for oracl
-
Idocs are not prosessing even after ALE settings in SAP XI and ECC
Hi Experts!, <b>I have a system which has SAP ECC and SAP XI 3.0 installed with 2 instances on the same operating system. ( In MMC you can see ECC and XI under the same SAP console tree ). I have made many times all possible ALE set
-
Undefined number of Ref cursor,
I im migrating from sqlserver to oracle and I have some procedure that could return from 1 to 10 cursor depending on the parameters. What is the best way to do that?