Multiple CONTINUEIF statements in SQL Loader
Anyone know how to do this?
Yes. I have read the Oracle documentation on SQL Loader and use of the CONTINUEIF statement. It doesn't state what the syntax is when setting CONTINUEIF for different columns, some that may not be contiguous.
I want to say something like
CONTINUEIF THIS (10)='-' AND THIS (11)='/'
I've tried various permutations of this syntax and a few others. Nothing I've tried works.
I can get CONTINUEIF to work if I only use one instance(column) specification.
Thank You in advance for any help.
You can only use a single CONTINUEIF clause in a SQL*Loader command file. If the characters are contiguous, then you can use CONTINUEIF THIS (10-11)='-/'
Similar Messages
-
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"
) -
Extracting Multiple Logical Records through sql loader
Hello gurus,
I have few questions regarding the sql loader. I m totally new to this i have never used, this is the first time i m using
1.
How do i find the position number of the charcter or a number ? do i need to physically count the position ? is ther any specific way of counting or use textpad to do that ?
I know it sounds like silly question... but i wanted to know if there is any better way of doing it
2.
example data
1119 Smith 1120 Yvonne
1121 Albert 1130 Thomas
The following control file extracts the logical records:
INTO TABLE emp
(empno POSITION(1:4) INTEGER EXTERNAL,
ename POSITION(6:15) CHAR)
INTO TABLE emp
(empno POSITION(17:20) INTEGER EXTERNAL,
ename POSITION(21:30) CHAR)---
2. Can you please expalin me what does the "null if deptno = blanks " ?
deptno POSITION(1:2) INTEGER EXTERNAL(2)
NULLIF deptno=BLANKS,I really appriciate it ~
ThanksHi,
The NULLIF means load blanks as NULL
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_field_list.htm#sthref1129
Not sure I understand your first question. You must of course know the format of the file, TextPad could be an ok tool for determining that format for a fixed column width file.
Regards
Peter -
Creating Multiple INSERT statements with SQL
is there a way to create multiple INSERT staements with SQL .
Example scenario : This is only example but i have lot of data in the real time.
sql : Select Emplid from Table A where Emplid between 100 and 350 will retun me 50 rows . i want to insert those rows into another table.
I am looking for output like below instead of Giving output just as EMPLIDs
Insert into PS_LM_DATA ( EMPLID ) values ( 123 )
Insert into PS_LM_DATA ( EMPLID ) values ( 234 )
Insert into PS_LM_DATA ( EMPLID ) values ( 334 )
and so on....
thanks ,
KaruIf you are inserting into another table, you could use
insert into PS_LM_DATA ( EMPLID )
select Emplid from Table A where Emplid between 100 and 350Example:
SQL> insert into emp2(empno) select empno from emp;
14 rows created.
SQL> insert into emp2(empno) select empno from emp where empno between 7369 and 7788;
8 rows created. -
Can we handle multiple fields delimiter in sql*loader
Hi,
Users wants to load the data from each of their individual system. But problem is when they save the csv file, due to their sytem setup some files gettng saved with pipe (|) seperated and on some system it is saved with comma (,) sepearted fields.
Can we handle both these field seperator in control file?
Please suggest
Thanks,
RahulRahul,
I recommned you should use "|" as "," can be embedded in a text string. I guess you can pass a directive to use to deliver "|" delimited file :). If you want to handle both then you might have to write a shell script or bat to pass delimiter as an argument which will edit and replace your control file.
Regards -
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 -
Importing oracle.sql.BLOB through SQL Loader
Hello,
Currently the system we have creates .sql files and executes them. This takes a long time, so we're attempting to change to using SQL Loader. The one problem I'm having that I can't seem to fix is finding out how to imitate the behavior of this SQL statement through SQL Loader:
INSERT INTO KRSB_QRTZ_BLOB_TRIGGERS (BLOB_DATA,TRIGGER_GROUP,TRIGGER_NAME)
VALUES (oracle.sql.BLOB@515263,'KCB-Delivery','PeriodicMessageProcessingTrigger')
I tried creating a lobfile and placing the text oracle.sql.BLOB@515263 within it this way
INTO TABLE KRSB_QRTZ_BLOB_TRIGGERS
WHEN tablename = 'KRSB_QRTZ_BLOB_TRIGGERS'
FIELDS TERMINATED BY ',' ENCLOSED BY '##'
TRAILING NULLCOLS
tablename FILLER POSITION(1),
TRIGGER_NAME CHAR(80),
TRIGGER_GROUP CHAR(80),
ext_fname FILLER,
BLOB_DATA LOBFILE(ext_fname) TERMINATED BY EOF
However, as expected, it merely loaded the text "oracle.sql.BLOB@515263" into the database. So does anyone have any ideas of how to imitate that insert statement through SQL Loader? The only information I have available is the string "oracle.sql.BLOB@515263", no other files or anything to aid with actually getting the binary data.
When the .sql file is run with that insert statement in it, a 1.2kb BLOB is inserted into the database versus a 22 byte BLOB that contains nothing useful when done through SQL Loader.
AlexMy preference is DBMS_LOB.LOADFROMFILE
http://www.morganslibrary.org/reference/dbms_lob.html
did you try it? -
SQL Loader Control File use of integer(n)
Dear Gentlemen,
I have an "ascii" file where some fields are binary of 2, 4 and 8 bytes. This file has to be loaded to oracle (8.1.7) Table using SQL Loader. According to SQL Loader documentation, for this case I must use as a field type: integer(n), where in my particular environment (Intel Windows), n may be 2, 4 or 8 according to the length of the field. Although I do not need to specify for integer(4); but, for integer(2) and integer(8), I need to specify it to get the rigth values. In the case of integer(2), it can be replaced by smallint; however for integer(8), I have to specify the number (8), and this form is not accepted as a sintactically correct statement by SQL Loader. Therefore I cannot load the correct data.
Could you please give some advice?.
Best regards,
Julio Porcel.Hi!
If it's not possible to implement through control file, load your data into some temporary table and then use power of SQL to do whatever you want with them.
Regards,
Andrew Velitchko
BrainBench MVP for Developer/2000
http://www.brainbench.com -
Sql loader function attachment....
Hello all,
I have a doubt on sql loader....
Now i'm having like below tables..
TableA
empno|ename
1|A
2|B
3|C
Table B
salary|empno
10|1
12|2
14|3
My requirement is, in my data file instead of empno i'm having ename. Now, I need to right a function where if in datafile ename is A its should update 1 in that empno field.
Please guide me to achieve this...
I am new to technical... So i'm not confortable in writing...
I come to know that we can attach the function in to sql loader..
select statement in sql loader
Thanks and Regards,
MuthuBy using last update function, I modified the control file like below.
load data
infile *
into TABLE AP_SUPPLIER_SITES_INT
REPLACE
fields terminated by ","
OPTIONALLY ENCLOSED BY '"'
VENDOR_INTERFACE_ID "VDR_INF_F(':CUSTOMER_NUM','9999')",
VENDOR_SITE_INTERFACE_ID "(ap_supplier_sites_int_s.NEXTVAL)",
LAST_UPDATE_DATE "SYSDATE",
LAST_UPDATED_BY,
VENDOR_SITE_CODE,
CREATION_DATE "SYSDATE",
CREATED_BY,
PURCHASING_SITE_FLAG,
PAY_SITE_FLAG,
ADDRESS_LINE1,
ADDRESS_LINE2,
ADDRESS_LINE3,
CITY,
STATE,
ZIP,
COUNTRY,
PHONE,
FAX,
PAYMENT_METHOD_LOOKUP_CODE,
TERMS_ID,
CREATE_DEBIT_MEMO_FLAG,
HOLD_UNMATCHED_INVOICES_FLAG,
EMAIL_ADDRESS,
MATCH_OPTION,
EXCLUDE_FREIGHT_FROM_DISCOUNT,
INVOICE_CURRENCY_CODE,
PAYMENT_CURRENCY_CODE,
COUNTRY_OF_ORIGIN_CODE,
FREIGHT_TERMS_LOOKUP_CODE,
PAY_GROUP_LOOKUP_CODE,
PAY_DATE_BASIS_LOOKUP_CODE,
ALWAYS_TAKE_DISC_FLAG,
ORG_ID
begindata
1005,,SYSDATE,1132,Test MA Site_1,SYSDATE,1132,Y,Y,No#907 62nd Street ,10th Sector,KK Nagar,Chennai,TamilNadu,600078,IN,+91 44 33333333,044 40404040,CHECK,10000,Y,N,[email protected],R,Y,INR,INR,IN,TBD,STANDARD,DISCOUNT,Y,120
1005,,SYSDATE,1132,Test MA Site_2,SYSDATE,1132,Y,Y,No#907 62nd Street ,10th Sector,KK Nagar,Chennai,TamilNadu,600078,IN,+91 44 33333333,044 40404040,CHECK,10000,Y,N,[email protected],R,Y,INR,INR,IN,TBD,STANDARD,DISCOUNT,Y,120
1005,,SYSDATE,1132,Test MA Site_3,SYSDATE,1132,Y,Y,No#907 62nd Street ,10th Sector,KK Nagar,Chennai,TamilNadu,600078,IN,+91 44 33333333,044 40404040,CHECK,10000,Y,N,[email protected],R,Y,INR,INR,IN,TBD,STANDARD,DISCOUNT,Y,120
1006,,SYSDATE,1132,Test1 M Site_1,SYSDATE,1132,Y,Y,No#907 62nd Street ,10th Sector,KK Nagar,Chennai,TamilNadu,600078,IN,+91 44 33333333,044 40404040,CHECK,10000,Y,N,[email protected],R,Y,INR,INR,IN,TBD,STANDARD,DISCOUNT,Y,120
1007,,SYSDATE,1132,Test1 B Site_1,SYSDATE,1132,Y,Y,No#907 62nd Street ,10th Sector,KK Nagar,Chennai,TamilNadu,600078,IN,+91 44 33333333,044 40404040,CHECK,10000,Y,N,[email protected],R,Y,INR,INR,IN,TBD,STANDARD,DISCOUNT,Y,120
*Now I am getting different error like below. Please look that error and give me your suggestion...*
Table "AP"."AP_SUPPLIER_SITES_INT", loaded from every logical record.
Insert option in effect for this table: REPLACE
Column Name Position Len Term Encl Datatype
VENDOR_INTERFACE_ID FIRST * , O(") CHARACTER
SQL string for column : "VDR_INF_F(':CUSTOMER_NUM','9999')"
VENDOR_SITE_INTERFACE_ID NEXT * , O(") CHARACTER
SQL string for column : "(ap_supplier_sites_int_s.NEXTVAL)"
LAST_UPDATE_DATE NEXT * , O(") CHARACTER
SQL string for column : "SYSDATE"
LAST_UPDATED_BY NEXT * , O(") CHARACTER
VENDOR_SITE_CODE NEXT * , O(") CHARACTER
CREATION_DATE NEXT * , O(") CHARACTER
SQL string for column : "SYSDATE"
CREATED_BY NEXT * , O(") CHARACTER
PURCHASING_SITE_FLAG NEXT * , O(") CHARACTER
PAY_SITE_FLAG NEXT * , O(") CHARACTER
ADDRESS_LINE1 NEXT * , O(") CHARACTER
ADDRESS_LINE2 NEXT * , O(") CHARACTER
ADDRESS_LINE3 NEXT * , O(") CHARACTER
CITY NEXT * , O(") CHARACTER
STATE NEXT * , O(") CHARACTER
ZIP NEXT * , O(") CHARACTER
COUNTRY NEXT * , O(") CHARACTER
PHONE NEXT * , O(") CHARACTER
FAX NEXT * , O(") CHARACTER
PAYMENT_METHOD_LOOKUP_CODE NEXT * , O(") CHARACTER
TERMS_ID NEXT * , O(") CHARACTER
CREATE_DEBIT_MEMO_FLAG NEXT * , O(") CHARACTER
HOLD_UNMATCHED_INVOICES_FLAG NEXT * , O(") CHARACTER
EMAIL_ADDRESS NEXT * , O(") CHARACTER
MATCH_OPTION NEXT * , O(") CHARACTER
EXCLUDE_FREIGHT_FROM_DISCOUNT NEXT * , O(") CHARACTER
INVOICE_CURRENCY_CODE NEXT * , O(") CHARACTER
PAYMENT_CURRENCY_CODE NEXT * , O(") CHARACTER
COUNTRY_OF_ORIGIN_CODE NEXT * , O(") CHARACTER
FREIGHT_TERMS_LOOKUP_CODE NEXT * , O(") CHARACTER
PAY_GROUP_LOOKUP_CODE NEXT * , O(") CHARACTER
PAY_DATE_BASIS_LOOKUP_CODE NEXT * , O(") CHARACTER
ALWAYS_TAKE_DISC_FLAG NEXT * , O(") CHARACTER
ORG_ID NEXT * , O(") CHARACTER
value used for ROWS parameter changed from 64 to 30
Record 1: Rejected - Error on table "AP"."AP_SUPPLIER_SITES_INT", column VENDOR_INTERFACE_ID.
ORA-06553: PLS-306: wrong number or types of arguments in call to 'VDR_INF_F'
Record 2: Rejected - Error on table "AP"."AP_SUPPLIER_SITES_INT", column VENDOR_INTERFACE_ID.
ORA-06553: PLS-306: wrong number or types of arguments in call to 'VDR_INF_F'
Record 3: Rejected - Error on table "AP"."AP_SUPPLIER_SITES_INT", column VENDOR_INTERFACE_ID.
ORA-06553: PLS-306: wrong number or types of arguments in call to 'VDR_INF_F'
Record 4: Rejected - Error on table "AP"."AP_SUPPLIER_SITES_INT", column VENDOR_INTERFACE_ID.
ORA-06553: PLS-306: wrong number or types of arguments in call to 'VDR_INF_F'
Record 5: Rejected - Error on table "AP"."AP_SUPPLIER_SITES_INT", column VENDOR_INTERFACE_ID.
ORA-06553: PLS-306: wrong number or types of arguments in call to 'VDR_INF_F'
Thanks and Regards,
Muthu -
Critical section with Sql*Load
Hi,
I need to prevent multiple instances of a batch job from running at the same time. This is easy when the batch job is pure PL/SQL. A critical section implemented with DBMS_LOCK does the job just well.
But now I have a batch job which first uploads a file using Sql*Load, and only later calls Sql*Plus and PL/SQL.
How do I prevent multiple instances of my Sql*Load from running in parallel ? (i.e. writing into the same table).
I've heard about restricting the number of concurrent sessions in the login profile. Trouble is, I have a dozen different "types" of batch jobs, and we don't want to have a dozen different logins. Batches of different types are allowed to run in parallel, and this is even desirable.
AndrewSince sqlldr is essentially an O/S command, you will need to do the locking at the O/S level. Depending on how you call the batch jobs, you have two choices.
If the controlling script and/or the loader control file for each batch have a consistent name, then you can do something like:
#!/usr/bin/ksh
me=$$
while [ $me -ne 0 ]
do
run=`ps -ef |grep <<script_or_control_file_name>> |grep -v grep |grep -v $me`
if [ "$run" = "" ]; then
run sqlldr and
rest of batch commands
break
else
sleep or exit or whatever
fi
done
-- Any post processing requiredWe have situations where the controlling shell script, and the loader control file are automatically created by a master control program. Since the file names differ for every run, we use a structure like this:
#!/usr/bin/ksh
flagfile=batch1.flg
while [ $flagfile = $flagfile ]
do
if [ ! -f $flagfile ]; then
touch $flagfile
run sqlldr and
rest of batch commands
if [ successful ] ; then
rm $flagfile
fi
break
else
sleep or exit or whatever
fi
done
-- Any post processing requiredHTH
John -
Load multiple records in 1 table from 1 line in text file w/sql loader
hi guys,
quick question, perhaps someone can help. searched around and didn't see this question asked before, and can't find any answer in SQL Loader faqs or docs.
i know i can extract multiple logical records from a single physical record in the input file as two logical records, and then use two into tables clauses to load the data into the table. see oracle 9i sql loader control file reference chapter 5 to see what i am talking about.
but my question follows:
cust_id amount1_val amount1_qual amount2_val amount2_qual amount3_val amount3_qual
123 1500.35 TA 230.34 VZ 3045.50 TW
basically i want to use one sql loader statement to load these 3 records into 1 table. the issue for me is that i need to re-use the cust_id for all 3 records as the key, along with the qualifier code. the example in the Oracle docs only works for data where the logical records are completely separate -- no shared column values.
i'm sure this is possible, perhaps using some :cust_id type parameter for the 2nd and 3rd records, or something, but i just don't have enough knowledge/experience with sql loader to know what to do. appreciate any help.
wayneHi wayne,
I found an example on what exactly you were looking for from an SQL*Loader documentation. Please see if it of some help to you
EXAMPLE
The control file is ULCASE5.CTL.
1234 BAKER 10 9999 101
1234 JOKER 10 9999 777
2664 YOUNG 20 2893 425
5321 OTOOLE 10 9999 321
2134 FARMER 20 4555 236
2414 LITTLE 20 5634 236
6542 LEE 10 4532 102
2849 EDDS xx 4555
4532 PERKINS 10 9999 40
1244 HUNT 11 3452 665
123 DOOLITTLE 12 9940
1453 MACDONALD 25 5532
In the above datafile
Column1 - Empno
Column2 - ENAME
Column3 - Depno.
Column4 - MGR
Column5 - Proj no.
-- Loads EMP records from first 23 characters
-- Creates and loads PROJ records for each PROJNO listed
-- for each employee
LOAD DATA
INFILE 'ulcase5.dat'
BADFILE 'ulcase5.bad'
DISCARDFILE 'ulcase5.dsc'
1) REPLACE
2) INTO TABLE emp
(empno POSITION(1:4) INTEGER EXTERNAL,
ename POSITION(6:15) CHAR,
deptno POSITION(17:18) CHAR,
mgr POSITION(20:23) INTEGER EXTERNAL)
2) INTO TABLE proj
(empno POSITION(1:4) INTEGER EXTERNAL,
3) projno POSITION(25:27) INTEGER EXTERNAL) -- 1st proj
Notes:
REPLACE specifies that if there is data in the tables to be loaded (EMP and PROJ), SQL*loader should delete the data before loading new rows.
Multiple INTO clauses load two tables, EMP and PROJ. The same set of records is processed three times, using different combinations of columns each time to load table PROJ.
Regards,
Murali Mohan -
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. -
Loading multiple files with SQL Loader
Hello.
I will appreciate your recommendation about the way to load multiple files (to multiple tables) using SQL Loader with only one Control file.
file1 to load to Table1, file2 to load to Table2 etc.
How the Control file should look like?
I was looking on Web, but didn't find exactly what I need.
Thanks!Ctl File : myctl.ctl
---------- Start ---------
LOAD DATA
INFILE 'F:\sqlldr\abc1.dat'
INFILE 'F:\sqlldr\abc2.dat'
INTO TABLE hdfc1
(TRANS_DATE CHAR,
NARRATION CHAR,
VALUE_DATE CHAR,
DEBIT_AMOUNT INTEGER,
CREDIT_AMOUNT INTEGER,
CHQ_REF_NUMBER CHAR,
CLOSING_BALANCE CHAR)
INTO TABLE hdfc2
(TRANS_DATE CHAR,
NARRATION CHAR,
VALUE_DATE CHAR,
DEBIT_AMOUNT INTEGER,
CREDIT_AMOUNT INTEGER,
CHQ_REF_NUMBER CHAR,
CLOSING_BALANCE CHAR)
-----------End-----------
Sqlldr Command
sqlldr scott/tiger@dbtalk control=F:\sqlldr\myctl.ctl log=F:\sqlldr\ddl_file1.txt
Regards,
Abu -
Loading multiple tables with SQL Loader
Hi,
I want to load multiple tables from a single data file using SQL Loader.
Here's the basic idea of what I want. Let's say I have two tables, table =T1
and table T2:
SQL> desc T1;
COL1 VARCHAR2(20)
COL2 VARCHAR2(20)
SQL> desc T2;
COL1 VARCHAR2(20)
COL2 VARCHAR2(20)
COL3 VARCHAR2(20)
My data file, test.dat, looks like this:
AAA|KBA
BBR|BBCC|CCC
NNN|BBBN|NNA
I want to load the first record into T1, and the second and third record load into T2. How do I set up my control file to do that?
Thank!Tough Job
LOAD DATA
truncate
INTO table t1
when col3 = 'dummy'
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS
(col1,col2,col3 filler char nullif col3='dummy')
INTO table t2
when col3 != 'dummy'
FIELDS TERMINATED BY '|'
(col1,col2,col3 nullif col3='dummy')
This will load t2 tbl but not t1.
T1 Filler col3 is not accepting nullif. Its diff to compare columns have null using when condition. If i find something i will let you know.
Can you seperate records into 2 file. Will a UNIX command work for you which will seperate 2col and 3col record types for you. and then you can execute 2 controlfiles on it.
Thanks,
http://www.askyogesh.com -
SQL*Loader and CONTINUEIF clause
Hi,
I used SQL*Loader to load in a table some files coming from main frame environnement.
The length of the physical record is 1662 characters. For some lines of the file, the characters CR (X'0C') could appear anywhere in the position 1158 to 1165 inclusively. I just want to know how to tell to SQL*Loader to concatenate the next record by using CONTINUEIF clause.
I made a simple test. I checked only the position 1165 and it works. Here is the "ctl":
OPTIONS (ERRORS=999999)
LOAD DATA
infile 'T:\RéalDelisle\AGR.PBC1.SCOPY001.de test avec x25 aux positions 1158 a 1165.txt'
BADFILE 'D:\Sinpac\Bad\sinpac_YT.bad'
DISCARDFILE 'D:\Sinpac\Disc\sinpac_YT.dsc'
APPEND
CONTINUEIF THIS PRESERVE (1165)=X'0C'
INTO TABLE AGRMDHD1.Sinpac_YT
+(+
CODEFICHIER constant "D501.A0405",
C001_CP12 position (1:12) ,
C001_record position (1:1662),
C001_record_1157 position (1:1157),
C001_record_1166 position (1166:1662),
+ C001_Mont_subv_adm position (1644:1652) "TO_NUMBER(:c001_mont_subv_adm,'999999D99', 'NLS_NUMERIC_CHARACTERS = ''. '' ')",+
C001_Mont_subv_adm_nouv position (1654:1662) "TO_NUMBER(:c001_mont_subv_adm_nouv,'999999D99', 'NLS_NUMERIC_CHARACTERS = ''. '' ')"
+)+
But, I want to do the test for the position 1158 to 1165 (the character X'0C' could appear in one of those positions). I tried this but it didn't work (I've got a syntax error):
OPTIONS (ERRORS=999999)
LOAD DATA
infile 'T:\RéalDelisle\AGR.PBC1.SCOPY001.de test avec x25 aux positions 1158 a 1165.txt'
BADFILE 'D:\Sinpac\Bad\sinpac_YT.bad'
DISCARDFILE 'D:\Sinpac\Disc\sinpac_YT.dsc'
APPEND
CONTINUEIF THIS PRESERVE (1158)=X'0C'
CONTINUEIF THIS PRESERVE (1150)=X'0C'
CONTINUEIF THIS PRESERVE (1160)=X'0C'
CONTINUEIF THIS PRESERVE (1161)=X'0C'
CONTINUEIF THIS PRESERVE (1162)=X'0C'
CONTINUEIF THIS PRESERVE (1163)=X'0C'
CONTINUEIF THIS PRESERVE (1164)=X'0C'
CONTINUEIF THIS PRESERVE (1165)=X'0C'
INTO TABLE AGRMDHD1.Sinpac_YT
+(+
CODEFICHIER constant "D501.A0405",
C001_CP12 position (1:12) ,
C001_record position (1:1662),
C001_record_1157 position (1:1157),
C001_record_1166 position (1166:1662),
+ C001_Mont_subv_adm position (1644:1652) "TO_NUMBER(:c001_mont_subv_adm,'999999D99', 'NLS_NUMERIC_CHARACTERS = ''. '' ')",+
C001_Mont_subv_adm_nouv position (1654:1662) "TO_NUMBER(:c001_mont_subv_adm_nouv,'999999D99', 'NLS_NUMERIC_CHARACTERS = ''. '' ')"
+)+
I looked in the documentation but I found nothing about the way to do it.
Does anybody have an idea?
Thank'sIf a record contains CR (X'0C'), then is the CR (X'0C') always the last character of the record? If so, I think you'd use LAST (it's all in the Docs.).
If not, then I don't think SQL*Loader will do what you want. Instead, I think you'd need to manipulate the data before it reaches SQL*Loader. You use Windows, so what about installing CygWin? It's a winner, really, and you can then do lovely sed,vi & awk stuff on your data - and it's very fast, too.
Regards - Don Lewis
Maybe you are looking for
-
Itunes running in background or not at all
I've gone through the support site and cant find any useful answers so i was hoping someone here might have a suggestion i havent thought of. Symptoms: after loading itunes i can get one of two things to happen. 1) the computer starts loading somethi
-
I have a FCP event and project with all accompanying media saved on a harddrive. I am now attempting to open the files on another computer that also has FCP X. I cannot figure out how to get it to open.
-
LSO - WBT is showing in portal 31.12.9999
Dear All, We are facing one problem, When we are booking (WBT)course it is showing in the portal unlimited. How to control this one. Is there any possibility to change in BSP page. This booking periods in which table it will store. Please give me
-
Removal of Trovi from macbook pro
When installing Microsoft Essentials, I have unfortunately ended up with Trovi which comes up on both Chrome and Safari. How do I delete please? I run 10.9.5 on my macbook pro.
-
Exporting video as frames?
I would like to export a video as a series of frames (aka separate still image files) in order to draw over them in Flash to create an animation. I have Final Cut Pro 7 and I have access to all Adobe software. Please help as I really cannot find this