SQL & PL/SQL :: Nested Table - Update Activity For Data Correction?

Mar 17, 2012

I've to do a update activity for data correction. There are about 1 crore records involved in this. I want to keep a log of the activity at least Sales No. so that I can validate my data correction. Main cursor is involved for this. The problem is if I insert each record for sales number in the loop then process will take about double time. So i decided to create a nested table and insert after each session finishes.

I'm talking about session here is. The table I'm updation is partition table. So I can have many sessions and each session updating different table partition. This way there is no lock, better performance. Server has 35 processors so I can at least have 25 sessiions.

I could have used varray for this. But I want to learn nested table also. Problem here is not to take different way to complete this activity but to learn why I'm facing this issue.

CREATE OR REPLACE TYPE OBJ_TXN_LOG AS OBJECT
(
SALES_NO VARCHAR2(24)
,sALES_SEQ NUMBER(4)
) ;

[code]...

View 18 Replies


ADVERTISEMENT

SQL & PL/SQL :: Update Nested Table Data

Mar 12, 2012

SCOTT@orcl_11gR2> create or replace type nesttype as table of clob;
2 /

Type created.

SCOTT@orcl_11gR2> create table emp
2 (empnonumber,
3 enamevarchar2(1000),
4 hobbynesttype)
5 nested table hobby store as hobby_nt
6 /

Table created.

SCOTT@orcl_11gR2> insert into emp values
2 (1, 'name1', nesttype ('dancing', 'cricket','listening music','dancing'))
3 /

1 row created.

SCOTT@orcl_11gR2> insert into emp values
2 (2, 'name2', nesttype ('cooking', 'dancing','cooking'))
3 /

1 row created.

I want to update nested table record based on index suppose i want to update 3rd number of hobby for name2 employee

i have written the below query

SCOTT@orcl_11gR2>update Table(select hobby from emp
2 where empno= 2) e
3 set value(e)='new_value' where to_char(value(e)) = (select 4 to_char(tab1_element)
5 from (select rownum rn,

[Code]...

2 rows updated.

but the above query is updating 2 records but my requirement is it should update only third record

How can we update nested table based on index number

View 10 Replies View Related

SQL & PL/SQL :: How To Compare Data In Nested Table

Mar 12, 2012

create type nesttype as table of clob;

create table emp
(empno number,
ename varchar2(1000),
language_known nesttype
)

I want to check whether language is already there in database or not.

i have written the below query

select * from emp where language_known =nesttype('english','hindi');

i am getting the below error

SQL Error: ORA-22901: cannot compare nested table or VARRAY or LOB attributes of an object type
22901. 00000 - "cannot compare nested table or VARRAY or LOB attributes of an object type"
*Cause: Comparison of nested table or VARRAY or LOB attributes of an
object type was attempted in the absence of a MAP or ORDER
method.
*Action: define a MAP or ORDER method for the object type.

How to compare data in nested table

View 16 Replies View Related

PL/SQL :: Inserting Data Into Nested Table

Jul 22, 2013

I am exploring the differences between OBJECT & RECORD. As i am still in process of learning, I found that both are structures which basically groups elements of different datatypes or columns of different datatypes, one is used in SQL and other is used in PL/SQL. Below i am trying to insert data into an table of type object but i am unsuccessful.

CREATE OR REPLACE type sam as OBJECT
(
v1 NUMBER,
v2 VARCHAR2(20 CHAR)
);

---Nested Table---
create or replace type t_sam as table of sam;
--Inserting data----
insert into table(t_sam) values(sam(10,'Dsouza')); Error Message:
[code]........

View 4 Replies View Related

Client Tools :: Export Data In Nested Table

Feb 17, 2010

I have some problem when i try to export data from a table which contains a nested table, using toad.

When toad generate the file, in the column corresponding to the nested table, toad just write a (DATASET) instead of the data contained in the nested table

Here is an example:
INSERT INTO SSD_REV_S ( REV_ID, REV_TAB, REV_TS, REV_USER, REV_LOG )
VALUES (
TO_Date( '07/30/2007 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'), (DATASET), TO_TIMESTAMP('4/3/2009 11:20:51.000000 AM','fmMMfm/fmDDfm/YYYY fmHH12fm:MI:SS.FF AM'), 'operator', 'Add EVENT');

REV_TAB is my nested table

way to export data from a table which contain a nested table, as a list of insert statement, so i can move the data to a different database schema? I can also use different client tool.

View 3 Replies View Related

SQL & PL/SQL :: Update Using Data From Another Table

Jan 19, 2012

table1: url_data

page_url category
learn.web/AU/eng/AWARD/efg null
learn.web/CN/eng/AWARD/efg null
learn.web/US/eng/AWARD/efg null
learn.web/UK/eng/AWARD/efg null
learn.web/JP/eng/AWARD/efg null
learn.web/CA/eng/AWARD/efg null

[Code]..

table2: country

country_code
AU
CN
US
UK
JP

[Code]...

Now I have to update category by using /CC/eng/ where CC is the country code from country

I can use where page_url LIKE '%/__/eng/' but here the problem is the last row. I have to update by looking up from country table.

View 6 Replies View Related

SQL & PL/SQL :: How To Update Data From Backup Table

Nov 4, 2013

I have a table named employee with 10 records. Empid is the primary key and empsal contains salary of the employees. I created backup of this table and name of backup table is empbackup.

Now empsal was updated to empsal*10 in employee table and 10 more records were also inserted in employee table. Now I want to restore the empsal column for 10 employees from empbackup(as initially there were only 10 employees in employee table when empbackup was created) table how can I do that in PL/SQL or Oracle?

View 16 Replies View Related

Forms :: Update Table Data Via Oracle 10g

Jul 7, 2011

I am trying to develop a form consisting of a key block and a single data block. The problem is that the driving table is not the table that needs to be updated.

user wants the following layout:student Advisor
ID# name degree major Concentration ID# name
The driving table (TABLE A) will supply the first 5 fields. The advisor ID comes from (TABLE B).

The user needs to update the adviser ID# field associated with the student ID# field. The form is to be tabular listing all students. I've seen some info on using procedures to insert, delete, update, query and lock tables, but i'm just not sure if that's what is needed.

View 6 Replies View Related

Forms :: Insert Data And Then Update Table

Aug 5, 2010

i have a tabular form select * from emp and i want to create table and store there data in goup select empono,sal,com group by dept i want to insert in another table.

how i insert the data in table by forms front end and then update also when again click the button or any change occur in form insert into a select empono,sal,com group by dept

View 2 Replies View Related

PL/SQL :: Update Column Based On Sum Of Data From Another Table

Apr 17, 2013

We had two tables.

Table 1: matusetrans

ITEMNUM Location Quantity transdate
AM1324 AM1 2 12-4-12
AM1324 AM1 2 15-5-12
AM1324 AM1 3 10-6-12
AM1324 AM1 4 5-1-13

[Code]....

Table 2: Inventory

ITEMNUM STORELOC lastyear currentyear
AM1324 AM1 need sum(quantity) here need sum(quantity)
AM1324 AM2 need sum(quantity) here need sum(quantity)

We have to update the last year and current year columns with sum of quantities for each item from matusetrans table based on date at different location in Inventory table.

we had nearly 13,000 records(itemnum's with different location) in inventory table in DB we have to update entire records.

How to write an sql queries to update lastyear and currentyear columns with sum of quantities based on itemnum and location in Inventory table

Edit/Delete Message

View 6 Replies View Related

Update AGENTS Table With Data Based On Queries?

Feb 3, 2009

I was trying to update the AGENTS table with the data based on queries. But all the records updates with the same data. I can't understand why.

Write a PL script to populate these columns as follows:

TRAVEL_STATUS is one of three values:
GLOBETROTTER: agent has visited five or more different locations in the course of his missions
ROVER: agent has visited between one and four locations
SLOB: agent has been on no missions.

CONTACTS is the number of targets that share the agent's home location.

some of the tables and columns are
agents table: agent_id, location_id
targets table: target_id, location_id
missions_agents table: agent_id, mission_id
missions_targets: target_id, mission_id
missions table: mission_id, location_id

My code is

DECLARE
status AGENTS.TRAVEL_STATUS%TYPE;
contact AGENTS.CONTACTS%TYPE;
CURSOR loc_cur
IS
SELECT
a.AGENT_ID id,

[code].....

View 7 Replies View Related

SQL & PL/SQL :: Cursors To Update Data And Store It Back To Same Table

Sep 4, 2010

I'm using few cursors to update my data and store it back to the same table. But for some reason the cursor seems to be picking obsolete data.

cursor c1
is
select distinct roles
from table1
where flag = '1';

cursor c2
is
select distinct roles
from table1
where flag = '1';
begin
for i in c1
loop

here im updating the roles im picking to to a suffix and role.

update table1
set role = suffix_role
where 'some condition';
end loop;
commit; -- committing so changes are visible for my next cursor.

for j in c2
loop

here im deleting all the roles that are not part of my comparing table.

delete from table1
where role = 'something';

But in my debugging table i see that its deleting roles present as input for first cursor, whereas it should actually pick data with suffix_roles.

View 12 Replies View Related

Truncate / Drop Partitions In Table Having Nested Table Columns

Sep 7, 2012

I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). how I will be able to truncate/drop partition from this table? IF I change column types from nested table to varray type, will it work?

Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?

View 1 Replies View Related

SQL & PL/SQL :: Using Nested Table

Jan 9, 2013

a material related to collections with Examples and also how to declare table type values.

View 9 Replies View Related

SQL & PL/SQL :: Nested Table Is Same As Multi Value Table In JBASE

Aug 29, 2012

Is Oracle will support Multi value storage ? In what way we can use Nested table? In real time application where we can use nested table . What is the usage of nested table in real time application.

View 2 Replies View Related

SQL & PL/SQL :: What Is The Advantage Of Nested Table

May 17, 2011

what is the advantage of Nested table ?

View 1 Replies View Related

PL/SQL :: Multidimensional Nested Table

Sep 10, 2013

I am studing Multidimensional Nested table and have the below code:

 DECLARE  TYPE table_type1 IS TABLE OF INTEGER;  TYPE table_type2 IS TABLE OF TABLE_TYPE1; 
table_tab1 table_type1 := table_type1(); 
table_tab2 table_type2 := table_type2(table_tab1);
BEGIN  FOR i IN 1 .. 2  LOOP    table_tab2.extend;   
table_tab2(i) := table_type1();   

[Code]...

exception  when others then    dbms_output.put_line(sqlerrm);END; This code is working fine as of now.But,If i comment below code(table_tab2 is also extended latter):

table_tab2.extend;     
table_tab2(i) := table_type1();

then it gives me error 'Subscription Beyond count'. I would like to know why i need to extend table_tab2 twice?!

View 7 Replies View Related

Remove Constraints On Nested Table?

Jul 11, 2011

I want to truncate table partition but I'm getting error:

CODEORA-02266: unique/primary keys in table referenced by enabled foreign keys

because of table has a nested table. Currently this column is not in use so I could drop it, but I want to avoid it (table is huge). Is there another posibility to do truncate partitions in this table? ALTER TABLE ... SET UNUSED doesn't resolve the problem.

View 2 Replies View Related

Materialized View On Nested Table?

Dec 2, 2010

I try to do this:

CREATE MATERIALIZED VIEW MV_NESTED_DATA
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
BUILD IMMEDIATE
USING NO INDEX
REFRESH COMPLETE
ON DEMAND
START WITH ROUND(SYSDATE)
NEXT ROUND(SYSDATE) + 1
WITH ROWID
AS
select NESTED_TABLE_FIELD from MY_TABLE@Y_DB_LINK;

where NESTED_TABLE_FIELD is a nested table stored as T_NESTED_TABLE

And I get the error: ORA-12014: table 'T_NESTED_TABLE' does not contain a primary key constraint

Why should it if I try to create a MV with "WITH ROWID" refresh option and not "WITH PRIMARY KEY" one?

View 4 Replies View Related

Tuning Select With Nested Table?

Feb 18, 2011

I have created table with nested table:

CODECREATE OR REPLACE TYPE ADDR_T AS OBJECT (
ADDR1 VARCHAR2 (50),
ADDR2 VARCHAR2 (50)
);
CREATE OR REPLACE TYPE t_ADDr AS TABLE OF ADDR_T;

[code]....

I have added some records and created index on ID column. I want to get result of CODEselect id, p.addr1,p.addr2 from nested_table n,table(n.COL1) p where id=1

Explain plan for that is:

CODESELECT STATEMENT  ALL_ROWSCost: 8  Bytes: 231  Cardinality: 3              
4 HASH JOIN  Cost: 8  Bytes: 231  Cardinality: 3          
2 TABLE ACCESS BY INDEX ROWID TABLE SYS.NESTED_TABLE Cost: 2  Bytes: 13  Cardinality: 1      
1 INDEX RANGE SCAN INDEX SYS.FDSFAS Cost: 1  Cardinality: 1  
3 TABLE ACCESS FULL TABLE (NESTED) SYS.COL1_TAB Cost: 5  Bytes: 163,840  Cardinality: 2,560

How to avoid full table scan on nested table? Cardinality is sum of all records in nested column in all rows in main table, why?

View 2 Replies View Related

SQL & PL/SQL :: Sorting Collection In Nested Table

Sep 11, 2012

I'm trying to sort a collection in a nested table in PL/SQL so these value can be used later for a display and for export to Excel. The sort is failing.

-- PLS-00642: local collection not allowed in SQL statements

-- PL/SQl: ORA-00902: invalid datatype

The error message are also noted below in the code on the line that fails.

A quick overview of this code- Using a nested table MyNestedTable the values from several select queries are combined into MyRecordsetZero using CURSOR, and MULTISET UNION. I'm trying to either sort MyRecordsetZero or populate MyRecordsetSorted with the sorted values for futher use.

IMPORTANT: The code is running in an enviroment that does not have permission to create.

Versions:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Developer: 8.0.0.1480

DECLARE
-- Declare the variable MyTID to be used by select statements and
-- set its data type and max character count
MyTID varchar2(10);
[code]....

View 13 Replies View Related

SQL & PL/SQL :: Sorting Nested Table / Collection

Nov 10, 2011

In test.pks file I declared the following type

TYPE tab_tests is table of NUMBER(15);

In test.pkb, I have the following procedure

PROCEDURE report (
i_cid IN NUMBER
)
IS
test1 tab_tests := tab_tests();
test2 tab_tests;
BEGIN

-- I populate test1 with the data and it works fine. But when I tried to make a sorted nested table with the following command.

I got this error 'ORA-00902: invalid datatype',

a nested table than the following, like a built in Oracle collection method?

execute immediate 'select cast( multiset (select * from table(test1) order by 1) as tab_tests) INTO test2 FROM dual';
END;

View 16 Replies View Related

SQL & PL/SQL :: Using EXTEND In Nested Table Types?

Mar 4, 2013

need to use Extend() in nested tables in Oracle? What could be the problem if I do not use this method in my code?

I have a nested collection type (TABLE OF VARCHAR2(32)) declared in my package. My stored procedure takes the TABLE type as input and inserts that data into a database table.
I see that my code works fine without using EXTEND method.

View 10 Replies View Related

SQL & PL/SQL :: Nested Table Creation Error

Apr 12, 2010

I am getting compilation error when create nested table type depend on table structure

SQL> CREATE OR REPLACE TYPE typ$nttb$1 IS TABLE OF emp%rowtype
2 ;
3 /

Warning: Type created with compilation errors.

SQL> show error
Errors for TYPE TYP$NTTB$1:

LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
1/29 PLS-00329: schema-level type has illegal reference to SCOTT.EMP
SQL>

View 5 Replies View Related

SQL & PL/SQL :: Can Pass Nested Table To Procedure

Nov 12, 2011

declare
cursor c is
select employee_id from employees;
type nst_type is table of employees.employee_id%type;
emp nst_type;
begin
open C;
loop
exit when C%notfound;
fetch c bulk collect into emp;
end loop;
close c;
end;

Above is the sample code, and now i want to pass 'emp' as an input parameter to the procedure.

How can I do that, as emp is of nst_type type and I do not know how my procedure will recognize the datatype...

View 4 Replies View Related

SQL & PL/SQL :: Oracle Nested Table Not Working?

Sep 21, 2011

I have a query which returns a nested table as a result of split function. I used any method to unnest the data. But I couldn't. I try it with this query.Note: To run the following query I attached everything needed.

-- This query gives very strange results.
SELECT *
FROM
(
SELECT

[code]...

View 18 Replies View Related

SQL & PL/SQL :: Grants On Nested Table To Other User

Jul 16, 2011

I have an issue on selecting data from a nested table owned by other user.

I have given select access on stc_irb_usr.stc_loy_settlebillpay_map_main to anthr user adminofs.

But when I try to query, it says insufficient privileges. adminofs is able to select other columns which are not nested.

I have given "grant execute on STC_IRB_USR.STC_BILLPAY_MAP_TAB_TYPE to adminofs;" but it did not

select * from stc_irb_usr.stc_loy_settlebillpay_map_main where rownum<3;

ERROR: OCI-21700: object does not exist or is marked for delete

SQL> desc stc_irb_usr.stc_loy_settlebillpay_map_main
Name Null? Type
----------------------------------------- -------- ----------------------------
BATCH_NUM NOT NULL NUMBER
ACCOUNT_NUM NOT NULL VARCHAR2(40)
PAY_BILL_SEQ_MAP STC_IRB_USR.STC_BILLPAY_MAP_

[Code]....

Name Null? Type
----------------------------------------- -------- ----------------------------
ALLOCATING_CREDIT_SEQ NUMBER
ALLOCATION_ENTITY_SEQ NUMBER
ALLOCATING_CREDIT_DATE DATE
ALLOCATING_CREDIT_TYPE VARCHAR2(20)
ALLOCATION_ENTITY_DATE DATE

[Code]...

View 2 Replies View Related

Insert Values Into A Nested Table?

May 15, 2013

Insert values into a table. The table is called PurchaseOrder_objtab. Here is the type for the table:

CREATE TYPE PurchaseOrder_objtyp AUTHID CURRENT_USER AS OBJECT
(
PONo NUMBER,
CUST_ref REF Customer_objtyp,
OrderDate DATE,
ShipDate DATE,

[code]...

The LineItemList_ntab is a nested table.

Here is the create code for LineItemList_ntabtyp:

CREATE TYPE LineItem_objtyp AS OBJECT (
LineItemNo NUMBER,
Stock_ref REF StockItem_objtyp,
Quantity NUMBER,
Discount NUMBER
)

[code]...

In the above code, the LineItemList_ntab is an empty LineItemList_ntabtyp. I am wanting to add values to this nested table rather than it being empty in the INSERT INTO code.

Here is some of the code I have tried to insert values with:

INSERT INTO PurchaseOrder_objtab
SELECT 1008, REF(C),
SYSDATE, '12-MAY-1999',
LineItemList_ntabtyp(1, REF(StckItem), 10, 1) FROM Stock_objtab StckItem WHERE StckItem.StockNo = 1004,
NULL

[code]...

The first insert statement above produces the following error:

SQL Error: ORA-00933: SQL command not properly ended

The second insert statement above produces the following error:

SQL Error: ORA-00936: missing expression

successfully insert values into the LineItemList_ntab nested table?

View 6 Replies View Related

PL/SQL :: How To Pass Input Parameter For Nested Table

May 10, 2013

I have a doubt how to pass input parameter for nested table which is declared as input parameter in procedure.

CREATE TYPE t_example AS OBJECT(msg_text VARCHAR2(100), bundle_msg_text VARCHAR2(100), version NUMBER(10))
/
create type t_msg_details ia table of t_example
/CREATE TABLE table_nested_sample
(msg_codes NUMBER(10),
language_id NUMBER(10),

[Code]...

How to call this procedure I want to insert data like this

Msg_codes               Language_id                 Language_name           msg_text_details
101                            1                              ENG                            "msg_test"         "Bundle_msg_text"   1
                                                                                                    "msg_test_1"  "Bundle_msg_text_2"   2

View 5 Replies View Related

Server Utilities :: Exp / Imp Failed On Nested Table

Jun 18, 2013

I am trying to exp/imp database schema from one environmet to other in oracle 11g. I have a couple nested tables (tables with types datatype). Here are the errors I am getting:

ORA-31693: Table data object "IPAM"."BACKEND_POLICY_TYPES" failed to load/unload and is being skipped due to error:
ORA-02354: error in exporting/importing data
ORA-00600: internal error code, arguments: [kpudpxcs_getCol_ref_4], [Imgver=1 InputStrmVer=9 Name=POLICY], [], [], [], [], [], [], [], [], [], []

ORA-31693: Table data object "IPAM"."LB_POLICIES" failed to load/unload and is being skipped due to error:
ORA-02354: error in exporting/importing data
ORA-00600: internal error code, arguments: [kpudpxcs_getCol_ref_4], [Imgver=1 InputStrmVer=9 Name=POLICY], [], [], [], [], [], [], [], [], [], []

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved