Load data from external table
Hi ,
How to load data from external table to transaction table using SQLLDR ?
You use an external table to load the data it is described in the link to the manual I provided.
Here is an example.
Re: Using DML order to import a .xls file
You would not be using SQLLDR though as external tables replace that functionality.
Similar Messages
-
Error while selecting date from external table
Hello all,
I am getting the follwing error while selecting data from external table. Any idea why?
SQL> CREATE TABLE SE2_EXT (SE_REF_NO VARCHAR2(255),
2 SE_CUST_ID NUMBER(38),
3 SE_TRAN_AMT_LCY FLOAT(126),
4 SE_REVERSAL_MARKER VARCHAR2(255))
5 ORGANIZATION EXTERNAL (
6 TYPE ORACLE_LOADER
7 DEFAULT DIRECTORY ext_tables
8 ACCESS PARAMETERS (
9 RECORDS DELIMITED BY NEWLINE
10 FIELDS TERMINATED BY ','
11 MISSING FIELD VALUES ARE NULL
12 (
13 country_code CHAR(5),
14 country_name CHAR(50),
15 country_language CHAR(50)
16 )
17 )
18 LOCATION ('SE2.csv')
19 )
20 PARALLEL 5
21 REJECT LIMIT UNLIMITED;
Table created.
SQL> select * from se2_ext;
SQL> select count(*) from se2_ext;
select count(*) from se2_ext
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04043: table column not found in external source: SE_REF_NO
ORA-06512: at "SYS.ORACLE_LOADER", line 19It would appear that you external table definition and the external data file data do not match up. Post a few input records so someone can duplicate the problem and determine the fix.
HTH -- Mark D Powell -- -
How to Load data from a Table in BW to R3 Table .. any FM or Program if you
I want to load data from a Table in BW side to R3 side. Any FM or Program if you Know.
If it is one time activity ..Download the data into excel file on BW side..
Write an ABAP program to read the data from the excel file on local workstation and update table.. -
Using FDM to load data from oracle table (Integration Import Script)
Hi,
I am using Integration Import Script to load data from oracle table to worktables in FDM.
i am getting following error while running the script.
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done
Attaching the full error report
ERROR:
Code............................................. -2147217887
Description...................................... Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
At line: 22
Procedure........................................ clsImpProcessMgr.fLoadAndProcessFile
Component........................................ upsWObjectsDM
Version.......................................... 1112
Thread........................................... 6260
IDENTIFICATION:
User............................................. ******
Computer Name.................................... *******
App Name......................................... FDMAPP
Client App....................................... WebClient
CONNECTION:
Provider......................................... ORAOLEDB.ORACLE
Data Server......................................
Database Name.................................... DBNAME
Trusted Connect.................................. False
Connect Status.. Connection Open
GLOBALS:
Location......................................... SCRTEST
Location ID...................................... 750
Location Seg..................................... 4
Category......................................... FDM ACTUAL
Category ID...................................... 13
Period........................................... Jun - 2011
Period ID........................................ 6/30/2011
POV Local........................................ True
Language......................................... 1033
User Level....................................... 1
All Partitions................................... True
Is Auditor....................................... False
I am using the following script
Function ImpScrTest(strLoc, lngCatKey, dblPerKey, strWorkTableName)
'Oracle Hyperion FDM Integration Import Script:
'Created By: Dhananjay
'Date Created: 1/17/2012 10:29:53 AM
'Purpose:A test script to import data from Oracle EBS tables
Dim cnSS 'ADODB.Connection
Dim strSQL 'SQL string
Dim rs 'Recordset
Dim rsAppend 'tTB table append rs object
'Initialize objects
Set cnSS = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
Set rsAppend = DW.DataAccess.farsTable(strWorkTableName)
'Connect to SQL Server database
cnss.open "Provider=OraOLEDB.Oracle.1;Data Source= +server+;Initial Catalog= +catalog+;User ID= +uid+;Password= +pass+"
'Create query string
strSQL = "Select AMOUNT,DESCRIPTION,ACCOUNT,ENTITY FROM +catalog+.TEST_TMP"
'Get data
rs.Open strSQL, cnSS
'Check for data
If rs.bof And rs.eof Then
RES.PlngActionType = 2
RES.PstrActionValue = "No Records to load!"
Exit Function
End If
'Loop through records and append to tTB table in location’s DB
If Not rs.bof And Not rs.eof Then
Do While Not rs.eof
rsAppend.AddNew
rsAppend.Fields("PartitionKey") = RES.PlngLocKey
rsAppend.Fields("CatKey") = RES.PlngCatKey
rsAppend.Fields("PeriodKey") = RES.PdtePerKey
rsAppend.Fields("DataView") = "YTD"
rsAppend.Fields("CalcAcctType") = 9
rsAppend.Fields("Amount") = rs.fields("Amount").Value
rsAppend.Fields("Desc1") = rs.fields("Description").Value
rsAppend.Fields("Account") = rs.fields("Account").Value
rsAppend.Fields("Entity") = rs.fields("Entity").Value
rsAppend.Update
rs.movenext
Loop
End If
'Records loaded
RES.PlngActionType = 6
RES.PstrActionValue = "Import successful!"
'Assign Return value
SQLIntegration = True
End Function
Please help me on this
Thanks,
Dhananjay
Edited by: DBS on Feb 9, 2012 10:21 PMHi,
I found the problem.It was because of the connection string.The format was different for oracle tables.
PFB the format
*cnss.open"Provider=OraOLEDB.Oracle.1;Data Source= servername:port/SID;Database= DB;User Id=aaaa;Password=aaaa;"*
And thanks *SH* for quick response.
So closing the thread......
Thanks,
Dhananjay -
Loading data from multiple tables to multiple sheets of excel using SSIS
I have a requirement in which I want to load data from 13 tables to 13 respective sheets of single excel file using SSIS.
Can anyone know SSIS logic for developing package for this?see similar example here
http://visakhm.blogspot.in/2013/09/exporting-sqlserver-data-to-multiple.html
In your case you need to use loop to iterate through tables
First get list of tables in a object variable created in SSIS using INFORMATION_SCHEMA.TABLES view
Then add a for each loop based on ADO.NET variable enumerator to iterate through tables and inside loop follow method as in the above link to create the sheet first and populate it.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Loading data from one table to another table
I need to load the data (data conversion) from one table to 3 different table.
I have to load the data from Source table to following 3 target tables.
So Consumer table has email pk and it has relationship with CONSUMER_RCV table and CONSUMER_RCV
table has relationship with CONSUMER_ATTR table. I am doing right now with pl/sql but I am looking
to use MULTI INSERT or SQL*LOADER or another efficient way.
I tried with MultiInsert but it getting failed as it's violating Unique Constraints as source table might contains
Duplicate emails.
Could you please show me how I can load the data efficiently?
Also I need to load in CONSUMER_ATTR table from CONTACT table which has ATTR1, ATTR2 columns.
so My mapping will be ...
Contact.email, first_name, last_name will go into Consumer table
then in CONSUMER_RCV, I generate the id column value by sequence, load email and DATE_CREATEd from contact table
And rest of the value is hard coded
Then in CONSUMER_ATTR table I will generate the CONSUMER_ATTR_id through sequence, for ID, will use the same
id column value which I have generated by sequence in CONSUMER_RCV, then put the attr_type = 'ATTR1' and for
attr_value column I will insert the value from contact table's ATTR1 value,
Then generate another CONSUMER_ATTR_ID, will use the same id column value which I have generated by sequence
in CONSUMER_RCV, then put the attr_type = 'ATTR2' and for
attr_value column I will insert the value from contact table's ATTR2 value,
Please let me know if you need further explanation.
I am using Oracle 9i R2.
Please consider CONTACT is Source table, CONSUMER is a Target1, CONSUMER_RCV is a Target2 and CONSUMER_ATTR is a Target3
to simplify the problem.
Following is the Table structure
=========================
CREATE TABLE CONTACT (
ID VARCHAR2 (40) NOT NULL, -- will go into Target1
EMAIL VARCHAR2 (100) , -- might be duplicate and will go into Target1 and Target2
FIRST_NAME VARCHAR2 (100) NOT NULL, -- will go into Target1
LAST_NAME VARCHAR2 (100) NOT NULL, -- will go into Target1
COUNTRY VARCHAR2 (40) NOT NULL, -- will go into Target1
PHONE VARCHAR2 (100), -- will go into Target1
NOTIFY VARCHAR2 (3), -- will go into Target2 table's RECEIVE_EMAIL column
CREATE_DATE DATE , -- will go into Target1 and target2
ATTR1 VARCHAR2 (400), -- will go into Target3 as attr_type= ATTR1 and will load actual value in ATTR_VALUE
ATTR2 VARCHAR2(100), -- will go into Target3 as attr_type= ATTR2 and will load actual value in ATTR_VALUE
ATTR2 VARCHAR2(100), -- will go into Target3 as attr_type= ATTR1 and will load actual value in ATTR_VALUE
CONSTRAINT CONTACT_PK
PRIMARY KEY ( USER_ID ) ) ;
CREATE TABLE CONSUMER(
EMAIL VARCHAR2 (100) NOT NULL, -- PK
TITLE VARCHAR2 (40),
FIRST_NAME VARCHAR2 (40),
LAST_NAME VARCHAR2 (40),
ADDRESS1 VARCHAR2 (40),
ADDRESS2 VARCHAR2 (40),
CITY VARCHAR2 (30),
STATE VARCHAR2 (30),
ZIP VARCHAR2 (10),
COUNTRY VARCHAR2 (40),
PHONE VARCHAR2 (15),
DATE_CREATED DATE NOT NULL,
CONSTRAINT CONSUMER_PK
PRIMARY KEY ( EMAIL ) ) ;
CREATE TABLE CONSUMER_RCV (
ID VARCHAR2 (40) NOT NULL,-- PK
EMAIL VARCHAR2 (100) NOT NULL,-- FK reference to Consumer
SITE VARCHAR2 (100) NOT NULL, -- default website
RECEIVE_EMAIL VARCHAR2 (1),
CREATE_DATE DATE NOT NULL,
CONSTRAINT CONSUMER_RCV_PK
PRIMARY KEY (ID) ) ;
ALTER TABLE CONSUMER_RCV ADD CONSTRAINT CONSUMER_RCV_FK
FOREIGN KEY (EMAIL)
REFERENCES CONSUMER (EMAIL) ;
CREATE TABLE CONSUMER_ATTR (
CONSUMER_ATTR_ID VARCHAR2 (40) NOT NULL, -- PK
ID VARCHAR2 (40) NOT NULL, -- FK reference to COnsumer_RCV
ATTR_TYPE VARCHAR2 (100) NOT NULL,
ATTR_VALUE VARCHAR2 (4000) NOT NULL,
CONSTRAINT CONSUMER_ATTR_PK
PRIMARY KEY ( CONSUMER_ATTR_ID ) ) ;
ALTER TABLE CONSUMER_ATTR ADD CONSTRAINT CONSUMER_ATTR_FK
FOREIGN KEY (CONSUMER_ATTR_ID)
REFERENCES CONSUMER_RCV (ID) ;HI Hema,
How are the entries related.. is it like for one entry in y table there are more than one entry in x table then you have to use loop with in loop , here are the both the conditions.
1) For each entry in Y there are more than one entries in X
sort y by quota trpid.
sort x by quota trpid.
loop at y.
loop at x where quota eq y-quota
and trpid eq y-trpid.
z-value = x-value.
append z.
endloop.
endloop.
2) For each y there is one entry in x table.
sort y by quota trpid.
sort x by quota trpid.
loop at y.
read table x with key quota = y-quota
trpid = y-trpid binary search.
if sy-subrc eq 0.
z-value = x-value.
append z.
Endif.
endloop.
Mahesh -
Loading data from one table to another using cursor
Hi,
I have given the below command to load the data from 1 table to another using cursor.
declare
cursor mycursor IS
SELECT extract_name,from_date,to_date,BETA from temp_table where EXTRACT_NAME='GIFTCARD_DETAILS';
Begin
for mycursor_1 IN mycursor loop
insert into tmp_tab columns(col1,col2,col3,col5) values(mycursor_1.EXTRACT_NAME,mycursor_1.from_date,mycursor_1.to_date,mycursor_1.BETA);
End loop;
commit;
end;
It is working fine.
But I want to hard code some of the columns ( like flags ) which are not there in 1st table and load them into 2nd table.
In db2 we will give commands like
varSqlStatus=`db2 "declare mycurs cursor for select extract_name,from_date,to_date,BETA,'N','Y' from temp_table"`
varSqlStatus=`db2 "load from mycurs of cursor modified by identityignore insert into tmp_tab(col1,col2,col3,col5,col6,col7) nonrecoverable"`
But I want it in oracle 10g, Can any one help me in this.Have you tried either of the two options :
1. Modify the CURSOR itself :
cursor mycursor IS
SELECT extract_name,from_date,to_date,BETA,'N','Y' from temp_table where EXTRACT_NAME='GIFTCARD_DETAILS';2. Modify the INSERT statement itself :
insert into tmp_tab columns(col1,col2,col3,col5,col6,col7) values(mycursor_1.EXTRACT_NAME,mycursor_1.from_date,mycursor_1.to_date,mycursor_1.BETA,'N','Y'); -
Hi,
I have a situation where i have to load data from one server/database table to multiple servers/databases.
Example:
I need to load data from dbo.TABLE_A (on Server: Server_A & Database: Database_A) to the same table on the list of server databases like
Server: Server_B , Database: Database_B
Server: Server_C , Database: Database_C
Server: Server_D , Database: Database_D
Server: Server_E , Database: Database_E
Server: Server_F , Database: Database_F
Server: Server_G , Database: Database_G
Server: Server_H , Database: Database_H
so on and so forth on 250 such server database combinations.
The table structure is the same on all the servers.
If i make the source or destination dynamic, it throws an error while mapping ?
I cannot get Linked server permissions and SQL Server Config thing doesn't work as well.
Please suggest on how to load data from one source to multiple server/databases.
Thank you.I just need to transfer one table's data. its like i have to use a query to pick data for
the most recent data. So i use something like, select A, B, C, D from dbo.table where ETL_TIMESTAMP > (the max(etltimestamp) in the destination on different server). There are no foreign key relationships and the data should not be truncated. it just had
to append the new records. -
How to load data from oracle table to XML using ODI ?
Hello Team
I am trying to load data from an oracle table to an xml file. I have configured the physical and the logical schemas for the same. I have used SQL to SQL as LKM and SQL to SQL Append as IKM with Sunopsis Memory Engine as staging area.
After this, when I am executing the interface, it is executed without any errors but to my surprise I am not finding the relevant data in the xml file. What could be the reason ?
Please look into this and lemme know how to solve it.
Thanks.908458 wrote:
Hello Phanikanth
Even IKM SQL Control Append is not solving the problem. There are many " order columns" in the target xml table. I have not mapped them or specified any order. Does the problem persist because of this ?
Thanks
Manoj
Ocle to XML file loading issue in ODI 10.1.3.5 -
Loading data from Z table to an ODS in BW/BI
Hello Gurus,
Can some one guide me how do I load data from a Z table which exists in the same BI system into an ODS/DSO. I'm working on a 04S system.
Your help is highly appreciated.
Thanks & Regards,
Prashanthhi Prasanth
u r using generic extraction method to load data from R/3 to BW server
u can use
T.Code SBIW or RSO2 to create Generic DataSource.
step 1- logon to R/3 system
step2 - check data in table
for this use t.code se11.
Db table name --- ZXXXXX.
1. select " Display " button.
2. select " contents"(shftctrlf11).--->execute.
*step-3 *- create generic datasource for trasactiona data
 enter t.code- rso2
 select t.data -
zXXXXX.(specify ur datasource name to create a new one).
 select create icon.
 appl.. component --- (browse and choose ur application component)(EX- sd).
 Extration from DBView"
 table/view---zXXXXX(give ur ztable name).
 text----give sht .des, m.des, L .des.......... for u data source.
 Select generic delta option in toolbar.
 Give delta specific field
 Field name---- (ex- pid)
Select any radio button(ex-numeric pointer).
 Settings additive delta radio button( for delta loads from ods to i.cube).
 Select save save .
 Package -
some package name.
 Save
 Continiue
 Coustomize the datasource by seleting selection check boxes for fields.
 Save
 MSg:- datasource hve been created.
SAP BW side:
Step :1
Enter t.code rsa13.
 Identify R/3 source system icon.
 Double click on R/3 s . system.
 Expand BW datasource
 Expand sap Appl. Comp..
 Select ur application component( for Ex- SD).
 Context menu -- replicate datasource
 Refresh tree once the replication is complete.
 Find ur datasource.
 Double click on data source icon { this implies data source is not assigned).
 Context menu
 Assign infosource..
 i.source assignment:
o select others radio button
o and select optioncreate.
 Flexible update.-------XXXXX
 Des----XXXXXX
 Continue
 Create I.Obj w .r t r/3 s.s fields.
 Assign the I.Obj to the fields of r/3 respectively.
 Enter 0RECORDMODE in comm.. structure.
 Activate
 create ODS obj and create structure and activate
 create update rules for Ods object with reference to i.source. and activate.
 Create infopackage and schedule data .and monitor the data in psa and ods objects tables. -
how can i load data from a oracle table to a text file or CSV file using PL/SQL procedures where the pls/sql code will take the table name dynamically.........
soumenTry this thread..
Is it possible to export a pl/sql region as a csv file? -
Error while loading data into External table from the flat files
HI ,
We have a data load in our project which feeds the oracle external tables with the data from the Flat Files(.bcp files) in unix.
While loading the data, we are encountering the following error.
Error occured (Error Code : -29913 and Error Message : ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04063: un) while loading data into table_ext
Please let us know what needs to be done in this case to solve this problem.
Thanks,
KartheekKartheek,
I used Google (mine still works).... please check those links:
http://oraclequirks.blogspot.com/2008/07/ora-29400-data-cartridge-error.html
http://jonathanlewis.wordpress.com/2011/02/15/ora-29913/
HTH,
Thierry -
Load data from one table to another
Hi all,
Please help me for my below requirement.
Oracle version : Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
Rules
1) First two city's should be loaded in city_1 and city_2.
2) If there are more two cities, only first two should be loaded.
3) If only one city_1 has value, it should be loaded in city_1.
drop table seven_cities;
create table seven_cities
(id number,
city_1 varchar2(100),
city_2 varchar2(100),
city_3 varchar2(100),
city_4 varchar2(100),
city_5 varchar2(100),
city_6 varchar2(100),
city_7 varchar2(100)
insert into seven_cities(id,city_1,city_2,city_3,city_4,city_5,city_6,city_7)
values (1,'New York',null,null,null,'Chicago',null,null);
insert into seven_cities(id,city_1,city_2,city_3,city_4,city_5,city_6,city_7)
values (2,null,'Hyderabad','Delhi','Mumbai',null,null,null);
insert into seven_cities(id,city_1,city_2,city_3,city_4,city_5,city_6,city_7)
values (3,null,null,null,null,null,null,'London');
insert into seven_cities(id,city_1,city_2,city_3,city_4,city_5,city_6,city_7)
values (4,null,null,null,'Sydeny','Melbourne','Paris','Berlin');
commit;
select * from seven_cities;
drop table two_cities;
create table two_cities
(id number,
city_1 varchar2(100),
city_2 varchar2(100));
Expected data to be loaded
id city_1 city_2
1 New York Chicago
2 Hyderabad Delhi
3 London null
4 Sydney MelbourneThanks
Raghuselect id,
coalesce(city_1,city_2,city_3,city_4,city_5,city_6,city_7) city_1,
nvl2(
city_1,
coalesce(city_2,city_3,city_4,city_5,city_6,city_7),
nvl2(
city_2,
coalesce(city_3,city_4,city_5,city_6,city_7),
nvl2(
city_3,
coalesce(city_4,city_5,city_6,city_7),
nvl2(
city_4,
coalesce(city_5,city_6,city_7),
nvl2(
city_5,
coalesce(city_6,city_7),
nvl2(
city_6,
city_7,
null
) city_2
from seven_cities
ID CITY_1 CITY_2
1 New York Chicago
2 Hyderabad Delhi
3 London
4 Sydeny Melbourne
SQL> SY. -
Loading data from a table to another
This question is continuation of my earlier thread
Re: query help
The last thread was answered by experts and was closed. But I have another problem, I'll put the whole scenario here:
I have a table with data as
id status_code emp_id
1 a 10
2 b 10
3 a 20
4 c 30
5 k 10
6 k 10
7 a 10
8 a 20
9 z 20
10 k 30
11 k 30
12 m 20
13 k 10
14 k 30and scripts are:
CREATE TABLE TEST
(id NUMBER,
status_code VARCHAR2(5),
emp_id NUMBER
INSERT INTO test VALUES (1,'a',10);
INSERT INTO test VALUES (2,'b',10);
INSERT INTO test VALUES (3,'a',20);
INSERT INTO test VALUES (4,'c',30);
INSERT INTO test VALUES (5,'k',10);
INSERT INTO test VALUES (6,'k',10);
INSERT INTO test VALUES (7,'a',10);
INSERT INTO test VALUES (8,'a',20);
INSERT INTO test VALUES (9,'z',20);
INSERT INTO test VALUES (10,'k',30);
INSERT INTO test VALUES (11,'k',30);
INSERT INTO test VALUES (12,'m',20);
INSERT INTO test VALUES (13,'k',10);
INSERT INTO test VALUES (14,'k',30);Here's the query that experts gave me in last thread, to fetch desired records:
The requirement was to fetch records of those emp ids where a given emp_id consectively gets same status code.
Each emp id gets a status code and at times it gets same status code as its previous status code. And I am interested in such scenarios.
For example,
emp_id=20 gets status_code=a in id=3 and its next status_code is also =a at id=8,
emp_id=10 gets status_code=k in id=5 and gets same status_code again in id=6,
emp_id=30 gets status_code=k in id=10 and gets same status code in id=11 and id=14.
And the answer was:
select *
from
select
id,
status_code,
emp_id,
lag(status_code) over (partition by emp_id order by id asc) as last_status,
lead(status_code) over (partition by emp_id order by id asc) as next_status
from test
where status_code = last_status
or status_code = next_status
/ But now the new issue is that the records of the table TEST are to be loaded into another table TEST_REVISED . For each ID of table TEST, there will be one or more records in table TEST_REVISED.
ALTER TABLE TEST ADD (CONSTRAINT id_pk PRIMARY KEY(id));
CREATE TABLE TEST_REVISED
(TR_ID NUMBER PRIMARY KEY,
ID NUMBER REFERENCES TEST(ID),
NEW_STATUS_CODE VARCHAR2(5)
);This is what I want to see in table TEST_REVISED
TR_ID, ID, NEW_STATUS_CODE
100, 1, 'test-code'
200, 2,' 'test-code'
300, 3, 'test-code'
400, 4, 'test-code'
500, 5, 'test-code'
600, 5, 'test-code'--notice here: EMP_ID=10 had same status consecutively in table TEST, so when that record is loaded to TEST_REVISED, ID=5 is used instead of id=6
700, 7, 'test-code'
800, 3, 'test-code'--notice here: EMP_ID=20 had same status consecutively in table TEST, so when that record is loaded to TEST_REVISED, ID=3 is used instead of id=8
900, 9, 'test-code'
1000, 10, 'test-code'
1100, 10, 'test-code'--notice here: EMP_D=30 had same status consecutively in table TEST, so when that record is loaded to TEST_REVISED, ID=10 is used instead of id=11
1200, 12, 'test-code'
1300, 13, 'test-code'
1400, 10, 'test-code'--notice here: EMP_ID=30 had same status consecutively in table TEST, so when that record is loaded to TEST_REVISED, ID=10 is used instead of id=14 or id=11Ignore the value of the column NEW_STATUS_CODE here.
How can I load data in table TEST_REVISED from table TEST keeping in view the requirement I mentioned? Table TEST has around 1 million records.
Once this achieved, I want to delete records from table TEST with following ids :
ID=6,8,11,14.
Thanks a lot!
Edited by: user5406804 on Dec 5, 2010 5:49 PM
Edited by: user5406804 on Dec 5, 2010 5:50 PMOK, i still don't see how this is all supposed to fit together.
You haven't said it, but i'm assuming when you have a series like
id emp status_code
1 30 k
2 30 k
3 10 a
4 30 k
5 30 kYou actually want the output to be
id emp status_code new_id
1 30 k 1
2 30 k 1
3 10 a 3
4 30 k 4
5 30 k 4Which presents a bit of a problem using simply analytic functions.
So here's the modified query that picks up just the rows you want 'changed'.
TUBBY_TUBBZ?
select
id,
emp_id,
status_code,
connect_by_root(id) as new_id
from
select
id,
emp_id,
status_code,
lag(status_code) over (partition by emp_id, status_code order by id asc) as last_status,
row_number() over (partition by emp_id, status_code order by id asc) as rn
from
select
id,
emp_id,
status_code,
lead(status_code) over (partition by emp_id order by id asc) as next_code,
lag(status_code) over (partition by emp_id order by id asc) as last_code,
row_number() over (partition by emp_id order by id asc) as rn
from test
where status_code in (last_code, next_code)
start with last_status is null
connect by prior emp_id = emp_id
and prior status_code = status_code
and prior rn = rn - 1
ID EMP_ID STATU NEW_ID
5 10 k 5
6 10 k 5
3 20 a 3
8 20 a 3
10 30 k 10
11 30 k 10
14 30 k 10
7 rows selected.
TUBBY_TUBBZ?You say you have a lot of rows in the TEST table, and i'm hoping and praying this is a one time requirement and not an on-going process that needs to occur so your best bet (performance wise) would probably be to use the above query to create a temporary table.
Use that temporary table to control the rest of the process (inserting into TEMP_REVISED and deleting from TEST).
That's the best i can think of based on what i believe your requirement is ... and i honestly don't think that's going to perform overly well (the connect by functionality specifically). -
Problem while selecting data from external tables
Hi All,
I am facing a problem with external tabels. I have created an external table
create table ext_org_table
( id varchar2(10)
, name varchar2(100)
,id_parent varchar2(10)
,name_parent varchar2(100))
organization external
( type oracle_loader
default directory MYDIR
access parameters
records delimited by newline
nologfile
nobadfile
fields terminated by ','
missing field values are null
location ('Orgdata.csv')
reject limit unlimited;
The problem is that when i give select * from ext_org_table , i get following error
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file Orgdata.csv in MYDIR not found
ORA-06512: at "SYS.ORACLE_LOADER", line 19
ORA-06512: at line 1
Now , i have file Orgdata.csv in the specified directory.
I have created directory in oracle using create directory command.
I have granted read,write permission on the directory to user.
I have given all read,write and execute permissions to folder where my files resides.My file resides in /appl/home/kk
Now i don't understand why it is giving error file in Mydir not found.
Kindly suggest.
Regards
KrishHi,
You are obviously doing someting wrong.
May be the direcotry is not present or may be the file is not rpesent in the directory.
I just tried ths
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as SYS
create directory mydir as 'c:\csv';
grant read,write on directory mydir to scott;From Scott
create table ext_org_table
( id varchar2(10)
, name varchar2(100)
,id_parent varchar2(10)
,name_parent varchar2(100))
organization external
( type oracle_loader
default directory MYDIR
access parameters
records delimited by newline
nologfile
nobadfile
fields terminated by ','
missing field values are null
location ('Orgdata.csv')
reject limit unlimited;
select * from ext_org_table;Ofcourse i made up some dummy data to test and its all OK.
again,
You may want to check if
1) If the directory exists (select * from all_directories where directory_name='MYDIR');
2) If the user has the read/write permissions on that directory
3) If the file orgdata exists in that directory.
Regards,
Bhushan
Maybe you are looking for
-
When using DAQ assistant to read frequency
When using DAQ assistant to read frequency and Task timing is set to: N Samples, Clock settings to read 26, Frequency setup to rising edge, 1 counter with 10 kHz to 1 kHz range. I get back a single number. Can I assume this is an average reading of 2
-
Variable power supply not working in virtual elvis
When i make a virtual elvis 3d schematic i cannot get any output from the variable power source, i have played with it alot and still no output. please help.
-
Why is the time in every official picture or video of an iDevice always 9:41 AM ?
I have seen in every official picture or video that the time is always 9:41 AM. I wonder what is the reason after this ? Any help is greatly appreciated. THANK YOU
-
Something very strange has just started to happen to me with CS4. I've been running CS4 on my Mac Pro for quite some time without any problems. Just yesterday I began to run into something like a mini "crash" when using the liquify tools. Previousl
-
The output measurement of HP34401A is of array data type. How can I convert it to double data type?