Sql loader using position and functions
Hi all, i need help loading some data in my table using sql loader. consider the following
CREATE TABLE er
a1 NUMBER,
a2 number,
a3 VARCHAR2(100),
a4 VARCHAR2(100),
a5 VARCHAR2(100),
a6 VARCHAR2(100),
a7 VARCHAR2(100),
a8 VARCHAR2(100)
OPTIONS (BINDSIZE=20548000, READSIZE=20548000, STREAMSIZE=20548000, DATE_CACHE=25000, SKIP=0)
LOAD DATA
INTO TABLE er
APPEND
TRAILING NULLCOLS
a1 POSITION(0001:0021) ,
a2 POSITION(0022:0042) "DECODE(SUBSTR(:a2,1,3),'***',NULL,:a2)" ,
a3 POSITION(0043:0053) ,
a4 POSITION(0054:0064) ,
a5 POSITION(0065:0075) ,
a6 POSITION(0076:0086) ,
a7 POSITION(0087:0093) "DECODE(SUBSTR(:a7,1,3),'***',NULL,:a7)"
BEGIN
0.00 ******************** X X X *X ****
END;if you look at the data, some fields have a lot of * and some has af few such as ****. i want to load this data into a table and when a field contain all * as a value, i want to set it to null. if a field contain a * and alphanumeric then that value should be load as it is.
in the example above, ******************** should be set to null and **** should also be set to null. notice that there is a field with X. since this field contain alpha numeric, it should be loaded into the table as is. the only time field should be set to null is when the value contain all .
somebody in this forum suggest using decode but it looks like it is not working and i get error when it reads second field and try to insert into a2 number column.
is there any way to use regular expression to find out if a field contain all *. also i want to trim each field since they might contain leading spaces.
can some one help with this using the sqlloader ctl and data above?
You can include regular expression in you SQL*Loader control file.
An example can be found here:
http://www.morganslibrary.org/reference/sqlloader.html
Demos 7 and 8 using the UPPER and DECODE functions to illustrate how to do it.
Similar Messages
-
SQL Loader: using your own function
Hi,
Is it possible to include your own function in sql*loader? Would this be a correct syntax?
LOAD DATA
APPEND
INTO TABLE MY_TABLE
IDE "my_seq.nextval"
CLIENT_NBR POSITION (1:10) CHAR
CLIENT_TYP POSITION (11:12) "MY_PACKAGE.MY_FUNCTION(:CLIENT_TYP)"
)So the value of the data ( position 11:12) needs te be processed first by the function. The result of the function needs to be stored in the CLIENT_TYP column.
Thank you
Message was edited by:
Ratjeuhstill yes/yes after the edit?Yes :)
-
SQL LOADER , EXTERNAL TABLE and ODBS DATA SOURCE
hello
Can any body help loading data from dbase file .dbt to an oracle 10g table.
I tried last day with SQL LOADER, EXTERNAL table , and ODBC data source.
Why all of these utilities still failing to solve my problem ?
Is there an efficient way to reach this goal ?
Thanks in advanceexport the dbase data file to text file,
then you have choice of using either sql loader or external table option to use.
regards -
To use SubRoutines and function modules and include
Hellow Friends ,
Can any body suggest me at waht situations we have to use SubRoutines and function modules and include in an abap report and also i need the standards in an abap program.Hi Rajesh,
You use create subroutines within your programs for those block of codes which are used often within the scope of the development. Function modules are like global subroutines , hence any number programs which might want to use the functionality within the function module can do so.
Creating includes is a good programming prctise, e.g. one for data declerations , one for subroutines, so that it makes the code more reader friendly and also helps in modularizing the program. Also once you put a subroutine in an include, you can use the same subroutine in other programs by referring to the include with the INCLUDE statement in your other programs.
Hence basically they are used for :
1. Reusability
2. Modularization of code (make it more readable)
Hope this is of some help.
Regards,
Aditya -
Spry Horizontal Menu causing site not to load using Firefox and Maverick OSX 10.9.2
Why does Spry Horizontal Menu cause site not to load using Firefox and Maverick OSX 10.9.2?
Your code is terribly malformed.
There are multiple body tags & erroneous tags that overlap your <head> and other content tags. Get those fixed first.
And you also have more than 1 doctype definition in the wrong place.
If my assumption is correct, I think each include file you're using has its own doctype, body, html & head definitions causing final PHP to render all these on your output page.
Run your site through W3 validator like Jon suggested earlier: [Invalid] Markup Validation of http://www.ambppct.org/ - W3C Markup Validator
Fix those and you should be good. -
SQL Loader: specify position for pipe separated file
Hi,
I have a problem with sql loader. i need to load 5 columns in a table and my file only contains 3 fields (pipe separated file) i need to add a sequenced id and a loading date. When i try to run the below, the sequence and the sysdate is populated correctly, but column3 is inserted into column1. If i add my file two more null columns, then it works properly:
||column1|column2|column3
also if i put my variables in the end it also works, but i cannot restructure the table so this solution doesnt work. Do u have any idea how to specify positions in pipe separated files? i should load file in the below format:
column1|column2|column3
it onlz works properly if i add the two pipe in the beginning
my control file:
LOAD DATA
INFILE 'test201001.csv'
APPEND
INTO TABLE test_load
FIELDS TERMINATED BY '|'
id "seq.nextval",
sys_creation_date "sysdate",
column_1,
column_2,
column_3
Thanx your help in advance
Edited by: user9013593 on 2010.01.19. 6:18
Edited by: user9013593 on 2010.01.19. 6:19user9013593 wrote:
Hi,
I have a problem with sql loader. i need to load 5 columns in a table and my file only contains 3 fields (pipe separated file) i need to add a sequenced id and a loading date. When i try to run the below, the sequence and the sysdate is populated correctly, but column3 is inserted into column1. If i add my file two more null columns, then it works properly:I hope someone provides a better solution below, but since no one has yet ...
Can you load the data "as is" into a work table, then use a PL/SQL program to process the work table correctly according to the data you have? -
SQL Load Queries - Trailer and Header record
I have a data file which comes with a header and a Trailer record.
We are using SQL load to load it.
Is a way to ignore the header and the trailer records.
Any help around this is highly appreciated.user532091 wrote:
Is a way to ignore the header and the trailer records.Assuming number of records in header is known, use SQL*Loader parameter
SKIP nwhere n is number of records in your header. Trailer is a different story. There is nothing built-in to handle trailer, so best solution is to remove trailer on OS level. Other than that, you can try SQL*Loader clause WHEN. For example, if triler row is something like:
TOTAL SIZE nnnnnnyou can use:
WHEN position(1,10) != 'TOTAL SIZE'
obviously, assuming non-trailer records can't start with TOTAL SIZE.
SY. -
SQL Loader ISSUE- when invoking function in a package - in Direct Path- SPK
This is the loader file a.ctl
load data
append
into table emp
when eno='4'
(eno number,
ename varchar2(20))
when (1)<>'4'
into table detpt
(deptno number,
deplogid "Log.get_logid('logid')"
Note: the deptlogid field is not null column.
The par fie is as follows
rows=1000
errors=0
direct=true
control=a.ctl
when i am running this file i am getting error when i am invoking the package Log.get_logid('logid')" in direct mode. It returns null value when it is used in control file.
1) if i am running this function in sql prompt like
select Log.get_logid('logid') from dual
i am getting result as 121.
2) what is the problem when the same function is used in Sql loader in direct mode.
3) is there any restriction to use the function in sql loader?
4) whether to use the function in sql loader is applicable for direct mode or conventional mode.
5) when i am running in conventional mode it is working fine . what is the reason??
I am running the loader from dos prompt like
c:> sqlldr scott/tiger@dev parfile=abc.par
Oracle 9i is the version for the loader.
Please help me out to solve the issueThis is the loader file a.ctl
load data
append
into table emp
when eno='4'
(eno number,
ename varchar2(20))
when (1)<>'4'
into table detpt
(deptno number,
deplogid "Log.get_logid('logid')"
Note: the deptlogid field is not null column.
The par fie is as follows
rows=1000
errors=0
direct=true
control=a.ctl
when i am running this file i am getting error when i am invoking the package Log.get_logid('logid')" in direct mode. It returns null value when it is used in control file.
1) if i am running this function in sql prompt like
select Log.get_logid('logid') from dual
i am getting result as 121.
2) what is the problem when the same function is used in Sql loader in direct mode.
3) is there any restriction to use the function in sql loader?
4) whether to use the function in sql loader is applicable for direct mode or conventional mode.
5) when i am running in conventional mode it is working fine . what is the reason??
I am running the loader from dos prompt like
c:> sqlldr scott/tiger@dev parfile=abc.par
Oracle 9i is the version for the loader.
Please help me out to solve the issue -
SQL LOADER USING EXTRNAL TABLE
I have .csv file having around 70k records
in which fields are delimited by tab and
enclosed in double quotes but double quotes may be part of data.
and records are delimited by newline.
After creating external table when I issue SELECT statment
select count(*) from proTxt ;
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04020: found record longer than buffer size supported, 524288, in C:\Program Files\Apache Software Foundation\Tomcat
5.5\webapps\tmTest\upload\product\Data\output09_1.txt
ORA-06512: at "SYS.ORACLE_LOADER", line 19
Following is the create table statement:
CREATE TABLE proTxt (PRO_CODE VARCHAR2(30),
PRO_DESC VARCHAR2(500),
PUR_PRICE VARCHAR2(20),
SALE_PRICE VARCHAR2(20)
ORGANIZATION EXTERNAL
TYPE ORACLE_LOADER
DEFAULT DIRECTORY DAT_DIR
ACCESS PARAMETERS
records delimited by NEWLINE SKIP 1
badfile BAD_DIR:'proTxt%a_%p.bad'
logfile LOG_DIR:'proTxt%a_%p.log'
fields terminated by X'9' OPTIONALLY ENCLOSED BY '"' AND '"'
missing field values are null
( PRO_CODE,
PRO_DESC,
PUR_PRICE,
SALE_PRICE
LOCATION ('output09_1.txt')
PARALLEL 4
REJECT LIMIT UNLIMITED;
record size is not large.
Log file :
LOG file opened at 12/05/12 20:25:40
KUP-04020: found record longer than buffer size supported, 524288, in C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\tmTest\upload\product\Data\output09_1.txt
KUP-04053: record number 2
data file
PRO_CODE PRO_DESC PUR_PRICE SALE_PRICE
"0000336658" "BEARING" "Rs.0.00" "Rs.0.00"
"0000790028" "SEAL" "Rs.76.00" "Rs.90.00"
"0000790118" "SPRING" "Rs.24.00" "Rs.28.00"
"0000792284" "F.BRK.CAL.W/O PA" "Rs.2,627.00" "Rs.3,100.00"
"0000792285" "F.BRK.CAL.W/O PA" "Rs.2,627.00" "Rs.3,100.00"
"0005896322" "PISTON, RING" "Rs.5,000.00" "Rs.5,900.00"
"0005896323" "PISTONS, RINGS AND P" "Rs.17,755.00" "Rs.20,951.00"
"0005896559" "PISTON, RINGS AND PI" "Rs.5,000.00" "Rs.5,900.00"Hi,
when i used
records delimited by *'\r'*
then 4226 record written to table
but enclosed charcter double quotes["] were also written and
there is some space between charcters
" 0 0 0 0 3 3 6 6 5 8 " " B E A R I N G " " R s . 0 . 0 0 " " R s . 0 . 0 0 "
" 0 0 0 0 8 5 6 7 0 7 " " P L U G " " R s . 0 . 0 0 " " R s . 0 . 0 0 "
Definitely this is "External Table with Flatfile Moved Across Platforms" issue.
when I opened .csv file in excel and saved as tab delimited it works fine.
But I do not know plateform of data file.
How to know the CHARACTERSET of data file
Log file
Field Definitions for table PROTXT
Record format DELIMITED, delimited by
Data in file has same endianness as the platform
Rows with all null fields are accepted
Fields in Data Source:
PRO_CODE CHAR (255)
Terminated by "9"
Enclosed by """ and """
Trim whitespace same as SQL Loader
PRO_DESC CHAR (255)
Terminated by "9"
Enclosed by """ and """
Trim whitespace same as SQL Loader
PUR_PRICE CHAR (255)
Terminated by "9"
Enclosed by """ and """
Trim whitespace same as SQL Loader
SALE_PRICE CHAR (255)
Terminated by "9"
Enclosed by """ and """
Trim whitespace same as SQL Loader -
SQL Loader, direct path and indexes on partition tables
Hi,
I have a big partitioned table and I have two indexes on it.
When I use SQL Loader to upload data to my table with using OPTIONS (DIRECT=TRUE) UNRECOVERABLE , then it takes almost half hour to load just one record!!
When I remove OPTIONS (DIRECT=TRUE), then it takes just two seconds to upload the same one record.
Am I missing anything? Can I use direct path load on indexed partitioned tables and have reasonable load time ?
An scheduled external job loads almost 100,000 records into this table every hour and I am trying to make the sql*loader performance it as fast as possible.
Any help would be appreciated,
AlanHi Alan,
How big is this table and what sort of indexes are they?
An index update using SQL*Loader unrecoverable direct path load is achieved by an isolated sort followed by a nologging merge of the old index and the new mini-index into a new index segment (this according to seminar notes by Jonathan Lewis). This will conceivably take a long time for a large table / large index.
Performance improvements? Are you loading all records into a new partition?
Cheers,
Colin -
Executing sqlldr (sql loader) from java and returning the error code
I'm wandering do sqlldr return any error code whenever it hit error while running in java.
For example, if i run in command prompt using the command below,
C:\ >sqlldr uid/pwd data=abc.dat control=abc.txt
It might give me some indicator that error occurs such as
SQL*Loader-601: For INSERT option, table must be empty. Error on table CURRENCY
or
SQL*Loader-500: Unable to open file (abc.txt)
SQL*Loader-553: file not found
SQL*Loader-509: System error: The system cannot find the file specified.
But when i run in java using the code below,
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("sqlldr uid/pwd data=abc.dat control=abc.txt");
int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
it will only give me the same exitValue of 1(i presume its error) / 0 (i presume no error) instead of the details of the error.
How can i get the exact error code/message if i were to execute it using java?
Any solution?mg,
I don't think user576271 wants the exit code, I think [s]he wants the error message.
But wouldn't error messages from SQL*Loader be sent to the stderr stream, and not the stdout stream?
In which case user576271 would need method "getErrorStream()" of class java.lang.Process, no?
Good Luck,
Avi. -
SQL Loader Direct Path and Nulls
I'm using Sql Loader with Direct Path and I cannot find a way to remove trailing spaces in varchar2 fields.
I'm trying to avoid updating the tables after loading.
Any ideas?Hi Alan,
How big is this table and what sort of indexes are they?
An index update using SQL*Loader unrecoverable direct path load is achieved by an isolated sort followed by a nologging merge of the old index and the new mini-index into a new index segment (this according to seminar notes by Jonathan Lewis). This will conceivably take a long time for a large table / large index.
Performance improvements? Are you loading all records into a new partition?
Cheers,
Colin -
Calling SQL Loader using HOST command from Developer Forms 4.5
I want to execute a set of code from D2K Forms 4.5 which has interfface with Client - OS ( In my case Windows NT/XP). I want to execute SQL Loader from Forms using Host Command and then after completion of that process, I want to do next transcations ( depending upond success of HOST/SQL Loader).
How to achive this?
I tried writing code like this ...
l_vc_command := 'sqlldr73'
||' USERID='||l_vc_username||'/'||l_vc_password||'@'||l_vc_connect_string
||' CONTROL='||l_vc_filepath||'Upload.ctl'
||' DATA='||LTRIM(RTRIM(l_vc_fileloc))
||' LOG='||l_vc_filepath|| l_vc_log_file || '_' || l_dt_sysdate_str ||'.log'
||' BAD='||l_vc_filepath|| l_vc_bad_file || '_' || l_dt_sysdate_str ||'.bad'
||' DISCARD='||l_vc_filepath|| l_vc_discard_file || '_' || l_dt_sysdate_str ||'.dsc';
HOST(l_vc_command,NO_PROMPT);
After this command i want to do some other code execution. so even if it fails or success, next code is executed. How to control this?
Please help..
Regards,
MilindForms6i running on W2000, Rdbms 8.1.7
in Forms I added a button TEST,
Trigger when-button-pressed : host('test.bat') ;
in directory .......\frm I added file test.bat :
REM ===============
cd /d C:\........\ldr
pause
sqlldr parfile=test.par
pause
type test.log
pause
exit
REM ================
now, pressing TEST button opens DOS window, telling me what's going on, running sqlldr, finally going back to forms
Are you using NO_PROMPT or NO_SCREEN option of HOST command ?
Had a look at Forms 4.5 manuals, there is no mentioning of (a)synchronously operation in connection with HOST command. -
Sql loader using sql statement
Hi All ,
May i know any way used sql loader refer sql statement e.g "select a from test"
import data into other table ?
if you have any sample or link , please let me know , thanks a lotIf you are using the database steps, the answer is yes. I've done it by creating a data source that uses the Microsoft Text Driver in the ODBC administrator. The Open Database step is then configured like any other ODBC database. In the .csv file, I have the first line define the column names (i.e. column1, column2) and the SQL statement I use is "SELECT * FROM junk.txt". I haven't tried anything with a WHERE clause but that should work as well.
-
wht is the way of using sqlldr in JSP script to load data Oracle DB from a csv file.
i know how we do sqlldr in cmd.
can we provide the sqlldr command to system by using jsp if yes how?SQL*Loader is a command-line utility. In theory, since Java can call out to the operating system, you could invoke SQL*Loader on the application server to load data into Oracle. It would probably be more appropriate, though, to copy the CSV to the database server and make use of an external table in the database to do the load.
Justin
Maybe you are looking for
-
Sharing music libraries across user accounts
We've got 1 Mac and 4 users with iPods. I'd like us to share music, but use our own accounts to manage our music and iPods. I've seen these articles but am still a little perplexed: Multiple iPods: http://docs.info.apple.com/article.html?artnum=30043
-
i was somewhat helped. but still i am getting problem to delete my photos that i synced last night via itunes on my pc. problem is i deleted the photos from the location on pc after getting them on my device, so i am unable to resync them, deselect a
-
Updated OSX - DVD-R's won't play now
A few weeks ago, I updated to 10.3.8, then 10.3.9, and now DVD-R's won't play anymore. The drive doesn't recognize them. These are DVD's that played fine before, in fact some of them are DVD's that I burned on this machine.
-
Syncing photos from another profile
Hi all I have an iMac and have 2 profiles. 1 is for my business where I have work photos document and also iTunes which i sync my iPhone, iPad and iPods to. The 2nd profile is solely for family photos. My main question is, how do I sync my Iphone, iP
-
activation required