Message split for nested tables
Hi all,
within PI 7.1 I want to split a message into multiple messages. But unfortunately using functions "UseOneAsMany" or "Concat" alone do not help me at all.
I think I need to combine this some how...
My source message has simplified following structure (including cardinality in brackets):
<OrderIn (1..1)>
<OrderData (1..n)>
<OrderDetails (1..1)>
<OrderNumber (1..1)></OrderNumber>
<Customer (1..1)></Customer>
</OrderDetails>
<DistirbutionRules (1..n)>
<Rule (1..1)></Rule>
<Description (1..1)></Description>
</DistirbutionRules>
</OrderData>
<TargetSystem (1..1)>
<SystemID (1..n)></SystemID>
</TargetSystem>
</OrderIn>
My target message has simplified following structure (including cardinality in brackets):
<OrderOut (1..n)>
<OrderData (1..n)>
<TargetSystem (1..1)></TargetSystem>
<OrderDetails (1..1)>
<OrderNumber (1..1)></OrderNumber>
<Customer (1..1)></Customer>
</OrderDetails>
<DistirbutionRules (1..n)>
<Rule (1..1)></Rule>
<Description (1..1)></Description>
</DistirbutionRules>
</OrderData>
</OrderOut>
So as incomming message I can have multiple orders and multiple target systems.
As result of the mapping I need one message per target system including all orders in the message.
As long as I have only one Order (OrderData) within the message and only one DistributionRule I can work with function UseOneAsMany as described.
But as soon as more than one Order or DistributionRule is defined I get a conversion error "Too many values in the first queue in function useOneAsMany".
Here the UseOneAsMany mapping (as Text Preview):
/ns0:Messages/ns0:Message1/ns1:RJ_SalesOrderOut/OrderData=SplitByValue(useOneAsMany(/ns0:Messages/ns0:Message1/ns1:RJ_SalesOrderIn/OrderData, /ns0:Messages/ns0:Message1/ns1:RJ_SalesOrderIn/TargetSystem/SystemID, /ns0:Messages/ns0:Message1/ns1:RJ_SalesOrderIn/TargetSystem/SystemID, result), type=0)
When I use only the Concat function I get no error even if I have multiple OrderData but only the first OrderData or DistributionRule is mapped to the target structure.
Here the Concat mapping (as Text Preview):
/ns0:Messages/ns0:Message1/ns1:OrderOut/OrderData=SplitByValue(concat(/ns0:Messages/ns0:Message1/ns1:OrderIn/OrderData, ifWithoutElse(exists(/ns0:Messages/ns0:Message1/ns1:OrderIn/TargetSystem/SystemID), const(value=), keepss=false), delimeter=), type=0)
regards
René
Hi Damian,
have a look at the hierarchy. Within the Source Structure "TargetSystem" and "OrderData" are independent from each other. To get the target messages I want to copy the whole "OrderData" table as many times as I have target systems. Like:
<OrderIn>
<OrderData>
<OrderDetails>
<OrderNumber>1</OrderNumber>
<Customer>Cust1</Customer>
</OrderDetails>
<DistirbutionRules>
<Rule>Rule1</Rule>
<Description>Desc1</Description>
</DistirbutionRules>
</OrderData>
<OrderData>
<OrderDetails>
<OrderNumber>2</OrderNumber>
<Customer>Cust2</Customer>
</OrderDetails>
<DistirbutionRules>
<Rule>Rule2</Rule>
<Description>Desc2</Description>
</DistirbutionRules>
</OrderData>
<TargetSystem>
<SystemID>A</SystemID>
<SystemID>B</SystemID>
</TargetSystem>
</OrderIn>
After mapping and splitting I want to get:
<OrderOut>
<OrderData>
<TargetSystem>A</TargetSystem>
<OrderDetails>
<OrderNumber>1</OrderNumber>
<Customer>Cust1</Customer>
</OrderDetails>
<DistirbutionRules>
<Rule>Rule1</Rule>
<Description>Desc1</Description>
</DistirbutionRules>
</OrderData>
<OrderData>
<TargetSystem>A</TargetSystem>
<OrderDetails>
<OrderNumber>2</OrderNumber>
<Customer>Cust2</Customer>
</OrderDetails>
<DistirbutionRules>
<Rule>Rule2</Rule>
<Description>Desc2</Description>
</DistirbutionRules>
</OrderData>
</OrderOut>
<OrderOut>
<OrderData>
<TargetSystem>B</TargetSystem>
<OrderDetails>
<OrderNumber>1</OrderNumber>
<Customer>Cust1</Customer>
</OrderDetails>
<DistirbutionRules>
<Rule>Rule1</Rule>
<Description>Desc1</Description>
</DistirbutionRules>
</OrderData>
<OrderData>
<TargetSystem>B</TargetSystem>
<OrderDetails>
<OrderNumber>2</OrderNumber>
<Customer>Cust2</Customer>
</OrderDetails>
<DistirbutionRules>
<Rule>Rule2</Rule>
<Description>Desc2</Description>
</DistirbutionRules>
</OrderData>
</OrderOut>
regards
René
Similar Messages
-
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. -
Error while create trigger on for nested table
I want to insert a record into a nested table.For this, I created a view for the table, which includes the nested table.It told me ORA-25015 cannot perform DML on this nested table view column.So I created a trigger for the nested table.However, it told me that ORA-25010 Invalid nested table column name in nested table clause.I think my nested table is valid, i don't konw why did it appear this kind of problem?
My table is
CREATE TABLE ENT
ID NUMBER(7) NOT NULL,
CREATE_DATE VARCHAR2(11 BYTE),
UPDATE_DATE VARCHAR2(11 BYTE),
DEPTS VARRAY_DEPT_SEQ
CREATE OR REPLACE
TYPE DEPT AS OBJECT
ID NUMBER(8),
ANCHOR VARCHAR2(20),
CREATE OR REPLACE
TYPE " VARRAY_DEPT_SEQ" as varray(930) of DEPT
CREATE OR REPLACE VIEW ENT_NESTED_VIEW
(ID, CREATE_DATE, UPDATE_DATE, DEPTS)
AS
select e.ID,cast(multiset(select r.id,r.anchor from ent z, table(z.depts) r where z.ID=e.ID )as varray_dept_seq)
FROM ENT e
Then when I created trigger;
CREATE OR REPLACE TRIGGER EMP.ENT_NESTED_TRI
INSTEAD OF INSERT
ON NESTED TABLE DEPTS OF EMP.ENT_NESTED_VIEW
REFERENCING NEW AS New OLD AS Old PARENT AS Parent
FOR EACH ROW
BEGIN
END ;
I met the problem: ORA-25010 Invalid nested table column name in nested table clause
Could you please tell me the reason
Thank you!
My insert SQL is:
insert into table(select depts from ent_nested_view where id=1856) values(varray_dept_seq(dept(255687,'AF58743')))
Message was edited by:
user589751Hi,TongucY
Compared with the "Referencing Clause with Nested Tables" part of this reference -
http://psoug.org/reference/instead_of_trigger.html, I found the answer of this
quesion. That is "CREATE OR REPLACE TYPE " VARRAY_DEPT_SEQ" as[b] varray(930) of
DEPT". It turns to be a varying array, not a nested table. It should be "CREATE OR
REPLACE TYPE " VARRAY_DEPT_SEQ" as table of DEPT". That is OK. Thank you very
much!
While there is an another question, if I create a varying array like" CREATE OR
REPLACE TYPE " VARRAY_DEPT_SEQ" as[b] varray(930) of DEPT " and I want to insert
a record into the varying array, which the record has been existed.The method that
create a view and a trigger seems not to be effective.
For instance,
There is a record in the table
ID:1020
CREATE_DATE:2005-10-20
UPDATE_DATE:2007-2-11
DETPS: ((10225,AMY))
I want to ask this record to be
ID:1020
CREATE_DATE:2005-10-20
UPDATE_DATE:2007-2-11
DETPS: ((10225,AMY),(10558,TOM))
How should I do?
Could you please help me?
Best regards.
Message was edited by:
user589751 -
Hi ,
I have a function which returns nested table as result .The nested table can sometimes be null.So when i reference the first and last value for a loop, when table is null , then i am getting numeric value error .So i added a check on the nested table as below
if n_table is empty then
exit;
end if;
for i in n_table.first ..n_table.last
loop
select count(1) into_count
from x where rate=n_table(i);
end loop;
Now iam getting a message as" DANGLING NOT NULL OF".Though it gets compiled .iam getting everytime when i first compile it .Please let me know what should i add to prevent thisNull and empty are two different things. Also please post the complete error message.
Notice the difference between
DECLARE
v_tab INTEGER_TT;
BEGIN
IF v_tab IS NOT NULL THEN
FOR i IN v_tab.FIRST..v_tab.LAST LOOP
DBMS_OUTPUT.PUT_LINE('Loop iteration ' || i);
END LOOP;
END IF;
END;and
DECLARE
v_tab INTEGER_TT := INTEGER_TT();
BEGIN
IF v_tab IS NOT EMPTY THEN
FOR i IN v_tab.FIRST..v_tab.LAST LOOP
DBMS_OUTPUT.PUT_LINE('Loop iteration ' || i);
END LOOP;
END IF;
END; -
Trigger how to get new and old value for nested table column?
Hi,
I have created a nested table based on the following details:
CREATE TYPE typ_item AS OBJECT --create object
(prodid NUMBER(5),
price NUMBER(7,2) )
CREATE TYPE typ_item_nst -- define nested table type
AS TABLE OF typ_item
CREATE TABLE pOrder ( -- create database table
ordid NUMBER(5),
supplier NUMBER(5),
requester NUMBER(4),
ordered DATE,
items typ_item_nst)
NESTED TABLE items STORE AS item_stor_tab
INSERT INTO pOrder
VALUES (800, 80, 8000, sysdate,
typ_item_nst (typ_item (88, 888)));
Now I would like to create a trigger on table pOrder for after insert or update or delete
and I would like to track the new and old value for the columns inside nested table.
Can anybody direct me how to do it?
I would like to know the sytax for it like:
declare
x number;
begin
x := :new.nestedtablecolumn;--how to get the new and old value from nested table columns
end;
Hope my question is clear.
Thanks,
LavanHi,
Try like this:
CREATE OR REPLACE TRIGGER PORDER_I
BEFORE INSERT
ON PORDER
REFERENCING OLD AS old NEW AS new
FOR EACH ROW
DECLARE
items_new typ_item_nst;
ordid_NEW NUMBER;
BEGIN
FOR i IN :new.items.FIRST .. :new.items.LAST LOOP -- For first to last element
DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').prodid: ' || :new.items(I).prodid );
DBMS_OUTPUT.PUT_LINE(':new.items(' || I || ').price: ' || :new.items(I).price );
END LOOP;
END;Regards,
Peter -
ROWNUM equivalent for Nested Tables?
Is there an equivalent to the ROWNUM pseudocolumn for a nested table such that something like this...
WITH driver_data AS
(SELECT 1 AS id, sys.dbms_debug_vc2coll('a','b','c') AS val FROM dual
UNION ALL
SELECT 2 AS id, sys.dbms_debug_vc2coll('x','y','z') AS val FROM dual)
SELECT t1.id,
--t2.rownum as pos,
t2.column_value AS val
FROM driver_data t1,
TABLE(t1.val) t2 ;
ID VAL
1 a
1 b
1 c
2 x
2 y
2 z...would return something like this...
ID VAL POS
1 a 1
1 b 2
1 c 3
2 x 1
2 y 2
2 z 3ABB wrote:
But the OP now has two collections per row of data, not one, as he showed above, so it becomes more complicated.Yes, it does. But still solvable:
with t1 as (
select t1.*,
rownum rn_main
from driver_data t1
t2 as (
select id,
val1,
rn_main,
row_number() over(partition by rn_main order by rn_nested) pos
from (
select id,
column_value val1,
rn_main,
rownum rn_nested
from t1,
table(val1)
t3 as (
select id,
val2,
rn_main,
row_number() over(partition by rn_main order by rn_nested) pos
from (
select id,
column_value val2,
rn_main,
rownum rn_nested
from t1,
table(val2)
select nvl(t2.id,t3.id) id,
val1,
val2,
nvl(t2.pos,t3.pos) pos
from t2 full outer join t3 on t2.rn_main = t3.rn_main and t2.pos = t3.pos
order by nvl(t2.rn_main,t3.rn_main),
nvl(t2.pos,t3.pos)
SQL> create table driver_data(
2 id number,
3 val1 sys.dbms_debug_vc2coll,
4 val2 sys.dbms_debug_vc2coll
5 )
6 nested table val1 store as val1_tbl,
7 nested table val2 store as val2_tbl
8 /
Table created.
SQL> insert
2 into driver_data
3 SELECT 1 id,
4 sys.dbms_debug_vc2coll('c','b','a') val1,
5 sys.dbms_debug_vc2coll('k','u') val2
6 FROM dual
7 UNION ALL
8 SELECT 2 id,
9 sys.dbms_debug_vc2coll('z','y','x') val1,
10 sys.dbms_debug_vc2coll('n','e','j','t') val2
11 FROM dual
12 UNION ALL
13 SELECT 1 id,
14 sys.dbms_debug_vc2coll('c','b','a') val1,
15 sys.dbms_debug_vc2coll('k','u') val2
16 FROM dual
17 UNION ALL
18 SELECT 2 id,
19 sys.dbms_debug_vc2coll('z','y','x') val1,
20 sys.dbms_debug_vc2coll('n','e','j','t') val2
21 FROM dual
22 /
4 rows created.
SQL> commit
2 /
Commit complete.
SQL> column val1 format a10
SQL> column val2 format a10
SQL> with t1 as (
2 select t1.*,
3 rownum rn_main
4 from driver_data t1
5 ),
6 t2 as (
7 select id,
8 val1,
9 rn_main,
10 row_number() over(partition by rn_main order by rn_nested) pos
11 from (
12 select id,
13 column_value val1,
14 rn_main,
15 rownum rn_nested
16 from t1,
17 table(val1)
18 )
19 ),
20 t3 as (
21 select id,
22 val2,
23 rn_main,
24 row_number() over(partition by rn_main order by rn_nested) pos
25 from (
26 select id,
27 column_value val2,
28 rn_main,
29 rownum rn_nested
30 from t1,
31 table(val2)
32 )
33 )
34 select nvl(t2.id,t3.id) id,
35 val1,
36 val2,
37 nvl(t2.pos,t3.pos) pos
38 from t2 full outer join t3 on t2.rn_main = t3.rn_main and t2.pos = t3.pos
39 order by nvl(t2.rn_main,t3.rn_main),
40 nvl(t2.pos,t3.pos)
41 /
ID VAL1 VAL2 POS
1 c k 1
1 b u 2
1 a 3
2 z n 1
2 y e 2
2 x j 3
2 t 4
1 c k 1
1 b u 2
1 a 3
2 z n 1
ID VAL1 VAL2 POS
2 y e 2
2 x j 3
2 t 4
14 rows selected.
SQL> SY. -
MetaData for nested table type
in a nested table a column is of datatype "TYPE"
so how can i get metadata for this column..
if "OPTIONS" is a column of datatype "TYPE"
and it has 2 columns option_id and option_value
then when i'am trying to get
array.getBaseTypeName
m gettin TAB_TY_OPTION_DETAILS
like this only..
how can i get metadata for this datatype.
Thanks in advance.check out ResultSetMetaData
-
Public Synonyms for Nested Tables - Insertion Problem
Hi,
we are facing a problem during implementation. Our DB set up
is , we will be having two schema named OWNR and COPY.
In the schema, OWNR we have to create all the tables,
types,procedures, packages and obj.....This schema will have
both DDL and DML privileges.
In the schema, COPY we are not supposed to create any tables,
objects. We have to create public synonyms for all the tables,
types, procedures... in OWNR and grant ALL privilege to the
schema COPY.The schema, COPY will have only DML privileges.
The problem is we have some nested tables in our application.
When I try to insert into the synonym which is created for the
nested table, it is not allowing me to insert..The whole
implementation is stucked..Please help.The scripts are given
below.......
We have a type name SITA_ADDRESS_TY which is used by the nested
table SITA_ADDRESSES_NT.Script used for creating the Type,Nested
table,Table, Public Synonym and granting all privilege to these
types and tables are
CREATE OR REPLACE TYPE SITA_ADDRESS_TY AS OBJECT (
SITA_ADDRESS VARCHAR2(10),
REMARKS VARCHAR2(100)) ;
PROMPT SITA_ADDRESSS_NT...
CREATE OR REPLACE TYPE SITA_ADDRESSES_NT AS TABLE OF
SITA_ADDRESS_TY ;
Using this nested table we have created the table,
UMS_SITA_ADDRESS
CREATE TABLE UMS_SITA_ADDRESS (
COMPANY_CODE VARCHAR2 (6) NOT NULL,
AIRLINE_CODE VARCHAR2 (6) NOT NULL,
DESTINATION VARCHAR2 (6) NOT NULL,
SITA_ADDRESS SITA_ADDRESSES_NT)
TABLESPACE EKUMDAT
PCTFREE 5
PCTUSED 40
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 64K
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 505
FREELISTS 1 FREELIST GROUPS 1 )
NOCACHE
NESTED TABLE SITA_ADDRESS STORE AS UMSNT_SITA_ADDRESS ;
PROMPT SYNONYM SITA_ADDRESS_TY...
CREATE PUBLIC SYNONYM SITA_ADDRESS_TY FOR SITA_ADDRESS_TY
PROMPT SYNONYM SITA_ADDRESSES_NT...
CREATE PUBLIC SYNONYM SITA_ADDRESSES_NT FOR SITA_ADDRESSES_NT
PROMPT UMS_SITA_ADDRESS...
CREATE PUBLIC SYNONYM UMS_SITA_ADDRESS FOR UMS_SITA_ADDRESS
Granting Privileges
PROMPT SITA_ADDRESS_TY...
GRANT EXECUTE ON SITA_ADDRESS_TY TO COPY
PROMPT SITA_ADDRESSS_NT...
GRANT EXECUTE ON SITA_ADDRESSES_NT TO COPY
PROMPT UMS_SITA_ADDRESS...
GRANT ALL ON UMS_SITA_ADDRESS TO COPY
When I connect to copy and desc UMS_SITA_ADDRESS, the structure
is
SQL> desc ums_sita_address
Name Null? Type
COMPANY_CODE NOT NULL VARCHAR2(6)
AIRLINE_CODE NOT NULL VARCHAR2(6)
DESTINATION NOT NULL VARCHAR2(6)
SITA_ADDRESS
OWNR.SITA_ADDRESSES_NT
Why is it so??. Even though I have a synonym for
SITA_ADDRESSES_NT, it is not referencing the synonym but instead
refer the OWNR.SITA_ADDRESSES_NT
Because of this when I try to insert into ums_sita_address(in
schema COPY), it is giving the following error,
SQL> insert into ums_sita_address values
('EK','EK','DXB',SITA_ADDRESSES_NT());
insert into ums_sita_address values
('EK','EK','DXB',SITA_ADDRESSES_NT())
ERROR at line 1:
ORA-00932: inconsistent datatypes
But when the same connect to OWNR and try to insert with the
same stmt, it is inserting...
Our middle tier can connect only to COPY schema alone..Is there
anything to be done in the DBA side to achieve this??.
Please help from your valuabe experience...Or can you ask your
collegues if they have got a soln to this probs..Our
implementation team is stucked with this...
Thanks
PriyaHi
I am not sure but maybe you need to use this command:
SQL> insert into ums_sita_address values
('EK','EK','DXB',SITA_ADDRESSES_TY());
SITA_ADDRESSES_TY() instead SITA_ADDRESSES_NT
Regards -
Public Synonyms for Nested Tables - Insertion Problem - Please Help!!!!!
Hi,
we are facing a problem during implementation. Our DB set up
is , we will be having two schema named OWNR and COPY.
In the schema, OWNR we have to create all the tables,
types,procedures, packages and obj.....This schema will have
both DDL and DML privileges.
In the schema, COPY we are not supposed to create any tables,
objects. We have to create public synonyms for all the tables,
types, procedures... in OWNR and grant ALL privilege to the
schema COPY.The schema, COPY will have only DML privileges.
The problem is we have some nested tables in our application.
When I try to insert into the synonym which is created for the
nested table, it is not allowing me to insert..The whole
implementation is stucked..Please help.The scripts are given
below.......
We have a type name SITA_ADDRESS_TY which is used by the nested
table SITA_ADDRESSES_NT.Script used for creating the Type,Nested
table,Table, Public Synonym and granting all privilege to these
types and tables are
CREATE OR REPLACE TYPE SITA_ADDRESS_TY AS OBJECT (
SITA_ADDRESS VARCHAR2(10),
REMARKS VARCHAR2(100)) ;
PROMPT SITA_ADDRESSS_NT...
CREATE OR REPLACE TYPE SITA_ADDRESSES_NT AS TABLE OF
SITA_ADDRESS_TY ;
Using this nested table we have created the table,
UMS_SITA_ADDRESS
CREATE TABLE UMS_SITA_ADDRESS (
COMPANY_CODE VARCHAR2 (6) NOT NULL,
AIRLINE_CODE VARCHAR2 (6) NOT NULL,
DESTINATION VARCHAR2 (6) NOT NULL,
SITA_ADDRESS SITA_ADDRESSES_NT)
TABLESPACE EKUMDAT
PCTFREE 5
PCTUSED 40
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 64K
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 505
FREELISTS 1 FREELIST GROUPS 1 )
NOCACHE
NESTED TABLE SITA_ADDRESS STORE AS UMSNT_SITA_ADDRESS ;
PROMPT SYNONYM SITA_ADDRESS_TY...
CREATE PUBLIC SYNONYM SITA_ADDRESS_TY FOR SITA_ADDRESS_TY
PROMPT SYNONYM SITA_ADDRESSES_NT...
CREATE PUBLIC SYNONYM SITA_ADDRESSES_NT FOR SITA_ADDRESSES_NT
PROMPT UMS_SITA_ADDRESS...
CREATE PUBLIC SYNONYM UMS_SITA_ADDRESS FOR UMS_SITA_ADDRESS
Granting Privileges
PROMPT SITA_ADDRESS_TY...
GRANT EXECUTE ON SITA_ADDRESS_TY TO COPY
PROMPT SITA_ADDRESSS_NT...
GRANT EXECUTE ON SITA_ADDRESSES_NT TO COPY
PROMPT UMS_SITA_ADDRESS...
GRANT ALL ON UMS_SITA_ADDRESS TO COPY
When I connect to copy and desc UMS_SITA_ADDRESS, the structure
is
SQL> desc ums_sita_address
Name Null? Type
COMPANY_CODE NOT NULL VARCHAR2(6)
AIRLINE_CODE NOT NULL VARCHAR2(6)
DESTINATION NOT NULL VARCHAR2(6)
SITA_ADDRESS
OWNR.SITA_ADDRESSES_NT
Why is it so??. Even though I have a synonym for
SITA_ADDRESSES_NT, it is not referencing the synonym but instead
refer the OWNR.SITA_ADDRESSES_NT
Because of this when I try to insert into ums_sita_address(in
schema COPY), it is giving the following error,
SQL> insert into ums_sita_address values
('EK','EK','DXB',SITA_ADDRESSES_NT());
insert into ums_sita_address values
('EK','EK','DXB',SITA_ADDRESSES_NT())
ERROR at line 1:
ORA-00932: inconsistent datatypes
But when the same connect to OWNR and try to insert with the
same stmt, it is inserting...
Our middle tier can connect only to COPY schema alone..Is there
anything to be done in the DBA side to achieve this??.
Please help from your valuabe experience...Or can you ask your
collegues if they have got a soln to this probs..We are stucked
with this...
Thanks
PriyaHi
I am not sure but maybe you need to use this command:
SQL> insert into ums_sita_address values
('EK','EK','DXB',SITA_ADDRESSES_TY());
SITA_ADDRESSES_TY() instead SITA_ADDRESSES_NT
Regards -
XML Type - ExtractValue for Nested Tables
Hi all,
PROCEDURE TESTING
IS
v_xml CLOB := '<EMPLOYEE><RECORD><EMPID>12</EMPID><EMPNAME>ROCK</EMPNAME></RECORD><RECORD><EMPID>13</EMPID>13<EMPNAME>PETER</EMPNAME></RECORD><RECORD><EMPID>14</EMPID><EMPNAME>JOHN</EMPNAME></RECORD></EMPLOYEE>';
BEGIN
FOR i IN
(SELECT EXTRACTVALUE (indv_xml, 'RECORD/EMPID') eid,EXTRACTVALUE (indv_xml, 'RECORD/EMPNAME') ename
FROM (SELECT VALUE (v) indv_xml
FROM (SELECT XMLTYPE (v_xml) main_xml
FROM DUAL),
TABLE
(XMLSEQUENCE
(EXTRACT
(main_xml,
'EMPLOYEE/RECORD'
) v))
LOOP
insert into employee values(eid,ename);
END LOOP;
END;
Now i have the xml like this:-
'<EMPLOYEE>
<EMPTYPE>
<TYPEID>121</TYPEID>
<ROW><EMPID>12</EMPID><EMPNAME>ROCK</EMPNAME></ROW>
<ROW><EMPID>13</EMPID>13<EMPNAME>PETER</EMPNAME></ROW>
</EMPTYPE>
<EMPTYPE>
<TYPEID>122</TYPEID>
<ROW><EMPID>14</EMPID><EMPNAME>JOHN</EMPNAME></ROW>
</EMPTYPE>
</EMPLOYEE>'
In this case, I have populate into two tables first EMP_TYPE (typeid - PK) and EMPLOYEE(EID,ENAME,TYPEID -FK)...
Pls provide me some sample code.
Thanks
SimbhuHi,
I have a similar requirement, where i need to extract a particular segment from an xml doc, but am getting errors:
The XML Doc is :
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Code39Response> <Code39Result>iVBORw0KGgoAAAANSUhEUgAAAC0AAAAeCAYAAAC49JeZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAO1JREFUWEftlgkOhTAIRPX+h3ZLaxCBMnWt0uQnml/Ikw5T+mFaXWtrhm5tda0BL8rQoCfFwN9jxXjzefaJZDnQk4B+Gbpfqoonx3+g52rkn1Rp67+8vybHGsuPiB8P8s5haaz2nCx3xbBynAZtadoL7c0hQtMj4888sVcCVA5Hc6jQaEcjx+6x15IcNz5dshrNBmugLbBLoHPjvEYe8BX4UAB+Vz8EumniFzDACFFpuGSVAd+qNB9oqE9Tu5P8W7pNpQGJe7w2RO3mI+uW0uACOlXNmnWi0nQWLukzNB2NaDRVyONT8qgcC24JGwGQIbYsvaAvwQAAAABJRU5ErkJggg==</Code39Result>
</Code39Response>
</soap:Body>
</soap:Envelope>
select XMLTYPE('<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Code39Response> <Code39Result>iVBORw0KGgoAAAANSUhEUgAAAC0AAAAeCAYAAAC49JeZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAO1JREFUWEftlgkOhTAIRPX+h3ZLaxCBMnWt0uQnml/Ikw5T+mFaXWtrhm5tda0BL8rQoCfFwN9jxXjzefaJZDnQk4B+Gbpfqoonx3+g52rkn1Rp67+8vybHGsuPiB8P8s5haaz2nCx3xbBynAZtadoL7c0hQtMj4888sVcCVA5Hc6jQaEcjx+6x15IcNz5dshrNBmugLbBLoHPjvEYe8BX4UAB+Vz8EumniFzDACFFpuGSVAd+qNB9oqE9Tu5P8W7pNpQGJe7w2RO3mI+uW0uACOlXNmnWi0nQWLukzNB2NaDRVyONT8qgcC24JGwGQIbYsvaAvwQAAAABJRU5ErkJggg==</Code39Result>
</Code39Response>
</soap:Body>
</soap:Envelope>') from dual
does NOT give any error. BUT
SELECT VALUE(v) xml_data
FROM (select XMLTYPE('<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Code39Response>
<Code39Result>iVBORw0KGgoAAAANSUhEUgAAAC0AAAAeCAYAAAC49JeZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAO1JREFUWEftlgkOhTAIRPX+h3ZLaxCBMnWt0uQnml/Ikw5T+mFaXWtrhm5tda0BL8rQoCfFwN9jxXjzefaJZDnQk4B+Gbpfqoonx3+g52rkn1Rp67+8vybHGsuPiB8P8s5haaz2nCx3xbBynAZtadoL7c0hQtMj4888sVcCVA5Hc6jQaEcjx+6x15IcNz5dshrNBmugLbBLoHPjvEYe8BX4UAB+Vz8EumniFzDACFFpuGSVAd+qNB9oqE9Tu5P8W7pNpQGJe7w2RO3mI+uW0uACOlXNmnWi0nQWLukzNB2NaDRVyONT8qgcC24JGwGQIbYsvaAvwQAAAABJRU5ErkJggg==</Code39Result>
</Code39Response>
</soap:Body>
</soap:Envelope>') main_xml from dual), TABLE(xmlsequence(extract(main_xml,'soap:Envelope/soap:Body/child::node()'))) v
Gives me the error below:
ORA-31011: XML Parsing Failed
ORA-19202: Error occured in XML Parsing
LPX-00601: Invalid token in '<soap:Envelope/soap:Body'
31011.00000 - "XML Parsing Failed"
Am i doing something wrong?
Thanks
Ashish -
Message split for every 1000 records
Hi All,
My scenario is Proxy to File.We have to process thousands of records from r/3 to.I need to create separate XML file for every 1000 records in receiver directory.Is there any solution to achieve this?
Thanks in advance
Kartikeyahere;s the blog krish was referring to..
Night Mare-Processing huge files in SAP XI -
Nested Tables and Advanced Queues- Please Help.
How do i work with NestedTable type and Advanced Queue.
I have done the following
I have Oracle 8.1.7 enterprise edition.
create type myType as TABLE OF varchar(32);
create type myObject as OBJECT (
id int,
myt myType);
DECLARE
BEGIN
dbms_aqadm.create_queue_table(
queue_table => 'my_queue_table',
multiple_consumers => TRUE,
queue_payload_type => 'myObject',
compatible => '8.1.3'
END;
The Nested Table and Object are created successfully.
but the queue is not created.
I get the following message.
DECLARE
ERROR at line 1:
ORA-22913: must specify table name for nested table column or
attribute
ORA-06512: at "SYS.DBMS_AQADM_SYS", line 2012
ORA-06512: at "SYS.DBMS_AQADM", line 55
ORA-06512: at line 3
I know how to specify the nested table storage clause for
create table statement, but there is no provision for
it in the create_queue_table procedure.
Any help will be greately appriciated.
i have already created and tested aqs with simple data types,
also i have created simple tables with nested table type
elements.
but the combo of Nested tables and AQ is not working.
thanks in advance.Hi Francois. Thank you very much for your reply, but it seems that i still get errors. So let me tell what i have done.
As you suggested me: i have done a block based on a sub-query for the nested-table:
'select courses from department where name= :department.name'.
In the master block(department) i have the when-new-record-instance trigger:
Declare
LC$Req varchar2(256);
Begin
LC$Req := '(select ns.courses from table
( select courses from department where name = ''' || :DEPARTMENT.name || ''' ) ns )';
Go_block('block11');
Clear_Block ;
Set_Block_Property( 'block11', QUERY_DATA_SOURCE_NAME, LC$Req ) ;
Execute_query ;
End ;
Now the errors i receive, this time in the runtime mode are:
- FRM-41380: Cannot set the blocks query data source
-FRM-41003: This function cannot be performed here.
Since it seems that you know how to work with the nested table i would really appreaciate your help. I am new in the nested table and if you could give an ex with my tables it would be great.
Thank you in advance. -
Creating view to get first row for each table !!
I am having tables(more than 10) which are related using foreign key and primary key relationship.
Example:
Table1:
T1Prim T1Col1 T1Col2
Table2
T2For T2Prim T2Col1 T2Col2 T2Col3
(here T2For will have value same as T1Prim and in my design it has same column name i.e. T1Prim)
Table3
T3For T3Prim T3Col1 T3Col2 T3Col3
(here T3For will have value same as T2Prim)
and so on.
The data in the tables is like For table1 there will be one record, for table2 there will be one record and for table 3 there are more than one records.
Can i view either the first record for each of them or all records from each of them by writing the following view.
I have written a view like this:
Create or replace view test (T1Prim,T1Col1, T1Col2,T2Prim,T2Col1 T2Col2, T2Col3, T3Prim,T3Col1, T3Col2, T3Col3)
As
Select
Table1.T1Prim,
Table1.T1Col1,
Table1.T1Col2,
Table2.T2Prim,
Table2.T2Col1,
Table2.T2Col2,
Table2.T2Col3,
Table3.T3Prim,
Table3.T3Col1,
Table3.T3Col2,
Table3.T3Col3
From
Table1,
Table2,
Table3
where
Table1.Prim = Table2.For
and Table2.Prim = Table3.For
When i ran the select statement on the view I am not getting any data. Whereas there is data when select is ran on individual table.
Can someone please tell me where i am goofing.
Thanks in the anticipation that i will get some hint to solve this.
Eagerly waiting for reply.
Thanks !!I mean use a collection :
Collection Methods
A collection method is a built-in function or procedure that operates on collections and is called using dot notation. The methods EXISTS, COUNT, LIMIT, FIRST, LAST, PRIOR, NEXT, EXTEND, TRIM, and DELETE help generalize code, make collections easier to use, and make your applications easier to maintain.
EXISTS, COUNT, LIMIT, FIRST, LAST, PRIOR, and NEXT are functions, which appear as part of an expression. EXTEND, TRIM, and DELETE are procedures, which appear as a statement. EXISTS, PRIOR, NEXT, TRIM, EXTEND, and DELETE take integer parameters. EXISTS, PRIOR, NEXT, and DELETE can also take VARCHAR2 parameters for associative arrays with string keys. EXTEND and TRIM cannot be used with index-by tables.
For more information, see "Using Collection Methods".
Syntax
Text description of the illustration collection_method_call.gif
Keyword and Parameter Description
collection_name
This identifies an index-by table, nested table, or varray previously declared within the current scope.
COUNT
COUNT returns the number of elements that a collection currently contains, which is useful because the current size of a collection is not always known. You can use COUNT wherever an integer expression is allowed.
For varrays, COUNT always equals LAST. For nested tables, normally, COUNT equals LAST. But, if you delete elements from the middle of a nested table, COUNT is smaller than LAST.
DELETE
This procedure has three forms. DELETE removes all elements from a collection. DELETE(n) removes the nth element from an index-by table or nested table. If n is null, DELETE(n) does nothing. DELETE(m,n) removes all elements in the range m..n from an index-by table or nested table. If m is larger than n or if m or n is null, DELETE(m,n) does nothing.
EXISTS
EXISTS(n) returns TRUE if the nth element in a collection exists. Otherwise, EXISTS(n) returns FALSE. Mainly, you use EXISTS with DELETE to maintain sparse nested tables. You can also use EXISTS to avoid raising an exception when you reference a nonexistent element. When passed an out-of-range subscript, EXISTS returns FALSE instead of raising SUBSCRIPT_OUTSIDE_LIMIT.
EXTEND
This procedure has three forms. EXTEND appends one null element to a collection. EXTEND(n) appends n null elements to a collection. EXTEND(n,i) appends n copies of the ith element to a collection. EXTEND operates on the internal size of a collection. So, if EXTEND encounters deleted elements, it includes them in its tally. You cannot use EXTEND with index-by tables.
FIRST, LAST
FIRST and LAST return the first and last (smallest and largest) subscript values in a collection. The subscript values are usually integers, but can also be strings for associative arrays. If the collection is empty, FIRST and LAST return NULL. If the collection contains only one element, FIRST and LAST return the same subscript value.
For varrays, FIRST always returns 1 and LAST always equals COUNT. For nested tables, normally, LAST equals COUNT. But, if you delete elements from the middle of a nested table, LAST is larger than COUNT.
index
This is an expression that must yield (or convert implicitly to) an integer in most cases, or a string for an associative array declared with string keys.
LIMIT
For nested tables, which have no maximum size, LIMIT returns NULL. For varrays, LIMIT returns the maximum number of elements that a varray can contain (which you must specify in its type definition).
NEXT, PRIOR
PRIOR(n) returns the subscript that precedes index n in a collection. NEXT(n) returns the subscript that succeeds index n. If n has no predecessor, PRIOR(n) returns NULL. Likewise, if n has no successor, NEXT(n) returns NULL.
TRIM
This procedure has two forms. TRIM removes one element from the end of a collection. TRIM(n) removes n elements from the end of a collection. If n is greater than COUNT, TRIM(n) raises SUBSCRIPT_BEYOND_COUNT. You cannot use TRIM with index-by tables.
TRIM operates on the internal size of a collection. So, if TRIM encounters deleted elements, it includes them in its tally.
Usage Notes
You cannot use collection methods in a SQL statement. If you try, you get a compilation error.
Only EXISTS can be applied to atomically null collections. If you apply another method to such collections, PL/SQL raises COLLECTION_IS_NULL.
You can use PRIOR or NEXT to traverse collections indexed by any series of subscripts. For example, you can use PRIOR or NEXT to traverse a nested table from which some elements have been deleted.
EXTEND operates on the internal size of a collection, which includes deleted elements. You cannot use EXTEND to initialize an atomically null collection. Also, if you impose the NOT NULL constraint on a TABLE or VARRAY type, you cannot apply the first two forms of EXTEND to collections of that type.
If an element to be deleted does not exist, DELETE simply skips it; no exception is raised. Varrays are dense, so you cannot delete their individual elements.
PL/SQL keeps placeholders for deleted elements. So, you can replace a deleted element simply by assigning it a new value. However, PL/SQL does not keep placeholders for trimmed elements.
The amount of memory allocated to a nested table can increase or decrease dynamically. As you delete elements, memory is freed page by page. If you delete the entire table, all the memory is freed.
In general, do not depend on the interaction between TRIM and DELETE. It is better to treat nested tables like fixed-size arrays and use only DELETE, or to treat them like stacks and use only TRIM and EXTEND.
Within a subprogram, a collection parameter assumes the properties of the argument bound to it. So, you can apply methods FIRST, LAST, COUNT, and so on to such parameters. For varray parameters, the value of LIMIT is always derived from the parameter type definition, regardless of the parameter mode.
Examples
In the following example, you use NEXT to traverse a nested table from which some elements have been deleted:
i := courses.FIRST; -- get subscript of first element
WHILE i IS NOT NULL LOOP
-- do something with courses(i)
i := courses.NEXT(i); -- get subscript of next element
END LOOP;
In the following example, PL/SQL executes the assignment statement only if element i exists:
IF courses.EXISTS(i) THEN
courses(i) := new_course;
END IF;
The next example shows that you can use FIRST and LAST to specify the lower and upper bounds of a loop range provided each element in that range exists:
FOR i IN courses.FIRST..courses.LAST LOOP ...
In the following example, you delete elements 2 through 5 from a nested table:
courses.DELETE(2, 5);
In the final example, you use LIMIT to determine if you can add 20 more elements to varray projects:
IF (projects.COUNT + 20) < projects.LIMIT THEN
-- add 20 more elements
Related Topics
Collections, Functions, Procedures
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems7.htm#33054
Joel P�rez -
Error while mapping two times nested table
Hi,
I have a Product table which has nested ProductSubcategory in it.
ProductSubcategory nested table also has nested table ProductCategory inside it.
So there is a nested table inside nested table.
I designed a dimension on warehoue builder and while mapping, i got "ORA-22913: must specify table name for nested table column or attribute" error.
I mapped nested tables before with using varray iterator and expand object, but they were nested once. Is there any solution for mapping two or more time nested tables?
Now i exracted tables and i continuou working but, i wondered is there any way.
Creation codes are below. Thanx :)
CREATE TABLE PRODUCT
( PRODUCTID NUMBER NOT NULL ,
ProductSubcategory ProductSubcategory,
MODIFIEDDATE DATE NOT NULL)
NESTED TABLE ProductSubcategory STORE AS ProductSubcategory_TABLE
( NESTED TABLE ProductCategoryId STORE AS ProductCategory_TABLE);
CREATE TYPE TYPE_ProductSubcategory AS OBJECT (
ProductSubcategoryID number ,
ProductCategoryId ProductCategory ,
Name Varchar(50) ,
rowguid varchar2(100) ,
ModifiedDate date );
CREATE TYPE TYPE_ProductCategory AS OBJECT (
ProductCategoryID number ,
Name Varchar(50) ,
rowguid varchar2(100) ,
ModifiedDate date );Bharadwaj Hari wrote:
Hi,
I agree with u...I am not sure of the environment the user has so i put forth all the 3 option that crossed my mind that time....thats why i said he has to choose what best suits him/her...
Also if the database is huge and we create physical temp tables (option 2 and ur idea) its like having redundant data in the database which is also a problem....So ist upto the user to actually evaluate the situation and come up with what best suits him/her...
Regards
BharathHi,
I understand your opinion. But I am not sure that the user have enough experience to choose the best option by his one. And about the redundant data: because of this I wrote that he should truncate the tables after the last mapping which loads all data into the real target table.
Regards,
Detlef -
Message split based on Element value
Hi all,
I am looking for a way to split my source message into multiple target messages based on the Material element.
My Source and Target structures are exactly the same.
What i am trying to do is read from a order related flat file with multiple Materials and then create multiple flat files based on each material. So basically, each target file will have all the order info for EACH material.
In MM i tried to change the occurance of the target message from 1 to 0..unbounded but was not succesful.
Any help is appreciated. Please see below example source and desired target messages
Source Message:
<Header>
<GUID1>E663336789</GUID1>
</Header>
<Data>
<Order>50000890</Order>
<Material>Mat1</Material>
</Data>
<Data>
<Order>50000891</Order>
<Material>Mat2</Material>
</Data>
<Data>
<Order>50000892</Order>
<Material>Mat1</Material>
</Data>
<Data>
<Order>50000892</Order>
<Material>Mat2</Material>
</Data>
Expected Result ->First Split Message
<Header>
<GUID1>E663336789</GUID1>
</Header>
<Data>
<Order>50000890</Order>
<Material>Mat1</Material>
</Data>
<Data>
<Order>50000892</Order>
<Material>Mat1</Material>
</Data>
Expected Result ->Second Split Message
<Header>
<GUID1>E663336789</GUID1>
</Header>
<Data>
<Order>50000891</Order>
<Material>Mat2</Material>
</Data>
<Data>
<Order>50000892</Order>
<Material>Mat2</Material>
</Data>Hi Lekshmi,
I tried your suggestion but am facing some problems. Based on certain combinations of Material#'s that i enter, sometimes the message split works correctly and sometimes it does not work correctly. At times, it would even create an empty 'Inbound_Msg1_MT' element. In the below example, i should be seeing 2 messages - one for 'Mat1' and the other for 'Mat2', but i just see 1 message split for 'Mat1'.
Any suggestions? TIA
Source
<ns0:Message1>
<ns1:Outbound_Msg1_MT xmlns:ns1="http://Test/Test">
<Header>
<GUID1>HDR</GUID1>
</Header>
<Data>
<Order>1</Order>
<Material>Mat1</Material>
</Data>
<Data>
<Order>2</Order>
<Material>Mat2</Material>
</Data>
</ns1:Outbound_Msg1_MT>
</ns0:Message1>
</ns0:Messages>
Result
<ns0:Message1>
<ns1:Inbound_Msg1_MT xmlns:ns1="http://Test/Test">
<Header>
<GUID1>HDR</GUID1>
</Header>
<Data>
<Order>1</Order>
<Material>Mat1</Material>
</Data>
</ns1:Inbound_Msg1_MT>
</ns0:Message1>
</ns0:Messages>
Mapping
Inbound_Msg1_MT
Material>removeContexts>sort>SplitByValue(Value Change)>Inbound_Msg1_MT
Header
Material>removeContexts>sort>SplitByValue(Value Change)>Header
GUID1
Material>removeContexts->useOneAsMany>SplitByValue(Each value)-->GUID1
Data
Data>removeContexts>formatByExample(1)
Material>removeContexts>sort>SplitByValue(Value Change)>formatByExample(2)
formatByExample-->Data
Order
Material>removeContexts>SortByKey(1)
Order>removeContexts>SortByKey(2)
SortByKey-->formatByExample(1)
Material>removeContexts>sort>SplitByValue(Each value)>formatByExample(2)
formatByExample->Order
Material
Material>removeContexts>sort>SplitByValue (EachValue)>Material
Maybe you are looking for
-
Lenovo Win 7 Pro Upgrade - Recovery Partition?
If this has been covered already then I apologize in advance, but it would be appreciated if someone would respond to the following: I recently upgraded my T61 to Windows 7 Pro using the two-disc set from Lenovo. To preserve my original XP pro set
-
How can I change the color and size of the freehand tool in Adobe Reader on the IPAD?
How can I change the size and color of the freehand tool in Adobe Reader for IPAD?
-
Trackpad gesture acting weird.
I have a 13" MBP, purchased Mid-2012. It has been wonderful so far. I use most of the trackpad gestures frequently. I have searched high and low for an answer to my problem. My trackpad has been flawless up until the last week. Show Desktop is a gest
-
DescriptorEventAdapter's aboutToUpdate and calling event.getOriginalObject
Hi All We have a class extending DescriptorEventAdapter and implementing its aboutToUpdate() method to update some audit information in every object. The implementation is here. public void aboutToUpdate(DescriptorEvent event) log.debug("Object updat
-
Horizontal scrollbar mystery.
In our application we use several interactive reports and we have an issue in some of them when using IE (horizontal scrollbar disappears). I have spent last few days trying to figure out what is the problem without any luck. Here are my discoveries: