Updating a nested table of references
Hi,
Can anyone tell me the syntax for updating a nested table of references?
For example:
CREATE TYPE purchaseorder_ob AS OBJECT(
order_number NUMBER(6),
shipping_date DATE,
city VARCHAR2(30),
orderlineitem orderlineitem_va);
CREATE TYPE refpurchaseorder_tab AS TABLE of REF purchaseorder_ob;
CREATE TYPE customer_ob AS OBJECT(
customer_number NUMBER(5),
customer_name VARCHAR2(50),
city VARCHAR2(30),
reftopurchaseorder refpurchaseorder_tab)
NOT FINAL;
CREATE TABLE customer_t OF customer_ob (customer_number Primary key)
NESTED TABLE reftopurchaseorder STORE AS reftopurchaseorder_nt;
UPDATE customer_t
SET reftopurchaseorder = ???????
WHERE customer_number = 1;
What do I put for ??????
Any help would be greatly appreciated.
Fernanda.
Type declarations are not complete, nevertheless for example:
SQL> CREATE TYPE orderlineitem_va AS VARRAY(10) of NUMBER(10);
2 /
Type created.
SQL> CREATE OR REPLACE TYPE purchaseorder_ob AS OBJECT(
2 order_number NUMBER(6),
3 shipping_date DATE,
4 city VARCHAR2(30),
5 orderlineitem orderlineitem_va);
6 /
Type created.
SQL> CREATE TYPE refpurchaseorder_tab AS TABLE of REF purchaseorder_ob;
2 /
Type created.
SQL> CREATE TYPE customer_ob AS OBJECT(
2 customer_number NUMBER(5),
3 customer_name VARCHAR2(50),
4 city VARCHAR2(30),
5 reftopurchaseorder refpurchaseorder_tab)
6 NOT FINAL;
7 /
Type created.
SQL> CREATE TABLE customer_t OF customer_ob (customer_number Primary key)
2 NESTED TABLE reftopurchaseorder STORE AS reftopurchaseorder_nt;
Table created.
SQL> desc customer_t
Name Null? Type
CUSTOMER_NUMBER NOT NULL NUMBER(5)
CUSTOMER_NAME VARCHAR2(50)
CITY VARCHAR2(30)
REFTOPURCHASEORDER REFPURCHASEORDER_TAB
SQL> insert into customer_t values(customer_ob(1,'James','Dublin',null));
1 row created.
SQL> commit;
Commit complete.
SQL> create table purchase_t of purchaseorder_ob;
Table created.
SQL> insert into purchase_t values(purchaseorder_ob(1,sysdate,'London',null));
1 row created.
SQL> insert into purchase_t values(purchaseorder_ob(2,sysdate,'London',null));
1 row created.
SQL> commit;
Commit complete.
SQL> select ref(p) from purchase_t p;
REF(P)
000028020918B2D893716E47CE91690542A6898D71432C6F6282764771BFD25979B8BCB3DB01000C
2D0000
0000280209EA531A4F6833495A9AF846C57A846A4D432C6F6282764771BFD25979B8BCB3DB01000C
2D0001
SQL> update customer_t
2 set REFTOPURCHASEORDER =
3 CAST(MULTISET(SELECT REF(p) FROM purchase_t p) AS REFPURCHASEORDER_TAB)
4 WHERE customer_number = 1
5 /
1 row updated.
SQL> commit;
Commit complete.
SQL> select * from customer_t;
CUSTOMER_NUMBER CUSTOMER_NAME
CITY
REFTOPURCHASEORDER
1 James
Dublin
REFPURCHASEORDER_TAB(000022020818B2D893716E47CE91690542A6898D71432C6F6282764771B
FD25979B8BCB3DB, 0000220208EA531A4F6833495A9AF846C57A846A4D432C6F6282764771BFD25
979B8BCB3DB)Rgds.
Similar Messages
-
Hi guys,
I have following nested table and I need to perform an update to the BRIDGE_GEOM nested table. Can somebody help me?
CREATE TABLE BRIDGE
BRIDGE_GEOM MDSYS.SDO_GEOMETRY,
MSLINK NUMBER(10) NOT NULL,
CREATE INDEX BRIDGE_RTREE_X ON BRIDGE
(BRIDGE_GEOM)
INDEXTYPE IS MDSYS.SPATIAL_INDEX
PARAMETERS('SDO_DIMENSIONALITY=3 SDO_FANOUT=35 SDO_INDX_DIMS=2');
CREATE OR REPLACE
TYPE MDSYS.SDO_POINT_TYPE AS OBJECT (X NUMBER,Y NUMBER,Z NUMBER)
CREATE OR REPLACE
TYPE MDSYS.SDO_ELEM_INFO_ARRAY AS VARRAY (1048576) of NUMBER
CREATE OR REPLACE
TYPE MDSYS.SDO_ORDINATE_ARRAY AS VARRAY(1048576) OF NUMBER
CREATE OR REPLACE
TYPE MDSYS.SDO_GEOMETRY AS OBJECT (
SDO_GTYPE NUMBER,
SDO_SRID NUMBER,
SDO_POINT SDO_POINT_TYPE,
SDO_ELEM_INFO SDO_ELEM_INFO_ARRAY,
SDO_ORDINATES SDO_ORDINATE_ARRAY)
/Hi!
Pls check the following code --
update bridge
set bridge_geom = MDSYS.SDO_GEOMETRY(5,
3,
SDO_POINT_TYPE(5,9,10),
SDO_ELEM_INFO_ARRAY(5),
SDO_ORDINATE_ARRAY(9)
where MSLINK = 15
/Though i got error while running ur script --
SQL> CREATE OR REPLACE
2 TYPE MDSYS.SDO_GEOMETRY AS OBJECT (
3 SDO_GTYPE NUMBER,
4 SDO_SRID NUMBER,
5 SDO_POINT SDO_POINT_TYPE,
6 SDO_ELEM_INFO SDO_ELEM_INFO_ARRAY,
7 SDO_ORDINATES SDO_ORDINATE_ARRAY)
8 /
CREATE OR REPLACE
ERROR at line 1:
ORA-02303: cannot drop or replace a type with type or table dependentsN.B.: Not Tested.....
Regards.
Satyaki De. -
How do I update a Nested Table of inherited Object Types?
Does anyone know why the following line (commented out) doesn't work and what I can do? Is there some way to cast the column I am trying to update? I think I am going crazy....
create or replace type person_ot as object (name varchar2(10)) not final;
create or replace type student_ot under person_ot (s_num number) not final;
create type person_tt as table of person_ot;
declare
lv_person_list person_tt;
lv_sql varchar2(1000);
ref_cur sys_refcursor;
begin
lv_sql:= 'select new student_ot(''fred'', 100) from dual
union all
select new student_ot(''sally'', 200) from dual';
open ref_cur for lv_sql;
fetch ref_cur bulk collect into lv_person_list;
close ref_cur;
dbms_output.put_line(lv_person_list.count);
for i in lv_person_list.first..lv_person_list.last loop
lv_person_list(i).name := initcap(lv_person_list(i).name ); -- This works!
lv_person_list(i).s_num := 9999; Why doesn't this line work and how can I update the column s_num ??? :-(
end loop;
end;
/Hi Tubby - You are right...It would make sense to create the Type as type of student_ot. Only problem is I am trying to keep it generic. I will include full listing to show what I am doing...
create or replace type person_ot as object (name varchar2(10)) not final;
create or replace type student_ot under person_ot (s_num number) not final;
create type person_tt as table of person_ot;
create table persons of person_ot;
declare
lv_person_list person_tt;
lv_sql varchar2(1000);
ref_cur sys_refcursor;
begin
lv_sql:= 'select new student_ot(''fred'', 100) from dual
union all
select new student_ot(''sally'', 200) from dual';
open ref_cur for lv_sql;
fetch ref_cur bulk collect into lv_person_list;
close ref_cur;
for i in lv_person_list.first..lv_person_list.last loop
lv_person_list(i).name := initcap(lv_person_list(i).name );
lv_person_list(i).s_num := 9999;* Why doesn't this line work?? :-(
end loop;
forall i in lv_person_list.first..lv_person_list.last
insert into persons values lv_person_list(i);
end;
/ -
How to update Nested tables with xsu
Hello,
I have three tables.
1) DEPARTMENT_TAB
2) EMPLOYEE_TYP
3) ADDRESS_TYP
ADDRESS_TYP is a collection and it is nested inside EMPLOYEE_TYP.
EMPLOYEE_TYP is a collection and it is nested inside DEPARTMENT_TAB.
created with below scropt
CREATE TYPE ADDRESS_TYP AS OBJECT (CITY VARCHAR2(10), STATE VARCHAR2(2));
CREATE TYPE ADDRESS_TYP_NT AS TABLE OF ADDRESS_TYP;
CREATE TYPE EMPLOYEE_TYP AS OBJECT (EMPNO NUMBER(4), ENAME VARCHAR2(10), ADDRESS_VAR ADDRESS_TYP_NT);
CREATE TYPE EMPLOYEE_TYP_NT AS TABLE OF EMPLOYEE_TYP;
CREATE TABLE DEPARTMENT_TAB (DEPTNO NUMBER(4), DNAME VARCHAR2(10), EMPLOYEE_VAR EMPLOYEE_TYP_NT)
NESTED TABLE EMPLOYEE_VAR STORE AS EMPLOYEE_TAB
( NESTED TABLE ADDRESS_VAR STORE AS ADDRESS_TAB);
I inserted two rows in DEPARTMENT_TAB and their nested tables using normalsql. and i generated below xml content using XSU java API
oracle.xml.sql.query.OracleXMLQuery
My Question is How to UPDATE a row in ADDRESS_TAB using XSU java API
oracle.xml.sql.dml.OracleXMLSave.
(When i was trying to update address_tab nested table's row with xml input file. it is deleting other existing rows)
Thanks.Why do you say it does not work?
-
Hi
I have created one nested table with the follwing columns. I have to insert records into the nested table. And also I have to update the nested table. Please find below my table and getting error message.
Please advose...!!
SQL> create type details as object(
2 basic number(7,2),
3 da number(6,2),
4 hra number(6,2),
5 pf number(6,2),
6 it number(6,2),
7 gross number(7,2),
8 ded number(6,2),
9 net number(8,2));
10 /
Type created.
SQL> create type details_t is table of details;
2 /
Type created.
SQL> ed
Wrote file afiedt.buf
1 create table emp_tab(empno number(4),name varchar2(10),details_tab details_t)
2* nested table details_tab store as empl_details
SQL> /
Table created.
SQL> ed
Wrote file afiedt.buf
1* insert into emp_tab values(&empno,'&name',details_t(details(&da,&hra,&pf,&it,null,null,null)))
SQL> /
Enter value for empno: 1
Enter value for name: asdf
Enter value for da: 120
Enter value for hra: 130
Enter value for pf: 120
Enter value for it: 120
old 1: insert into emp_tab values(&empno,'&name',details_t(details(&da,&hra,&pf,&it,null,null,null
new 1: insert into emp_tab values(1,'asdf',details_t(details(120,130,120,120,null,null,null)))
insert into emp_tab values(1,'asdf',details_t(details(120,130,120,120,null,null,null)))
ERROR at line 1:
ORA-02315: incorrect number of arguments for default constructorCan I use '&' while inserting records into nested table? yes / no ?
I have to update gross, ded, net columns also..!!
Please help me..!!
Regards
Azep@dev>
zep@dev> create type details as object
2 (
3 basic number(7, 2),
4 da number(6, 2),
5 hra number(6, 2),
6 pf number(6, 2),
7 it number(6, 2),
8 gross number(7, 2),
9 ded number(6, 2),
10 net number(8, 2)
11 )
12 /
Type created
zep@dev> create type details_t is table of details
2 /
Type created
zep@dev> create table emp_tab(empno number(4),name varchar2(10),details_tab details_t)
2 nested table details_tab store as empl_details
3 /
Table created
zep@dev> insert into emp_tab
2 values
3 (1,
4 'asdf',
5 details_t(details(120, 130, 120, 120, 1, 2, 3, 4)));
1 row inserted
zep@dev>
zep@dev> select *
2 from table (select details_tab
3 from emp_Tab t
4 where t.empno = 1);
BASIC DA HRA PF IT GROSS DED NET
120,00 130,00 120,00 120,00 1,00 2,00 3,00 4,00
zep@dev> -- second object in the same empno = 1
zep@dev> insert into table
2 (select details_tab
3 from emp_Tab t
4 where t.empno = 1)
5 values
6 (details(200, 230, 220, 220, 10, 11, 12, 13));
1 row inserted
zep@dev>
zep@dev> select *
2 from table (select details_tab
3 from emp_Tab t
4 where t.empno = 1);
BASIC DA HRA PF IT GROSS DED NET
120,00 130,00 120,00 120,00 1,00 2,00 3,00 4,00
200,00 230,00 220,00 220,00 10,00 11,00 12,00 13,00
zep@dev>
zep@dev> update table (select details_tab
2 from emp_Tab t
3 where t.empno = 1)
4 set gross = nvl(basic,0) + nvl(da,0) + nvl(hra,0),
5 ded = nvl(pf,0) + nvl(it,0),
6 net = nvl(gross,0) - nvl(ded,0)
7 where basic = 120;
1 row updated
zep@dev>
zep@dev> select *
2 from table (select details_tab
3 from emp_Tab t
4 where t.empno = 1);
BASIC DA HRA PF IT GROSS DED NET
120,00 130,00 120,00 120,00 1,00 370,00 121,00 -1,00
200,00 230,00 220,00 220,00 10,00 11,00 12,00 13,00
zep@dev> -
How to update nested table records ??
Hi, I am just starting to write anything in PL/SQL and having some difficulties with basic syntax. Thanks for any help in advance.
My problem is how to update collection (nested table of objects) with SQL statement. My nested table is not a column of regular table.
Example:
CREATE OR REPLACE TYPE tmpRec AS OBJECT(
Col1 INT,
Col2 INT
CREATE OR REPLACE TYPE tmpTable IS TABLE OF tmpRec;
DECLARE v tmpTable :=
tmpMBATable(
tmpRec(1,1),
tmpRec(2,2),
tmpRec(3,3),
BEGIN
--UPDATE TABLE(CAST(v AS tmpTable)) T SET T.Col2 = 1 WHERE T.Col1 =1;
--UPDATE TABLE(v) T SET T.Col2 = 12 WHERE T.Col1 =1;
--UPDATE (SELECT * FROM TABLE(v) )T SET T.Col2 = 12 WHERE T.Col =1;
END;
I am getting either
PL/SQL: ORA-22841: DML is not allowed on PL/SQL Collections
OR
PL/SQL: ORA-00903 Bad table name.
I found there is no problem when collection is a column of DB table (UPDATE TABLE(select collection_column from table) T SET T.Col2 = 12 WHERE T.Col1 =1;) but i want it to be just a collection without storing it in DB, is it possible ?
Please help.898539 wrote:
Thanks, for fast answer but my problem is more complex, maybe you can show me some workaround i try to use collection but maybe i should do something else...A complex problem does not mean a complex solution. In fact, complex problems should ideally be solved by breaking the complexity down into simpler components and then solving each of these in turn.
As far as nested tables go? An interesting feature. But one that I will need a lot of convincing and justification for to consider for a production system. There are some major limitations with using nested tables. And these do not exist when using the simpler form of a standard relational child table instead.
I am migrating from Sybase Adaptive Server Enterprise and searching for sollution for something we used temporary tables for so far.Temporary tables in Sybase are typically used to prevent concurrency issues (readers and writers blocking one another). Thus make a temp copy of the data and do not prevent concurrent access to the source data itself.
These reasons simply do not exist in Oracle. In most cases, using temporary tables in Oracle simply because that is how it was implemented in Sybase, would be fundamentally flawed.
Oracle is not Sybase. It does a very poor imitation of Sybase.
I need a collection that can store some data and I need to be able to use it as a table so I can join to it via SQL query or call some DML on it.Why do you need a collection? The best place for data in Oracle is inside a table. Not inside a collection - especially not if that collection resides in PGA memory in the PL/SQL engine.
In my store procedure I am updating, deleteing and inserting some data to it depends on context.What context? Oracle supports context namespaces - often used for virtual private database (VPDB) implementations. If you are referring to scope instead - there are a number of ways that Oracle supports scope too.
The bottom line is that you should not approach this problem with "+how do I convert this Sybase method into an Oracle method+". Instead you need to look at the business requirement that the Sybase method addresses and then determine how best to address that requirement using Oracle. -
How do I reference a column in a nested table in a trigger. I am issuing an update statement:
UPDATE TABLE (SELECT inv_level
FROM inventory_level
WHERE machine_id = '1111'
SET inventory_level = '15'
WHERE column_id = '2'
I want to create a trigger that execute before the insert. I want to insert the machine_id, the column_id, inventory_level into a change history table. The issue is he column_id and inventory_level fields are in the nested table. I tried to reference them as :NEW.column_id, but that didn't work.I too have had problems working with triggers & nested tables. This may help
Imagine the scenario of a table that holds customer data that needs a specific record per user of the database to indicate if they can contact that customer.
To solve this I created the following
create type contact_type as object
(username varchar2(30),
can_mail number,
can_phone number);
create type contact_nt_type as table
of contact_type;
--table cust
create table cust_table(
custid number,
custname varchar2(50),
contact_nt contact_nt_type)
nested table contact_nt store as contact_nt_tab;
-- populate tables
insert into cust_table
values(1001,'Customer1',
contact_nt_type(
contact_type('SCOTT',1,0),
contact_type('TIMS',0,1)));
insert into cust_table
values(1002,'Customer2',
contact_nt_type(
contact_type('SCOTT',0,0),
contact_type('TIMS',0,0)));
-- view cust_vu
create or replace view cust_vu
as
select ct.custid, ct.custname, nt.can_mail, nt.can_phone
from cust_table ct, table(ct.contact_nt) nt
where nt.username = user;
Now, if scott looks at the customer through the view he sees one set of contact details and if I look I see another. But if we try to update the view we get
ORA-01733: virtual column not allowed here
To solve this create an "instead of" trigger
create or replace trigger cust_vu_update
instead of update on cust_vu
for each row
begin
-- update the parent table
update cust_table
set custname = :new.custname
where custid = :old.custid;
-- update the nested table
update table(
select contact_nt
from cust_table
where custid = :old.custid)
set can_mail = :new.can_mail,
can_phone = :new.can_phone
where username = user;
end;
The documentation has a whole section on triggers & nested tables which, for me, did not solve any of my issues. Following the Create trigger syntax, specifically the dml_event_clause, caused me 0600 errors and my session was terminated!
There may be better solutions but this one works for me. -
Tables in memory (Nested tables ?)
For performance reasons, I would like to insert, update, etc...
a table in memory. Can I use a nested table as if it was a
normal table ? Can I do updates on nested tables with values
from normal database tables ??
Statement like : Update <nested-table> set <nested-
table>.x=<value> where <nested-table>.y = <normal-table>.y
Thanks for a quick response.The answer is yes and no.
A nested table is a "collection" and can be referenced in a SQL
statement using the pseudo-functions THE, CAST, MULTISET and
TABLE. The nested table and varray collections can be a column
in a database table (Oracle8) and are persistent. SQL
statements cannot act on memory held nested tables, varray and
index-by collections, which are transient. Index-by collections
are same as the older PL/SQL tables.
SQL statements cannot operate directly on transient collections.
For speed you can define an index-by collection as a table of
rowtype, and move data back and forth from database tables and
memory held tables using SQL. Records and index-by tables are
more efficient in Oracle 8 than in Oracle 7
In PL/SQL you can use replacement (:=) on the record or
record.column of the rowtype index-by collection. The downside
is you have to keep track of your own indexing which is only
BINARY_INTEGER, no SELECT, UPDATE, INSERT using FROM and WHERE
on transient collections. This works in Oracle 7 also.
Good Luck. -
How to update a column in a nested table for a given record in the master t
Hi I have translations for all attributes of an item stored as a nested table
CREATE OR REPLACE TYPE T_ITM_ATTR AS OBJECT(
ATTR_NM VARCHAR2(30),
ATTR_VAL VARCHAR2(200 CHAR),
ATTR_STS_BL NUMBER(1))
INSTANTIABLE
FINAL
CREATE OR REPLACE TYPE T_ITM_ATTRIBUTES AS TABLE OF T_ITM_ATTR;
CREATE TABLE XGN_MOD_ITEMS_T
IDS NUMBER,
MOD_IDS NUMBER NOT NULL,
MOD_ITM_IDS NUMBER NOT NULL,
LGG_ID VARCHAR2(3 CHAR) NOT NULL,
ITM_TYPE VARCHAR2(50 CHAR) NOT NULL,
ITM_NM VARCHAR2(50 CHAR) NOT NULL,
ITM_BLOCK VARCHAR2(50 CHAR),
ITM_ATTR T_ITM_ATTRIBUTES,
ITM_COL1 VARCHAR2(1 CHAR),
ITM_DSC VARCHAR2(100 CHAR),
CREATED_BY VARCHAR2(30 CHAR) DEFAULT USER NOT NULL,
CREATION_DATE DATE DEFAULT SYSDATE NOT NULL,
LAST_UPDATED_BY VARCHAR2(30 CHAR),
LAST_UPDATE_DATE DATE
NESTED TABLE ITM_ATTR STORE AS NESTED_ITM_ATTR_T
TABLESPACE XGN4_TAB
PCTUSED 40
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
What I want to do is to update only the attr_val of each item to a value coming from a temporary table where the user inserted his translations
So how can I update ?
this doesn't work since I have to know the previous value?
update table(
select t2.attr_val
from XGN_MOD_ITEMS_T t1, table(t1.itm_attr) t2
where t1.mod_itm_ids=160) attr
set value(attr) = 'Profil'
where value(attr) = 'Profile'
This updates all occurences for all entries wich doesn't work either because I have for each language another record
UPDATE /*+ NESTED_TABLE_GET_REFS */
NESTED_ITM_ATTR_T
SET attr_val = 'SHIT'
WHERE attr_val = 'Profile'http://www.psoug.org/reference/nested_tab.html
Look for UPDATE. There is a working demo on the page.
That said nested tables are not a good place to store data. Reconsider using relational tables with, if necessary, object views. -
Nested table - how to reference internal column without a name??
Hi guys, I've a question regarding nested tables - Ive searched around and cant find an answer.
Heres my sample code :
CREATE OR REPLACE TYPE scotttype AS table of number;
create table scott1 (col_a varchar2(10), col_b scotttype) nested table col_b store as col_b
insert into scott1 values ('onetwo',scotttype(1,2))
insert into scott1 values ('threefour',scotttype(3,4))
select t1.col_a, column_value col_b
from scott1 t1, TABLE(t1.col_b) t2
insert into table(select s.col_b FROM scott1 s WHERE s.col_a = 'onetwo')
values (5);Ok, so that seems fine.
If I want to do an update or delete though, how can I reference col_b as the nested table doesnt have a column name ?
Ie :
update table(select col_b from scott1 where col_a = 'onetwo') col_b
set col_b.XXXXX = 6
where col_b.XXXXX = 5won't work - so what do I put in place of the XXXXX ???
I'm sure its simple, but I can't find it!
Thanks allSQL> select t1.col_a, column_value col_b
2 from scott1 t1, TABLE(t1.col_b) t2;
COL_A COL_B
onetwo 1
onetwo 2
threefour 3
threefour 4
onetwo 5
SQL> commit;
Commit complete.
SQL> update table(select col_b c1 from scott1 where col_a = 'onetwo') t1
2 set column_value = 6
3 where column_value= 5;
1 row updated.
SQL> commit;
Commit complete.
SQL> select t1.col_a, column_value col_b
2 from scott1 t1, TABLE(t1.col_b) t2;
COL_A COL_B
onetwo 1
onetwo 2
threefour 3
threefour 4
onetwo 6
SQL> -
How to insert reference of object in nested table
hi , i have a problem with nested table :
CREATE OR REPLACE TYPE ITEM AS OBJECT
ITEM_ID NUMBER,
ITEM_DES VARCHAR2(4000),
PRODUCT_NO VARCHAR2(15),
PRODUCT_DES VARCHAR2(4000)
CREATE TABLE ITEMS OF ITEM
CONSTRAINT ITEM_PK PRIMARY KEY (ITEM_ID)
CREATE OR REPLACE TYPE BOM AS OBJECT
BOM_ID NUMBER,
ITEM_ID NUMBER,
BOM_PARENT_ID number
create or replace type boms as table of ref bom;
create table bom_table
bom_ids bom,bom_member boms
) nested table bom_member store as bom_childs;
insert into bom_table (bom(1,1,null),null);
insert into bom_table (bom(2,1,1),boms(select ref(t) from bom_table t where t.bom_id=1))
show error.
how i can insert in nested table reference of object
thanksyour table "bom_table" is not an object table or view, and thus you can't create object references to it's rows. you'll need to create an object table or view of "bom" objects, with a corresponding object identifier, and then reference that table/view in your subquery instead.
Gerard -
Hi All,
I have a update problem in nested table.
Below is my query:
CREATE OR REPLACE TYPE TRACER.SEARCH_DATA AS TABLE OF VARCHAR2(20);
UPDATE TRACER_SEARCH_SCHEDULE_LOT_NUM
SET NOT_FOUND_SOR_LOT_NUM = SEARCH_DATA(
SELECT
COLUMN_VALUE
FROM
TABLE (SELECT SORTING_LOT_NUMBER FROM TRACER_SEARCH_SCHEDULE_LOT_NUM WHERE JOB_ID = 8)
WHERE
TRIM(COLUMN_VALUE) NOT IN (SELECT DISTINCT (SORTING_LOT_NUMBER) FROM SEARCH_SCHEDULE_RESULT_LOT_NUM WHERE JOB_ID = 8)
) WHERE JOB_ID = 8;
ORA-00936: missing expression
or I try as following
DECLARE
sor_lot_num_not_found SEARCH_DATA :=
SEARCH_DATA
SELECT
FROM
TABLE (SELECT SORTING_LOT_NUMBER FROM TRACER_SEARCH_SCHEDULE_LOT_NUM WHERE JOB_ID = 8)
WHERE
TRIM(COLUMN_VALUE) NOT IN (SELECT DISTINCT (SORTING_LOT_NUMBER) FROM SEARCH_SCHEDULE_RESULT_LOT_NUM WHERE JOB_ID = 8)
BEGIN
UPDATE TRACER_SEARCH_SCHEDULE_LOT_NUM SET NOT_FOUND_SOR_LOT_NUM = sor_lot_num_not_found WHERE JOB_ID = 8;
END;
ORA-06550: line 5, column 9:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( ) - + case mod new not null others <an identifier>
table avg count current exists max min prior sql stddev sum
variance execute multiset the both leading trailing forall
merge year month DAY_ hour minute second timezone_hour
timezone_minute timezone_region timezone_abbr time timestamp
interval date
<a string literal with character set specificat
ORA-06550: line 11, column 5:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
; for and or group having intersect minus order start union
where connect
ORA-06550: line 14, column 4:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted d
I have try on the Select Statement, it work. So is it the way that I assign data from nested table and update method is wrong?
Edited by: skymonster84 on Mar 8, 2011 5:12 PMHi,
I think MULTISET operators might interest you.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/operators006.htm
Not tested :
UPDATE tracer_search_schedule_lot_num
SET not_found_sor_lot_num =
sorting_lot_number
MULTISET EXCEPT ALL
CAST(
MULTISET(
SELECT distinct sorting_lot_number
FROM search_schedule_result_lot_num
WHERE job_id = 8
AS search_data
WHERE job_id = 8
; -
HOw to improve insert/update/select for nested table.
Hi All,
I think this is my second thread for nested table.
i just want to know what are the different ways available to improve the insert/update/select operation on Nested table.
Thanks in advance.By not using a nested table for data storage in the first place...
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:8135488196597
Perhaps Parallel Query/DML might give some relief. -
Nested table updation in FOR Cursor loop
Hello,
I have nested table as follows:
SQL> desc fp
Name Null? Type
ORDER_NUM NOT NULL VARCHAR2(10)
ORDER_TIE_NUM NOT NULL VARCHAR2(10)
FACILITY NOT NULL VARCHAR2(10)
ON_SHORTS NUMBER(2)
ACTIVE_SHORTS NUMBER(2)
PARTS DPM_TRANSFORM_CODE.FP_SLC_SHORT
FIRST_SHORT DATE
LAST_SHORT DATE
SQL> desc DPM_TRANSFORM_CODE.FP_SLC_SHort
DPM_TRANSFORM_CODE.FP_SLC_SHort TABLE OF DPM_TRANSFORM_CODE.FP_SHORT_INFO
Name Null? Type
PART_NUM VARCHAR2(7)
AREA VARCHAR2(7)
PART_QTY NUMBER(3)
ON_SHORT_CNT NUMBER(4)
OFF_SHORT_CNT NUMBER(4)
FIRST_DATE DATE
LAST_DATE DATE
UPDATE TABLE(SELECT PARTS FROM DPM_REPORTING.FP WHERE ORDER_NUM = P.ORDER_NUM AND ORDER_TIE_NUM = P.ORDER_TIE_NUM) PARTS
SET PARTS.OFF_SHORT_CNT = PARTS.OFF_SHORT_CNT + 1
WHERE PARTS.last_date < SYSDATE - 2/24;
This Update Statement is in FOR Cursor Loop
where select statement for the cursor is
"SELECT ORDER_NUM,ORDER_TIE_NUM,PARTS FROM DPM_REPORTING.FP WHERE FACILITY = 'PN1'"
This select statement generates 20000 records & due to which the Update statement gets executed that many times inside FOR loop.The Procedure has become quite slow due to this.
Please help.
Thanks,
RekhaYou could do it all in one sql update statement, without any pl/sql or cursor or looping:
UPDATE fp t1
SET t1.parts =
CAST (MULTISET (SELECT part_num, area, part_qty, on_short_cnt,
CASE WHEN last_date < SYSDATE - 2/24
THEN off_short_cnt + 1
ELSE off_short_cnt
END,
first_date, last_date
FROM TABLE (SELECT parts
FROM fp
WHERE facility = 'PN1'
AND order_num = t1.order_num
AND order_tie_num = t1.order_tie_num))
AS fp_slc_short)
WHERE t1.facility = 'PN1'
/ -
Nested table update gets ORA-00904 with ExecuteSQL, error-free in TOAD
I'm trying to run an UPDATE query through the ExecuteSQL method
of the oraDatabase object. The catch seems to be that this one
affects a nested table (field to be updated is a table itself).
This SQL runs perfectly in T.O.A.D. ...
UPDATE B457.AIRLINE a SET
a.rental_cust_code=B457.RENTCUSTCODELIST(rentcustcodes
('45645'),rentcustcodes('1234'),rentcustcodes('234234')) WHERE
a.AIRLINE_CODE='RCR'
...but, it produces the "SQL execution error, ORA-00904: invalid
column name" when run using ExecuteSQL.
Do I need to use a different syntax?and the complete example
SQL> create or replace TYPE t_indirizzo AS OBJECT (
2 via VARCHAR(45),
3 numero NUMBER,
4 cap INTEGER(5),
5 citta VARCHAR(30),
6 provincia VARCHAR(30),
7 regione VARCHAR(30)
8 );
9 /
Type created.
SQL>
SQL>
SQL> create or replace TYPE t_telefono AS OBJECT (
2 num_tel NUMBER(15)
3 );
4 /
Type created.
SQL>
SQL> create or replace TYPE t_listaTelefono AS TABLE OF t_telefono
2 /
Type created.
SQL>
SQL> create or replace TYPE t_cliente AS OBJECT (
2 cod_cliente NUMBER(8),
3 indirizzo t_indirizzo,
4 email VARCHAR(30),
5 telefono t_listaTelefono
6 ) NOT FINAL;
7 /
Type created.
SQL>
SQL> CREATE TABLE cliente OF t_cliente(
2 cod_cliente NOT NULL,
3 indirizzo NOT NULL,
4 email NOT NULL,
5 PRIMARY KEY (cod_cliente)
6 ) nested table telefono store as numTelCli_tab
7 return as value
8 /
Table created.
SQL>
Maybe you are looking for
-
Opening pdf's in applications from safari - ipad
When opening a pdf in an application from safari (i.e. pdf expert, goodreader) the pdf name does not show correctly. Is there a way to properly create the pdf or open it differently to keep the name in the application? Thank you, Tom
-
Download of JHeadstart not working
Has anyone had a problem downloading JHeadstart? I go to http://www.oracle.com/technology/consulting/9iServices/JHeadstart.html click on download to which I get the "agree to our license," I agree then get brought back to the original page. I have tr
-
How can I change the margin for the header/footer?
The header/footer are about .5 from the top/bottom but I want them at about .3/.4. How can I change this?
-
Hi I have had my iPod touch for 2 years with out apple care and for some reason every 5 minutes my iPod touch would flash a white screen and then just die. I know apple cant do anything because I am out warrenty =( any suggestions?
-
i have the Adobe CS3 design premium and the CD but i have a new mac and can't use the CD to download the product. I have the series number as well just need to find where to download the product