Using sql load insert multiple fields data into a single column in database
Hi ,
I have my log file in sun OS box something like this
=======
(07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011
(07/29/2009 00:02:26.236) 3675 (07/29/2009 00:02:28.207) 949395117
(07/29/2009 00:02:28.240) 337710 (07/29/2009 00:02:30.621) 949400864
=============
I am trying to insert the data into oracle data base as follows.
=============================
column1 : (07/29/2009 00:02:24.467)
column2 : 367518
column3 : (07/29/2009 00:02:26.214)
column4 : 949384011
===========================
Can anyone help me with the control file format?
someone suggested me the code below.
==========
LOAD DATA
INFILE 'D:\work\load.txt'
INTO TABLE sample
(col1 POSITION(02:24) char,
col2 POSITION(27:32) INTEGER EXTERNAL,
col3 POSITION(35:57) CHAR,
col4 POSITION(60:68) INTEGER EXTERNAL
===========
but this works only for the fixed length data? Please help
user11744904 wrote:
Hi ,
I have my log file in sun OS box something like this
=======
(07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011
(07/29/2009 00:02:26.236) 3675 (07/29/2009 00:02:28.207) 949395117
(07/29/2009 00:02:28.240) 337710 (07/29/2009 00:02:30.621) 949400864
=============
I am trying to insert the data into oracle data base as follows.
=============================
column1 : (07/29/2009 00:02:24.467)
column2 : 367518
column3 : (07/29/2009 00:02:26.214)
column4 : 949384011
===========================
Can anyone help me with the control file format?
someone suggested me the code below.
==========
LOAD DATA
INFILE 'D:\work\load.txt'
INTO TABLE sample
(col1 POSITION(02:24) char,
col2 POSITION(27:32) INTEGER EXTERNAL,
col3 POSITION(35:57) CHAR,
col4 POSITION(60:68) INTEGER EXTERNAL
===========
but this works only for the fixed length data? Please helpIs the requirement to load all data in a single column or multiple columns? The thread subject and body are conflicting.
Similar Messages
-
Merging 2 rows data into a single column in OBIEE
Hi All,
Requirement is "Merging 2 rows into a single column"
Scenario: data from table called "transactions_table"
Id
transaction no
transaction name -------------------------------quantity
100
1
abc
1000
100
2
def
2000
Required out put:
Id
Transactions & Quantity
100
abc(1000),def(2000)
Please provide me solution, and let me know if any additional information is required.
Thanks in advance to all of you.can you please share your data like below
column1, column2 .....
and where are you trying to do this? at answer or bi admin tool?
there are a few ways to do this. -
Merging 2 rows data into a single column in OBIEE 11g
Hi All,
Requirement is "Merging 2 rows into a single column"
Scenario: data from table called *"transactions_table"*
Id ------------- transaction no ----------------------- transaction name -------------------------------quantity
100 ----------- 1 ----------------------- abc ------------------------------ 1000
100 ----------- 2 ------------------------ def ------------------------------ 2000
Required out put:
Id ----------------- Transactions & Quantity
100 -------------- abc(1000),def(2000)
Please provide me solution, and let me know if any additional information is required.
Thanks in advance to all of you.
Regards,
chrscheck the below link, that may help you.
Re: Horizontal value display
If it is helpful, please mark as correct or helpful -
Error when using SQL Developer to IMPORT Access data into Oracle
Hello,
I am using SQL Develoepr to export Access mdb file into Oracle. When I try to use Tools ---? Migration---> Microsssfot access exported -->
I am getting an error message upon attaching the Access database file, the error states
"Error#40179 - XMLExporter - Methiod'AddFromFile' of object'_References failed. Export did not complete successfully.
What could be the reason for this error please advise.
ThanksHi,
Try searching for:Re: 30EA2 - No Available Databases in Capture step with MS Access Migration
Thread: 30EA2 - No Available Databases in Capture step with MS Access Migration
Posted: Dec 20, 2010 11:04 AM
Also note that copy to oracle - (for just table/column information) is available on right click.
-Turloch
SQLDeveloper team -
Combining multiple plot data into a single graph.
This is my current data structure:
1D array of... (contains 6 plots, each with their own x and y arrays)
A cluster of two elements
1D array of I32
1D array of DBL
A cluster of two elements
2D array of DBL (y points for multiple plots)
1D array of I32 (x points for the multiple plots)
I need to combine these into something suitable for throwing at an XY-Graph. This operation will need to be done three times (for three different graphs), where only the 2D array of DBL is different for each graph (all three 2D arrays are located in the same cluster along with the shared 1D array). What is the best way of doing this?
The 1x6 array of clusters contains plots 0-5 for each graph. Is there a way to hide these plots from the graph's legend?
Never say "Oops." Always say "Ah, interesting!"J.Mamakos wrote:
I need to combine these into something suitable for throwing at an XY-Graph. This operation will need to be done three times (for three different graphs), where only the 2D array of DBL is different for each graph (all three 2D arrays are located in the same cluster along with the shared 1D array). What is the best way of doing this?
Sorry - this was actually a bit wrong/incomplete.
Graph1 includes one 2D array of DBL against the 1D array of I32.
Graph2 includes elements 2-3 of the 1x6 array, and also one 2D array of DBL against the 1D array of I32.
Graph3 includes elements 4-5 of the 1x6 array, and also one 2D array of DBL against the 1D array of I32.
This is how I'm doing it at the moment, but am I missing a trick here? Is there a better way?
As for my question about hiding any plots (on the legend) that came from the 1x6 array, is this even posible?
Either that, or is it possible to hide a graph whilst leaving its legend showing?
Or can one show/hide a graph's label in run-time?
Never say "Oops." Always say "Ah, interesting!" -
How to use sql loader with sequence?
Hi,
I have create a sequence and I would like to use when I am using sql loader when import some data into table.
Please give me some idea.
ThanksAnother option is to apply SQL operators to fields
LOAD DATA
INFILE *
APPEND
INTO TABLE emp
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' (
empno,
ename,
job,
mgr,
hiredate DATE(20) "DD-Month-YYYY",
sal,
comm,
deptno CHAR TERMINATED BY ':',
projno,
loadseq "my_seq.nextval")This is a modified control file of Case Study 3 which originally demonstrated the use of the Sequence parameter -
How to export&import data using sql *loader
Hi all,
How to export&import data from sql*loader. Give me the clear steps..
Thanks in AdvanceHi did you already exported data from SQL SERVER? if not using SQL*LOADER you cannot export data. SQL*LOADER is only mean for importing data from flat files(usually text files) into ORACLE tables.
for importing data into oracle tables using sql*loader use below steps
1) create a sql*loader control file.
it looks like as follows
LOAD DATA
INFILE 'sample.dat'
BADFILE 'sample.bad'
DISCARDFILE 'sample.dsc'
APPEND
INTO TABLE emp
TRAILING NULLCOLS
or for sample script of control file search google.
2) at command prompt issue following
$ sqlldr test/test
enter control file=<give control file name which you create earlier>
debug any errors (if occured) -
Sql loader error in offline data load
Hi,
I have done an offline schema creation using existing tablespace.
I am trying to do an offline data load using sql loader.The CTL and DAT file are generated by the work bench.
This is my CTL file code generated by workbench.
load data
infile 'Import.dat' "str '<EORD>'"
into table IMPORT
fields terminated by '<EOFD>'
trailing nullcols
When I am running the ctl file with DAT file in sql loader I am getting the following error
SQL*Loader-350: Syntax error at line 4.
Expecting single char, found "<EOFD>".
fields terminated by '<EOFD>'
^
My Sql Loader version is Release 8.0.6.3.0
Please help if anyone has came across this issue.
Thanks in advance.
Regards
Saravanan.BSaravanan,
Its a long time since I have seen 8 sql loader. Check the doc. Is it resrticted to a single character delimter??
Barry -
Using SQL Loader to insert data based on conditionally statements
I would like to use sql loader to insert records from a single text file into an Oracle database table. Sounds easy but the problem is that I need to check the existence of data in another table (Table A) before data can be loaded into Table B.
Table A has two columns: dept_no (primary key value) and dept_name (char)
Table B has five columns: emp_no (primary key value), dept_no (foreign key value to Table A), employee (char), job_title (char) and salary (number)
Text File looks like this:
Finance Jones President 10000
HR Smith Admin 2000
HelpDesk Jenkins Technician 3000
Problem:
1. I need sql loader to insert records into Table B by first checking if the first field in the file is in Table A.
2. If value exists get it's dept_no value.
3. If value doesn't exist discard record ( I might want to have sql loader insert a new record for this into Table A)
4. Using value from #2, insert the value in Table B for dept_no column.
5. Also assign a sequence value for the emp_no value in Table B.
Any guidance is greatly appreciated.
Thanks,Hello,
I am not sure this is possible with SQL loader. I would rather use an external table based on your file.
Then, I would use SQL to load your data into your table, based on your conditions.
Your request is not very complicated, writing the SQL to do that will be really more simple than trying to do it with SQL loader.
Hope it will help.
Regards,
Sylvie -
How to insert one table data into multiple tables by using procedure?
How to insert one table data into multiple tables by using procedure?
Below is the simple procedure. Try the below
CREATE OR REPLACE PROCEDURE test_proc
AS
BEGIN
INSERT ALL
INTO emp_test1
INTO emp_test2
SELECT * FROM emp;
END;
If you want more examples you can refer below link
multi-table inserts in oracle 9i
Message was edited by: 000000 -
How to use SQL*LOADER to read data in |SMITH|ALFRED| format
the data I need to upload to table using SQL*LOADER is in format as below:
|AD |Argentina |
|CN |China |
|US |America |
|GB |England |so how should I write my control file to read the data into two columns table?
I googled and people say that use Enclosed fields—delimiter (|), and I tried with below, but not working:
LOAD DATA
INFILE *
insert
INTO TABLE tmp_country_mapping
FIELDS ENCLOSED BY '|'
(country_id, country_name)
BEGINDATA
|AD |Argentina |
|CN |China |
|US |America |
|GB |England |Anyone could help?
BTW, I don`t want the spaces behind the value of the second column.
Thanks
Edited by: PhoenixBai on Dec 28, 2010 2:50 PMProblem solved, by removing the NLS_LANG=ENGLISH.
>
before the load, data is as below:
|AD |安道尔共和国 |
|AE |阿联酋 |
|AF |阿富汗 |
|AG |安提瓜和巴布达 |
|AI |安圭拉岛 |
|AL |阿尔巴尼亚 |after the load, data displays as below:
AD °2μà??12oí1ú
AE °¢áa??
AF °¢??o1
AG °2ìá1?oí°í2?′?
AI °21?à-μo
AL °¢??°í?á??And my database supports Chinese words and it displays correctly for other tables, except this one.
What could be the problem?
>
Edited by: PhoenixBai on Dec 28, 2010 5:05 PM -
Load XML File into temporary tables using sql loader
Hi All,
I have an XML file as below. I need to insert the contents into a temporary staging table using sql loader. Please advice how I need to do that.
For example Portfolios should go into a seperate table, and all the tags inside it should be populated in the columns of the table.
Family should go into a seperate table and all the tags inside it should be populated in the columns of the table.
Similarly offer, Products etc.
- <ABSProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <ProductSalesHierachy>
- <Portfolios>
- <Portfolio productCode="P1">
<Attribute name="CatalogProductName" value="Access" />
<Attribute name="Status" value="Active" />
</Portfolio>
- <Portfolio productCode="P2">
<Attribute name="CatalogProductName" value="Data" />
<Attribute name="Status" value="Active" />
</Portfolio>
- <Portfolio productCode="P3">
<Attribute name="CatalogProductName" value="Voice" />
<Attribute name="Status" value="Active" />
</Portfolio>
- <Portfolio productCode="P4">
<Attribute name="CatalogProductName" value="Wireless" />
<Attribute name="Status" value="Active" />
</Portfolio>
</Portfolios>
- <Families>
- <Family productCode="F1">
<Attribute name="CatalogProductName" value="Internet Access Services" />
<Attribute name="Status" value="Active" />
- <ParentHierarchy>
<Item productCode="P1" modelType="Portfolio" />
</ParentHierarchy>
</Family>
- <Family productCode="F2">
<Attribute name="CatalogProductName" value="Local Access Services" />
<Attribute name="Status" value="Active" />
- <ParentHierarchy>
<Item productCode="P2" modelType="Portfolio" />
</ParentHierarchy>
</Family>
</Families>
- <SubFamilies>
- <SubFamily productCode="SF1">
<Attribute name="CatalogProductName" value="Business Internet service" />
<Attribute name="Status" value="Active" />
- <ParentHierarchy>
<Item productCode="F1" modelType="Family" />
</ParentHierarchy>
</SubFamily>
</SubFamilies>
- <ProductRefs>
- <ProductRef productCode="WSP1" modelType="Wireline Sales Product">
<ActiveFlag>Y</ActiveFlag>
- <ProductHierarchy>
<SalesHierarchy family="F1" subFamily="SF1" portfolio="P1" primary="Y" />
<SalesHierarchy family="F2" portfolio="P2" primary="N" />
<FinancialHierarchy quotaBucket="Voice" strategicProdCategory="Local Voice" />
</ProductHierarchy>
</ProductRef>
- <ProductRef productCode="MSP2" modelType="Handset">
<ActiveFlag>Y</ActiveFlag>
- <ProductHierarchy>
<SalesHierarchy portfolio="P4" primary="Y" />
</ProductHierarchy>
</ProductRef>
</ProductRefs>
</ProductSalesHierachy>
- <Offers>
- <Offer productCode="ABN">
<OfferName>ABN</OfferName>
<OfferDescription>ABN Description</OfferDescription>
- <Segments>
<Segment>SCG</Segment>
<Segment>PCG</Segment>
</Segments>
<OfferUpdateDate>2009-11-20</OfferUpdateDate>
<ActiveFlag>Y</ActiveFlag>
</Offer>
- <Offer productCode="OneNet">
<OfferName>OneNet</OfferName>
<OfferDescription>OneNet Description</OfferDescription>
- <Segments>
<Segment>SCG</Segment>
<Segment>PCG</Segment>
<Segment>PCG2</Segment>
</Segments>
<OfferUpdateDate>2009-11-20</OfferUpdateDate>
<ActiveFlag>Y</ActiveFlag>
</Offer>
</Offers>
- <Products>
- <Product productCode="WSP1" modelType="Wireline Sales Product">
<ProductName>AT&T High Speed Internet</ProductName>
<ProductDescription>High Speed Internet</ProductDescription>
<LegacyCoProdIndicator>SBC</LegacyCoProdIndicator>
<RevenueCBLCode>1234B</RevenueCBLCode>
<VolumeCBLCode>4567A</VolumeCBLCode>
<SAARTServiceIDCode>S1234</SAARTServiceIDCode>
<MarginPercentRequired>Y</MarginPercentRequired>
<PercentIntl>%234</PercentIntl>
<UOM>Each</UOM>
<PriceType>OneTime</PriceType>
<ProductStatus>Active</ProductStatus>
<Compensable>Y</Compensable>
<Jurisdiction>Everywhere</Jurisdiction>
<ActiveFlag>Y</ActiveFlag>
- <Availabilities>
<Availability>SE</Availability>
<Availability>E</Availability>
</Availabilities>
- <Segments>
<Segment>SCG</Segment>
<Segment>PCG</Segment>
</Segments>
<VDIndicator>Voice</VDIndicator>
<PSOCCode>PSOC 1</PSOCCode>
<USBilled>Y</USBilled>
<MOWBilled>N</MOWBilled>
<ProductStartDate>2009-11-20</ProductStartDate>
<ProductUpdateDate>2009-11-20</ProductUpdateDate>
<ProductEndDate>2010-11-20</ProductEndDate>
- <AliasNames>
<AliasName>AT&T HSI</AliasName>
<AliasName>AT&T Fast Internet</AliasName>
</AliasNames>
- <OfferTypes>
<OfferType productCode="ABN" endDate="2009-11-20" />
<OfferType productCode="OneNet" />
</OfferTypes>
- <DynamicAttributes>
- <DynamicAttribute dataType="String" defaultValue="2.5 Mbps" name="Speed">
<AttrValue>1.5 Mbps</AttrValue>
<AttrValue>2.5 Mbps</AttrValue>
<AttrValue>3.5 Mbps</AttrValue>
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="TransportType">
<AttrValue>T1</AttrValue>
</DynamicAttribute>
</DynamicAttributes>
</Product>
- <Product productCode="MSP2" modelType="Handset">
<ProductName>Blackberry Bold</ProductName>
<ProductDescription>Blackberry Bold Phone</ProductDescription>
<LegacyCoProdIndicator />
<RevenueCBLCode />
<VolumeCBLCode />
<SAARTServiceIDCode />
<MarginPercentRequired />
<PercentIntl />
<UOM>Each</UOM>
<PriceType />
<ProductStatus>Active</ProductStatus>
<Compensable />
<Jurisdiction />
<ActiveFlag>Y</ActiveFlag>
- <Availabilities>
<Availability />
</Availabilities>
- <Segments>
<Segment>SCG</Segment>
<Segment>PCG</Segment>
</Segments>
<VDIndicator>Voice</VDIndicator>
<PSOCCode />
<USBilled />
<MOWBilled />
<ProductStartDate>2009-11-20</ProductStartDate>
<ProductUpdateDate>2009-11-20</ProductUpdateDate>
- <AliasNames>
<AliasName />
</AliasNames>
- <OfferTypes>
<OfferType productCode="ABN" />
</OfferTypes>
- <DynamicAttributes>
- <DynamicAttribute dataType="String" name="StlmntContractType">
<AttrValue />
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="BMG 2 year price">
<AttrValue>20</AttrValue>
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="MSRP">
<AttrValue>40</AttrValue>
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="BMGAvailableType">
<AttrValue />
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="ProductId">
<AttrValue>123456</AttrValue>
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="modelSource">
<AttrValue>product</AttrValue>
</DynamicAttribute>
</DynamicAttributes>
</Product>
</Products>
<CatalogChanged>Y</CatalogChanged>
</ABSProductCatalog>Two options that come to mind. Others exist.
#1 - {thread:id=474031}, which is basically storing the XML in an Object Relational structure for parsing
#2 - Dump the XML into either an XMLType based table or column and use SQL (with XMLTable) to create a view that parses the data. This would be the same as the view shown in the above post.
Don't use sql*loader to parse the XML. I was trying to find a post from mdrake about that but couldn't. In short, sql*loader was not build as an XML parser so don't try to use it that way. -
ORA-01841 Error when value for date col is NULL in .dat (using SQL Loader)
Hello Gurus,
I have some data in .dat file which needs to be loaded into oracle table. I am using SQL * Loader to do the job. Although "NULLIF col_name =BLANKS" works for character datatype, but when value for date col is NULL then I get ORA-01841 error. I have to make NULL for all rows withour value for date column
Early reply will be highly appreciated
FarooqHi,
May be this problem is not with the NULLIF. The value for the date column is not in proper date format.
create table:
create table kk (empno number, ename varchar2(20), deptno number, hiredate date)
Control file:
LOAD DATA
INFILE 'd:\kk\empdata.dat'
insert into TABLE kk ( empno position (1:2) integer external,
ename position(4:5) char NULLIF ename=BLANKS,
deptno position (7:8) integer external NULLIF deptno=BLANKS,
hiredate position (10:20) date NULLIF hiredate=BLANKS)
data file:
10 KK 01-jan-2005
20 10
SELECT * FROM KK;
EMPNO ENAME DEPTNO HIREDATE
10 KK 01-JAN-05
20 10
Verify the data file.
Hope it will help -
Insert stmt depends on condiotion using SQL*loader
Hi everbody
insert stmt depends on condiotion using SQL*loader
I have problem regarding to SQL*loader
i wants to insert data into table depeds on condiotion like
LOAD DATA
APPEND
INTO TABLE TMP
WHEN (26:33) = '161M1099'
TMP_FIELD1 CHAR(256),
TMP_TTYNO CONSTANT'1232:1228'
INTO TABLE TMP
WHEN (26:33) = '161P1340'
TMP_FIELD1 CHAR(256),
TMP_TTYNO CONSTANT'1232:1228'
INTO TABLE TMP
WHEN (26:33) = '161T1001'
TMP_FIELD1 CHAR(256),
TMP_TTYNO CONSTANT'1232:1228'
it is going to 1st condition and insert both tmp_field1 and tmp_ttyno now
problem occur when its going into 2nd condition
it is going to insert only constant tmp_ttyno not tmp_field1
and same in 3rd condition also
so what to do to insert data from file in tmp_field1
if any1 knows then please help me.You try with external table. A lot of flexibility is there.
Thanks. -
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...
Maybe you are looking for
-
hello!!!! I'm doing a web portal. In a layout i chose: "hide in design view". how can i show it again? ty
-
New to Mac. How do I install a printer?
I am trying to install a new printer. I have a Aficio MP C2800 from Ricoh. Went on their web page and downlaoded printer software but the printer did not show up as installed on MacBook. How do I install a new printer on MacBook Pro?
-
6120 classic:My voice commands do not work
Please help. Don't know if I'm just being stupid or there is something not right with my 6120c. My voice commands do not work. If I press the button for a voice command, it says that there are no voice tags saved. If I go into the voice command appli
-
Cant get flickering out of animation
Hello all, please take a look at following Applet: www.coskuns-castle.de/rotation It is a rotating animation. It is realtime, means you can rotate the scene with your mouse. It is not bad at all, but I cant get the damn flickering out of the animatio
-
Error in GS01 - Creating a hierarchy of accounts
I created a set of accounts with T. GS01, with name ZTEST, by copying an existing set TEST (with the EC-PCA GLPCT table, field RACCT). In the set ZTEST, i changed the hierarchy of the accounts and saved. I launched a report with Report Painter, in