CAST and MULTISET with nested table
I am trying to figure out the syntax of using
MULTISET. I have two queries.
One very basic where I want to cast the station names
and ids, retrieved from a regular table into a nested
table.
e.g.
SELECT cast(multiset(stn_id, stn_name) as castTab) FROM station_tab WHERE stn_name like '%xyz%';
The other retrieve sections of a nested table and cast back as
nested table type.
SELECT * FROM CAST(MULTISET(SELECT * FROM
THE (SELECT tmn_history FROM tmin WHERE tmn_stn_ncdcid = 01063456) NT
WHERE (EXTRACT(YEAR FROM NT.dta_date) = 1915) AS data_tab ;
The schema/tables are as follows
=========================================================================
CREATE TABLE station_tab
stn_id INTEGER PRIMARY KEY,
stn_name VARCHAR(50)
CREATE OR REPLACE TYPE data_point AS OBJECT
dta_date DATE,
dta_val NUMBER,
dta_dtobtnd DATE
CREATE OR REPLACE TYPE data_tab AS TABLE OF data_point;
CREATE TABLE tmin
tmn_stn_id INTEGER ,
tmn_history data_tab
) NESTED TABLE tmn_history STORE AS tmn_history_tab;
CREATE OR REPLACE TYPE castObj AS OBJECT
dta_val NUMBER,
stn_name VARCHAR(50)
CREATE OR REPLACE TYPE castTab AS TABLE OF castObj;
=====================================================================
Thank you.
barr
With trial and error and going thru the examples
in AskTom and documentation found that the follwing syntax works.
(Also realized this is the wrong forum);
SELECT * FROM TABLE (cast(multiset
(SELECT stn_ncdcid,stn_name FROM station_tab WHERE stn_name LIKE '%WSFO%')
AS castTab));
select * FROM TABLE (CAST(MULTISET (SELECT * FROM
THE (SELECT tmn_history FROM tmin WHERE tmn_stn_ncdcid = 01063456) NT
WHERE (EXTRACT(YEAR FROM NT.dta_date) = 1915)
ORDER BY NT.dta_date) as data_tab)) ;
Similar Messages
-
Trying to UNION two views with nested tables
I am using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod, and my objective is to generate some XML. What I have been doing in the past, is to create a view, and then pass that view to the DBMS_XMLQuery routine. This gives me a CLOB that I pass along to the application. A typical object would be something like:
create or replace type XML_UGroup_Member_Type as object (
username varchar2(128),
group_key varchar2(128));
create or replace type XML_UGroup_Member_List
as table of XML_UGroup_Member_Type;
show errors
Create or replace type XML_UGroup_Type as object (
Group_Space varchar2(32),
group_key varchar2(128),
group_name varchar2(255),
members XML_UGroup_Member_List);
/This particular application will be doing stuff with group information. Pretty simply types - a group with a name and a few other keys, and a list of members. A sample view would be like:
create or replace view xml_department_ugroup_view of xml_ugroup_type
with object identifier ( group_key ) as
Select 'Department',
'Department:' || orgn_code,
'Department_' || orgn_name
cast ( multiset (
select Username, person_id,
'Department:' || effective_orgn
from directory_master dm, logins l
where effective_orgn = dd.orgn_code
and dm.person_id = l.owner)
as XML_UGroup_Member_List )
as members
from directory_departments dd
where dept_include = 'Y';
can select from this view, and I can pass it to the DBMS_XMLQUERY package and get a nice XML document. What I want to is essentially put several of these views together, like
Select * from XML_Department_Ugroup_View
Union
Select * from XML_Portfolio_Ugroup_View;But UNION does not work with nested tables:
ERROR at line 1: ORA-00932: inconsistent datatypes: expected - got SIMON.XML_UGROUP_MEMBER_LIST
What I was hoping to do, was to develop a set of sub views for each of the group "spaces", and then generate a view/object that includes all of the sub views, and be able to operate with that single object.
Thoughts on how to make this work, or on alternate approaches? I have considered calling XMLQuery on each of the sub views and concatenating the XML documents and returning that to the application, but I was hoping to find a more "unified" approach.I modified my approach a bit - I changed the base views to return an XMLType object, like:
create or replace view xml_portfolio_ugroup_xml
as
Select XMLElement("group",
xml_ugroup_type(
'Portfolio',
'Portfolio:' || coas_code || ':' || orgn_Code,
cast ( multiset (
select Username,
from directory_master dm, logins l
where ( effective_orgn, effective_coas ) in
where effective_orgn = dd.orgn_code
and dm.person_id = l.owner
as XML_UGroup_Member_List ))) as grp
from directory_departments dd
where dept_include = 'Y';and then I combined them with something like the following (I expect to adjust this as I learn more about the XML DB support)
create or replace view xml_ugroup_xml as
select xmlconcat(
(select xmlagg(grp) from xml_department_ugroup_xml),
(select xmlagg(grp) from xml_portfolio_ugroup_xml)
) as GROUPS
from dualand as I define more group branches, I can add them into the XMLConCat stanzas. I am still open to suggestions as to ways of doing this better or cleaner, but this at least gets the project moving forward again. -
Import tables with nested table : ORA-00600
In Oracle 9.2
Create object, type as table, and table with nested table (store as syms_ntab) are successfully.
Also its export.
In process of import on another server (also 9.2, 'fromuser=one touser=two') shows errors:
. . importing table "SYMS_NTAB"
IMP-00058: ORACLE error 600 encountered
ORA-00600: internal error code, arguments: [kokeeafi1], [2], [2], [], [], [], [], []
IMP-00075: Warning: The nested table may contain partial rows or duplicate rows
But for all that table is created and error occur on phase inserting strings.
What is this?
In Oracle 8.0.5 i perform similar operation without error.From Oracle error messages and codes manual:
ORA-00600 internal error code, arguments: [string], [string], [string], [string], [string], [string], [string], [string]
Cause: This is the generic internal error number for Oracle program exceptions. It indicates that a process has encountered a low-level, unexpected condition. Causes of this message include:
* timeouts
* file corruption
* failed data checks in memory
* hardware, memory, or I/O errors
* incorrectly restored files
The first argument is the internal message number. Other arguments are various numbers, names, and character strings. The numbers may change meanings between different versions of Oracle.
Action: Report this error to Oracle Support Services after gathering the following information:
* events that led up to the error
* the operations that were attempted that led to the error
* the conditions of the operating system and databases at the time of the error
* any unusual circumstances that occurred before receiving the ORA-00600 message
* contents of any trace files generated by the error
* the relevant portions of the Alter files
Note: The cause of this message may manifest itself as different errors at different times. Be aware of the history of errors that occurred before this internal error. -
PL/SQL add procedure with nested table - Duplicate Thread
Hi,
I am trying to do a procedure to input information for one order and another for 2 orders.
The information I have so far is as follows:
Drop table Orders cascade constraints;
Drop type item_type;
Drop type Item_nested;
Create or Replace Type item_type AS Object (
Cat_code Varchar2(6),
Amount_ord Number(3),
Cost Number(5,2) );
Create or Replace Type item_nested as table of item_type;
Create Table Orders (
Order_no Varchar2(8) constraint pkorder primary key,
Customer_name Varchar2(30),
AddressLine1 Varchar2(20),
AddressLine2 Varchar2(20),
AddressLine3 Varchar2(20),
Town Varchar2(20),
Postcode Varchar2(10),
Country Varchar2(20),
Order_items item_nested,
Order_date Date)
Nested Table Order_items
Store as nested_items return as locator;
This has so far worked but I have not managed the insert procedure.
I am using Oracle SQL*plus
Thanks
SG
Edited by: user10689875 on 11-Jan-2009 03:39Duplicate thread ->
PL/SQL add procedure with nested table
Please remove it & marked it as duplicate.
Regards.
Satyaki De. -
Partition exchange error on table with nested table
On Oracle 11.2.0.1, I have a partitioned table with some partitions that need to be 'archived' (in terms of moving partitions to an 'archive' table).
I have a source table like:
CREATE TABLE IS_PODACI245
ID_OBJEKTA_IDENTIFIKACIJA NUMBER(10),
ID_OBJEKTA NUMBER(20),
DATUM TIMESTAMP(6) NOT NULL,
TZ NUMBER(3),
DATA1 NUMBER(10),
DATA2 NUMBER(6),
DATA3 NUMBER(10),
DATA4 NUMBER,
DATA5 T_NTCIP_CLIMATE_TABLE
NESTED TABLE DATA5 STORE AS IS_PODACI245_STORE_TABLE
TABLESPACE DATA
PARTITION BY RANGE (DATUM)
PARTITION P_201107 VALUES LESS THAN (TIMESTAMP' 2011-08-01 00:00:00')
LOGGING
NOCOMPRESS
TABLESPACE DATA,
PARTITION P_MAXVALUE VALUES LESS THAN (MAXVALUE)
LOGGING
NOCOMPRESS
TABLESPACE DATA
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE INDEX IDX_IS_PODACI245_KOMPLEKS ON IS_PODACI245
(ID_OBJEKTA_IDENTIFIKACIJA, ID_OBJEKTA, DATUM)
TABLESPACE DATA
LOCAL (
PARTITION P_201107
LOGGING
NOCOMPRESS
TABLESPACE DATA,
PARTITION P_MAXVALUE
LOGGING
NOCOMPRESS
TABLESPACE DATA
NOPARALLEL;
CREATE OR REPLACE TYPE t_ntcip_climate_table as table of t_ntcip_climate_fmt;
CREATE OR REPLACE TYPE t_ntcip_climate_FMT as object
( dev_index number(6)
, dev_description varchar2(512)
, dev_type number(10)
, dev_status number(10)
, dev_mfr_status varchar2(512)
, dev_active number(3)
, dev_test_activation number(10)
/I would like to make exchange partition using stage table, and everything is going fine on all tables, but only on a few of them (listed source is one of them, and they're only tables with nested tables wihin), where I get an error.. but sometimes ;)
on a statement like:
ALTER TABLE IS_PODACI245_ARH EXCHANGE PARTITION P_201106 WITH TABLE IS_PODACI245_STAGE EXCLUDING INDEXES WITHOUT VALIDATION;I got an error:
ORA-00001: unique constraint (TXV.SYS_C0032911) violated
it's an unique index between parent and nested table.
what could cause that problem?Dear,
I suppose that the unique constraint
ORA-00001: unique constraint (TXV.SYS_C0032911) violatedis the one you 've created on the nested table IS_PODACI245_STORE_TABLE
If so, why not disable that constraint and try again.
I have never exchanged such a kind of partitioned table having a nested table in it. But, I could imagine that the cloned non partitioned table IS_PODACI245_STAGE should at least be the exact image of the partitioned table IS_PODACI245_ARH (of course without the partition part) but with the nested table part and including all indexes
In addition, if you have a parent/child relationship between your partitioned tables, then there is a chronological order of exchange starting by the child and then finishing by the parent
see the following link for more information about this order of exchange (and comment 2 for an example also)
http://jonathanlewis.wordpress.com/2006/12/10/drop-parent-partition/#more-65
Hope this helps
Mohamed Houri -
Problem when expanding Tree - Tree with nested table column
Hi, i have created the tree using the Tree with nested table column.
I have created a node called TREE_ROOT in the context.
This node has few attributes which includes children_loaded, is_leaf, is_expanded.
I have created the recursive node TREE_SUB for the above node TREE_ROOT.
In the view, i have created the table with the master column. The above attributes have been mapped accordingly. I have created the action handler for load_children.
In this action handler method, i receive the context_element correctly. In this method, i determine the children of the selected element and the resulting children are attached to this context_element.
But the problem is: when i add elements to context_elements in the method load_children, these
elements get added to the node TREE_ROOT as well.
Please help.
thanks and best regards,
PramodI just use some types defined in this user... Well, I hope you know what is the type definition of d_period_sec,
don't you ? I didn't ask to provide all types existed now, only types you are
using.
Anyhow you have been granted with execute privilege for types you are using:
SQL> conn tau_tll/tau_tll;
Connected.
SQL> create or replace type d_period_sec as object (date# date);
2 /
Type created.
SQL> grant execute on d_period_sec to public with grant option;
Grant succeeded.
SQL> conn scott/tiger
Connected.
SQL> CREATE OR REPLACE TYPE unit_function AS OBJECT (
2 xi NUMBER,
3 yi NUMBER,
4 xe NUMBER,
5 ye NUMBER,
6 xm NUMBER,
7 ym NUMBER,
8 v NUMBER,
9 a NUMBER,
10 f NUMBER,
11 descr VARCHAR2 (20)
12 );
13 /
Type created.
SQL> grant execute on unit_function to master;
Grant succeeded.
SQL> CREATE OR REPLACE TYPE unit_moving_point AS OBJECT
2 (
3 p tau_tll.d_period_sec, -- from user TAU_TLL
4
5 m unit_function
6 )
7 /
Type created.
SQL> grant execute on unit_moving_point to master;
Grant succeeded.
SQL> CREATE OR REPLACE TYPE moving_point_tab AS TABLE OF unit_moving_point;
2 /
Type created.
SQL> grant execute on moving_point_tab to master;
Grant succeeded.
SQL> CREATE OR REPLACE TYPE moving_point AS OBJECT (u_tab moving_point_tab);
2 /
Type created.
SQL> grant execute on moving_point to master;
Grant succeeded.
SQL> conn master/master
Connected.
SQL> CREATE TABLE MPOINTS (
2 id NUMBER,
3 mpoint scott.Moving_Point)
4 NESTED TABLE mpoint.u_tab store as moving_tab;
Table created.Rgds. -
Fill datagridview with Nested Table Object Type ???
Hello everybody, please you help me resolve my problem?
I follow this example: *(A Sample Application using Object-Relational features)* http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10799/adobjxmp.htm
And this tutorial: *(Using Oracle User-Defined Types with .NET and Visual Studio)* http://www.oracle.com/technology/obe/hol08/dotnet/udt/udt_otn.htm
Now I have 3 Object Table: Stock, Customer and Purchase Order. With the tutorial it's OK to show the data of Stock and Customer Table [there is no nested table in], but I can't do this with table Purchase Order, the tutorial don't show how to work with Nested Table type [Missing or something ?]
When I try to display the data of table Purchase Order, I get the error:
typeName='LINEITEMLIST_NTABTYP'' is not specified or is invalid*
Follow the tutorial, I generate custom class for this UDT and get another error:
this.STOCK_REF = ((object)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "STOCK_REF")));*
Argument Exception Unhandle: Object attribute is not mapped to a custom type member.*
Can You show me how to do this ? Show the data of the Nested Table in Visual Studio, do I have something wrong ??? Thanks and Best Regards.I think you need to go through the tutorial more carefully. I think you are missing steps.
You are using a REF. Are you creating an object table for the objects to be stored in? Are you dereferencing the REF? This is covered by the Oracle by Example tutorial.
http://www.oracle.com/technology/obe/hol08/dotnet/udt/udt_otn.htm#t11
When you receive the nested table, it will be inside a .NET class. You can create this class by using the Create Custom Class menu item on the nested table type in server explorer.
This class will contain a ToString method and a ToXML method.
The question is, where are you attempting to display the data from this nested table? In a grid?
Does it make sense to display a nested table inside one cell of a grid? No. You would need to construct a special UI that will show the
nested table. Maybe the user clicks on the cell on the grid, which opens a new grid that displays the data. Or maybe there is a second grid on the form that always shows the nested table for the row that the first grid currently has selected.
I realize I am not providing you the code... but it sounds like you need to design a more sohisticated UI than what the tutorial is using -- one that can handle displaying one additional table per row. -
ANSI Standard Join with Nested Table
Does anyone know how to (or whether you actually can) use ansi standard table joins with nested tables.
Non-ansi standard would look something like this
SELECT e.empno
FROM departments d, TABLE(d.employees) e
WHERE d.deptno = 10;
Where d.employees is a nested table.
But if I try ansi-standard I like such:
SELECT e.empno
FROM departments d
JOIN TABLE(d.employees) e
WHERE d.deptno = 10;
I get
ORA-00905: missing keyword
because I have nothing to join it on.
Your help is very much appreciatedBoth replies worked fine.
I think I will go with the NATURAL JOIN as it seems the cleanest option.
Thanks Guru 2748 -
Issues with Nested Tables and Adobe Designer
Hi,
I have some strange issues when I am trying to create a nested dynamic table with SAP DATA in Adobe Designer.
My Outer Table has article items and in this table I got a nested charges. For instance the table contains this data:
DATA
|->Article1
|--->charge111
|--->charge211
|
|->Article2
|--->charge122
|--->charge222
Now I am trying to display the data in a Adobe Designer table. But if I create a table with a row article and a repeating row charge all charges will be displayed under the first Article.
This is the result:
DATA
|->Article1
|--->charge111
|--->charge211
|--->charge122
|--->charge222
|
|->Article2
How can I solve this issue? I tried to select data binding on charges like article.DATA.charges.DATA[*] but this don't work.
Anyone an idea?Alex,
Is it print based form or interactvie form.
ABAP
If it is printbased form and if you are designing from SFP, you can use the following solution.
You have to create a nested table in the context as below.
say Table1-> Article ( fields: ARTICLENAME,....other fields) info Table2->cost info(fields:ARTICLENAME,Charge...,other fields).
The 2 tables should contains data as beow.
Table1 data.
1row->Article1 -.....other values.
2row->Article2 -.....other values.
3row->Article3 -.....other values.
Table2 data.
1row->Article1 -Charge11 .....other values.
2row->Article1 -Charge12 .....other values.
3row->Article1 -Charge13 .....other values.
4row->Article2 -Charge21 .....other values.
5row->Article2 -Charge22 .....other values.
6row->Article2 -Charge23 .....other values.
7row->Article3 -Charge31 .....other values.
8row->Article3 -Charge32 .....other values.
9row->Article3 -Charge33 .....other values.
In the context drag table2 into the table1 and define where clause on ARTICLENAME.
In the layout drag nested table in the body page and make alignments.
If your requirement is interactive, may be you can use the similar logic. -
HI frds:)
I need some help regarding writeing soem queries..
I have to use view in retreving data and by useing member functions of object.
1) i have to create a nested table by useing type object.
2) i have to create a object wtih member functions inorder to create view of taht nested table,.
3) by useing this objectt view and by useing methods i have to write soem queries ...
If any one know or any information regarding this please reply me... as i have searched in net alot but i was unable to figure out..
Thanks....// first createing object
create type emp_det as object
(empname varcahr2(20),start_date date,end_date date);
// creating table of that object
create table emp_detai_table as table of emp_det;
// creating nested table
create table empl (emp_no number,emp_detail emp_detail_table,dep_no number)nested table emp_detail store as s;
//now i want to create view.. inorder to create view i need to create object. in that object i want to create methods.. these methods should work with date attributes..
after creating object view i need to select or write some queries by useing member methods..
This is the tast i have to perform.,. i have no materials ...if u have any link ..forward me..
i have to do it as soon as possible..
waiting for your reply... -
DBMS_SQL.BIND_VARIABLE with nested table and ORA-600
Hello, I'm experimenting a little with pl/sql and I was trying to do some dynamic SQL using DBMS_SQL, but I'm having a problem when binding a variable that is a neste table(got no problems in the same example if I bind with a varchar2 variable).
Here is a reduction of the problem:
DECLARE
TYPE CENA_TYPE IS TABLE OF VARCHAR2(30);
CENA CENA_TYPE;
L_UPDATE_STMT VARCHAR2(2000);
UPDATE_CURSOR INTEGER:=DBMS_SQL.OPEN_CURSOR;
RES INTEGER;
BEGIN
CENA:=CENA_TYPE('HELLO');
L_UPDATE_STMT:= 'BEGIN '
||'DBMS_OUTPUT.PUT_LINE(:CENA(1));'
||'END;';
DBMS_SQL.PARSE(UPDATE_CURSOR, L_UPDATE_STMT ,DBMS_SQL.NATIVE);
DBMS_SQL.BIND_VARIABLE(UPDATE_CURSOR,':CENA',CENA);
RES:=DBMS_SQL.EXECUTE(UPDATE_CURSOR);
DBMS_SQL.CLOSE_CURSOR(UPDATE_CURSOR);
END;
/What am I doing wrong??
ThanksPedro_gloria wrote:
What am I doing wrong??DBMS_SQL executes in own context. Therefore, even though type CENA_TYPE is declared in calling anonymous block it is not known to anonymous block you execute in DBMS_SQL. Also, you must initialize and extend collection. Use:
SQL> set serveroutput on
SQL> DECLARE
2 L_UPDATE_STMT VARCHAR2(2000);
3 UPDATE_CURSOR INTEGER:=DBMS_SQL.OPEN_CURSOR;
4 RES INTEGER;
5 BEGIN
6 L_UPDATE_STMT:= 'DECLARE
7 TYPE CENA_TYPE IS TABLE OF VARCHAR2(30);
8 CENA CENA_TYPE := CENA_TYPE();
9 BEGIN '
10 ||'CENA.extend;'
11 ||'CENA(1) := :1;'
12 ||'DBMS_OUTPUT.PUT_LINE(CENA(1));'
13 ||'END;';
14 DBMS_SQL.PARSE(UPDATE_CURSOR, L_UPDATE_STMT ,DBMS_SQL.NATIVE);
15 DBMS_SQL.BIND_VARIABLE(UPDATE_CURSOR,':1','Hello');
16 RES:=DBMS_SQL.EXECUTE(UPDATE_CURSOR);
17 DBMS_SQL.CLOSE_CURSOR(UPDATE_CURSOR);
18 END;
19 /
Hello
PL/SQL procedure successfully completed.
SQL> SY. -
Join two tables to one recordset with nested table?
Hello all!
I want to "de-normalize" two tables into one for presentation reasons. For example:
CREATE TABLE foo(id number)
CREATE TABLE bar(foo_id number, value varchar2(4))
And with some data:
FOO:
1
2
BAR:
1, 'gaz'
1, 'boz'
2, 'blah'
Now I want to create a view that holds the value of the BAR table in a nested table, if possible and efficient enough..
VIEW:
1, nested_table('gaz,'boz')
2, nested_table('blah')
Any clue for creating such a view? I would prefer a view, because this view will be joined with other tables later.
Thanks in advice!Or
SQL> with foo as
2 ( select 1 id from dual union all
3 select 2 id from dual
4 ),
5 bar as
6 (
7 select 1 foo_id, 'gaz' value from dual union all
8 select 1 foo_id, 'boz' value from dual union all
9 select 2 foo_id, 'blah' value from dual
10 )
11 --
12 --
13 select id,
14 cast(multiset((select value from bar where id=foo_id)) as sys.dbms_debug_vc2coll) value
15 from foo
16 /
ID VALUE
1 DBMS_DEBUG_VC2COLL('gaz', 'boz')
2 DBMS_DEBUG_VC2COLL('blah')or from 10g on
SQL> with foo as
2 ( select 1 id from dual union all
3 select 2 id from dual
4 ),
5 bar as
6 (
7 select 1 foo_id, 'gaz' value from dual union all
8 select 1 foo_id, 'boz' value from dual union all
9 select 2 foo_id, 'blah' value from dual
10 )
11 --
12 --
13 select id,
14 cast(collect(value) as sys.dbms_debug_vc2coll) value
15 from foo, bar
16 where id=foo_id
17 group by id
18 /
ID VALUE
1 DBMS_DEBUG_VC2COLL('gaz', 'boz')
2 DBMS_DEBUG_VC2COLL('blah')Edited by: michaels2 on Oct 8, 2008 2:27 PM -
Urgent Help Please, Error with Nested Table
Hello All,
I'm trying to create data mining models based on some medical data. I have combined two tables (Patients) and (tumors) into one table (cancer_patients). In the (cancer_patients) table there is one column (tumors) as nested table column. So I got the following error (ORA-22913) about the nested table. I need an advice about how to fix this error in ODM please
This is the code of the tables
CREATE TABLE "DSS2_MINING"."PATIENTS"
( "PATIENT_ID" VARCHAR2(10 BYTE) NOT NULL ENABLE,
"REGISTRY_ID" NUMBER(10,0),
"RACE" VARCHAR2(2 BYTE),
"***" VARCHAR2(1 BYTE),
"BIRTHDATE_YEAR" NUMBER(4,0),
"NUMBER_OF_PRIMARIES" NUMBER(1,0),
"VITAL_STATUS_RECORD" VARCHAR2(1 BYTE),
"CAUSE_OF_DEATH" VARCHAR2(5 BYTE),
"SURVIVAL_TIME" VARCHAR2(4 BYTE),
"SURVIVAL_TIME_FINAL" NUMBER,
"SURVIVAL_VARIABLE" VARCHAR2(1 BYTE),
CONSTRAINT "PATIENTS_PK" PRIMARY KEY ("PATIENT_ID");
CREATE TABLE "DSS2_MINING"."TUMORS"
( "TUMOR_ID" NUMBER NOT NULL ENABLE,
"PATIENT_ID" VARCHAR2(10 BYTE), -- FK
"SEER_RECORD_NUMBER" NUMBER, -- This column contain a sequance number of the records for each patients
"MARITAL_STATUS" VARCHAR2(1 BYTE),
"AGE" NUMBER,
"DATE_OF_DIAGNOSIS" DATE,
"HISTOLOGY_GROUP" VARCHAR2(2 BYTE),
"BEHAVIOR" VARCHAR2(1 BYTE),
"GRADE" VARCHAR2(1 BYTE),
"DERIVED_AJCC_STAGE_GROUP" VARCHAR2(2 BYTE),
"STAGE_OF_CANCER" VARCHAR2(2 BYTE),
"RADIATION" VARCHAR2(1 BYTE),
"CS_SCHEMA" VARCHAR2(2 BYTE),
"FIRST_PRIMARY_IND" VARCHAR2(1 BYTE),
"TUMOR_SIZE" NUMBER(4,1),
"TUMOR_EXTENSION" VARCHAR2(2 BYTE),
"LYMPH_NODES" VARCHAR2(1 BYTE),
"NODES_POSITIVE" NUMBER,
"ESTROGEN" VARCHAR2(3 BYTE),
"PROGESTERONE" VARCHAR2(3 BYTE),
"SURGERY" VARCHAR2(2 BYTE),
CONSTRAINT "TUMORS_PK" PRIMARY KEY ("TUMOR_ID");
create or replace type tumor_object AS
object(
tumor_id VARCHAR2(1),
marital_status VARCHAR2(1),
age NUMBER(3),
date_of_diagnosis DATE,
cs_schema VARCHAR2(2),
histology_group VARCHAR2(2),
behavior VARCHAR2(1),
grade VARCHAR2(1),
first_primary_ind VARCHAR2(1),
tumor_size NUMBER(4, 1),
tumor_extension VARCHAR2(2),
lymph_nodes VARCHAR2(1),
nodes_positive NUMBER(4),
surgery VARCHAR2(2),
radiation VARCHAR2(1)
create or replace type tumor_table as table of tumor_object;
CREATE TABLE "DSS2_MINING"."CANCER_PATIENTS"
( "PATIENT_ID" VARCHAR2(10 BYTE) NOT NULL ENABLE,
"RACE" VARCHAR2(2 BYTE),
"***" VARCHAR2(1 BYTE),
"NUMBER_OF_PRIMARIES" NUMBER(1,0),
"TUMORS" "DSS2_MINING"."TUMOR_TABLE" ,
"VITAL_STATUS_RECORD" VARCHAR2(1 BYTE),
"CAUSE_OF_DEATH" VARCHAR2(5 BYTE),
"SURVIVAL_TIME_FINAL" NUMBER,
"SURVIVAL_VARIABLE" VARCHAR2(1 BYTE),
CONSTRAINT "CANCER_PATIENTS_PK" PRIMARY KEY ("PATIENT_ID")
NESTED TABLE "TUMORS" STORE AS "TUMORS_STOR_TABLE"Then, I have transferred the data using
INSERT
INTO CANCER_PATIENTS
SELECT PATIENT_ID,
RACE,
NUMBER_OF_PRIMARIES,
SELECT CAST(
COLLECT(
TUMOR_OBJECT(
TUMOR_ID,
MARITAL_STATUS,
AGE,
DATE_OF_DIAGNOSIS,
CS_SCHEMA,
HISTOLOGY_GROUP,
BEHAVIOR,
GRADE,
FIRST_PRIMARY_IND,
TUMOR_SIZE,
TUMOR_EXTENSION,
LYMPH_NODES,
NODES_POSITIVE,
SURGERY ,
RADIATION
AS TUMOR_TABLE
FROM "TUMORS" T
WHERE T.PATIENT_ID = P.PATIENT_ID
VITAL_STATUS_RECORD,
CAUSE_OF_DEATH,
SURVIVAL_TIME_FINAL,
SURVIVAL_VARIABLE
FROM PATIENTS PThanks
A.L
Edited by: user9003901 on Nov 30, 2010 12:23 AMHi
i was using AWM since 9i just because it creates OLAP metadata with a new API called CWM2, and Oracle Enterprise Manager was using a propietary API .
With AWM 10.1.0.4 building your OLAP metadata is very simple, you can define your Dimensions, cubes, measures and even you can load your data from your source system.
You can refer to the Oracle® OLAP Application Developer's Guide where you can find more information on this tool.
And relative to your error i will recommend that you build on a dimension-by-dimension basis and try to validate your OLAP Metadata.
Regards -
Hello All
I have a task about insert data into a nested table. First I will explain the scenario.
I have 2 table (patients) and (tumors) that contain medical data about cancer patients.
CREATE TABLE "DSS2_MINING"."PATIENTS"
( "PATIENT_ID" VARCHAR2(10 BYTE) NOT NULL ENABLE,
"REGISTRY_ID" NUMBER(10,0),
"RACE" VARCHAR2(2 BYTE),
"SEX" VARCHAR2(1 BYTE),
"BIRTHDATE_YEAR" NUMBER(4,0),
"NUMBER_OF_PRIMARIES" NUMBER(1,0),
"VITAL_STATUS_RECORD" VARCHAR2(1 BYTE),
"CAUSE_OF_DEATH" VARCHAR2(5 BYTE),
"SURVIVAL_TIME" VARCHAR2(4 BYTE),
"SURVIVAL_TIME_FINAL" NUMBER,
"SURVIVAL_VARIABLE" VARCHAR2(1 BYTE),
CONSTRAINT "PATIENTS_PK" PRIMARY KEY ("PATIENT_ID");
CREATE TABLE "DSS2_MINING"."TUMORS"
( "TUMOR_ID" NUMBER NOT NULL ENABLE,
"PATIENT_ID" VARCHAR2(10 BYTE), -- FK
"SEER_RECORD_NUMBER" NUMBER, -- This column contain a sequance number of the records for each patients
"MARITAL_STATUS" VARCHAR2(1 BYTE),
"AGE" NUMBER,
"DATE_OF_DIAGNOSIS" DATE,
"HISTOLOGY_GROUP" VARCHAR2(2 BYTE),
"BEHAVIOR" VARCHAR2(1 BYTE),
"GRADE" VARCHAR2(1 BYTE),
"DERIVED_AJCC_STAGE_GROUP" VARCHAR2(2 BYTE),
"STAGE_OF_CANCER" VARCHAR2(2 BYTE),
"RADIATION" VARCHAR2(1 BYTE),
"CS_SCHEMA" VARCHAR2(2 BYTE),
"FIRST_PRIMARY_IND" VARCHAR2(1 BYTE),
"TUMOR_SIZE" NUMBER(4,1),
"TUMOR_EXTENSION" VARCHAR2(2 BYTE),
"LYMPH_NODES" VARCHAR2(1 BYTE),
"NODES_POSITIVE" NUMBER,
"ESTROGEN" VARCHAR2(3 BYTE),
"PROGESTERONE" VARCHAR2(3 BYTE),
"SURGERY" VARCHAR2(2 BYTE),
CONSTRAINT "TUMORS_PK" PRIMARY KEY ("TUMOR_ID");The table (patients) contain the basic information about the patients. The table (tumors) contain information about the tumors. each record in the (patients) table can have one or more records in the (tumors) table using the (patient_id) column. I wanna move the data from the (patients) and (tumors) tables to a new table (cancer_patients) that contain a nested table column. so I did the following code
create or replace type tumor_object AS
object(
tumor_id VARCHAR2(1),
marital_status VARCHAR2(1),
age NUMBER(3),
date_of_diagnosis DATE,
cs_schema VARCHAR2(2),
histology_group VARCHAR2(2),
behavior VARCHAR2(1),
grade VARCHAR2(1),
first_primary_ind VARCHAR2(1),
tumor_size NUMBER(4, 1),
tumor_extension VARCHAR2(2),
lymph_nodes VARCHAR2(1),
nodes_positive NUMBER(4),
surgery VARCHAR2(2),
radiation VARCHAR2(1)
create or replace type tumor_table as table of tumor_object;
CREATE TABLE "DSS2_MINING"."CANCER_PATIENTS"
( "PATIENT_ID" VARCHAR2(10 BYTE) NOT NULL ENABLE,
"RACE" VARCHAR2(2 BYTE),
"SEX" VARCHAR2(1 BYTE),
"NUMBER_OF_PRIMARIES" NUMBER(1,0),
"TUMORS" "DSS2_MINING"."TUMOR_TABLE" ,
"VITAL_STATUS_RECORD" VARCHAR2(1 BYTE),
"CAUSE_OF_DEATH" VARCHAR2(5 BYTE),
"SURVIVAL_TIME_FINAL" NUMBER,
"SURVIVAL_VARIABLE" VARCHAR2(1 BYTE),
CONSTRAINT "CANCER_PATIENTS_PK" PRIMARY KEY ("PATIENT_ID")
NESTED TABLE "TUMORS" STORE AS "TUMORS_STOR_TABLE"
So my problem about how to transfer and insert the data, I tried to use the associative array to hold the rows of the tumors table but it didn't work out. I think the main issue is that each record in the patients table have multiple records in the tumors table.
I hope if anybody can help in this case or I you know any reference about similar cases
Thanks
A.L
Edited by: user9003901 on Nov 26, 2010 2:48 AMSomething like:
INSERT
INTO CANCER_PATIENTS
SELECT PATIENT_ID,
RACE,
SEX,
NUMBER_OF_PRIMARIES,
SELECT CAST(
COLLECT(
TUMOR_OBJECT(
TUMOR_ID,
MARITAL_STATUS,
AGE,
DATE_OF_DIAGNOSIS,
CS_SCHEMA,
HISTOLOGY_GROUP,
BEHAVIOR,
GRADE,
FIRST_PRIMARY_IND,
TUMOR_SIZE,
TUMOR_EXTENSION,
LYMPH_NODES,
NODES_POSITIVE,
SURGERY ,
RADIATION
AS TUMOR_TABLE
FROM "TUMORS" T
WHERE T.PATIENT_ID = P.PATIENT_ID
VITAL_STATUS_RECORD,
CAUSE_OF_DEATH,
SURVIVAL_TIME_FINAL,
SURVIVAL_VARIABLE
FROM PATIENTS P
/SY.
P.S. This site has censorship. It replaces word S E X with ***, so change it back when testing. -
Hi,
I have a table called time_slots
CREATE OR REPLACE TYPE type_timeslots AS TABLE OF DATE;
CREATE TABLE time_slots
time_code VARCHAR2(50),
TIME_SLOT TYPE_TIMESLOTS
NESTED TABLE TIME_SLOT STORE AS NESTED_TIME_SLOTS
I have a SQL which returns multiple rows for each period_code, as I need to insert data into the above table based on a source table.
But I don't know how to do this.
For example, I have a SQL which returns
Time Code Slots
OPENH 09:00
OPENH 10:00
OPENH 11:00
CLOSH 12:00
CLOSH 13:00
CLOSH 14:00
NOH 15:00
NOH 16:00
So, I want the INSERT statement to insert 3 rows into the table and the slots collected into the nested table. I don't know how to merge the 3 rows that relate to OPENH into 1 row with a collection for the slots.
I want to do this in SQL rather than PL/SQL.
Please help.
Thanks
MTo insert from a select statement, you can use the collect function to group the time slots into your collection for each distinct time code. See below. I've created a view called "sample_data" just to make the examples easier.
SQL> CREATE OR REPLACE TYPE type_timeslots AS TABLE OF DATE;
2 /
Type created.
SQL> CREATE TABLE time_slots
2 (
3 time_code VARCHAR2(50),
4 time_slot TYPE_TIMESLOTS
5 )
6 NESTED TABLE TIME_SLOT STORE AS NESTED_TIME_SLOTS;
Table created.
SQL> CREATE VIEW sample_data
2 AS
3 SELECT 'OPENH' AS time_code, TO_DATE('09:00','HH24:MI') AS time_slot FROM dual
4 UNION ALL
5 SELECT 'OPENH' AS time_code, TO_DATE('10:00','HH24:MI') AS time_slot FROM dual
6 UNION ALL
7 SELECT 'OPENH' AS time_code, TO_DATE('11:00','HH24:MI') AS time_slot FROM dual
8 UNION ALL
9 SELECT 'CLOSH' AS time_code, TO_DATE('12:00','HH24:MI') AS time_slot FROM dual
10 UNION ALL
11 SELECT 'CLOSH' AS time_code, TO_DATE('13:00','HH24:MI') AS time_slot FROM dual
12 UNION ALL
13 SELECT 'CLOSH' AS time_code, TO_DATE('14:00','HH24:MI') AS time_slot FROM dual
14 UNION ALL
15 SELECT 'NOH' AS time_code, TO_DATE('15:00','HH24:MI') AS time_slot FROM dual
16 UNION ALL
17 SELECT 'NOH' AS time_code, TO_DATE('16:00','HH24:MI') AS time_slot FROM dual
18 ;
View created.
SQL> SELECT time_code
2 , CAST(COLLECT(time_slot) AS type_timeslots) AS time_slot
3 FROM sample_data
4 GROUP BY
5 time_code;
TIME_CODE TIME_SLOT
CLOSH TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
NOH TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08')
OPENH TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
SQL> INSERT INTO time_slots (time_code, time_slot)
2 SELECT time_code
3 , CAST(COLLECT(time_slot) AS type_timeslots) AS time_slot
4 FROM sample_data
5 GROUP BY
6 time_code;
3 rows created.
SQL> SELECT * FROM time_slots;
TIME_CODE TIME_SLOT
CLOSH TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
NOH TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08')
OPENH TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
SQL> SELECT t.time_code
2 , TO_CHAR(nt.column_value, 'HH24:MI') AS time_slot
3 FROM time_slots t
4 , TABLE(t.time_slot) nt;
TIME_CODE TIME_SLOT
CLOSH 12:00
CLOSH 13:00
CLOSH 14:00
NOH 15:00
NOH 16:00
OPENH 09:00
OPENH 10:00
OPENH 11:00
8 rows selected.Regards
Maybe you are looking for
-
Need help with Boot Camp and Win 7
I have iMac 27" (iMac11,1) 2.8 GHz, quad core, 8MB of L3, 8GB of Memory, Boot ROM Version IM111.0034.B02 and SMC Version 1.54f36 and can't get this machine to run Windows 7 using Boot Camp. I have successfully loaded Win 7 but when it claims to be s
-
Connect mini i-pad to TV ?
Can I hardwire connect a mini i-pad to a Samsung HD TV that takes HDMI and USB?
-
Aperture 3 and Sinar STI raw files
I am trying to archive all my images in Aperture 3 and I have shot a huge amount as Sinar raw files (STI files), which Aperture 3 does not recognise. I can convert them to DNG files using Brambaer tools but Aperture still does not recognise these DNG
-
StorEdge 3310 RAID hung.
During the billing run on a Sun Fire V440, the attached 3310 hung. Reboots of the server did nothing to improve the situation, but once the RAID was powercycled everything was alright again. sccli version 2.1.1 built 2005.09.16.23.10 build 1 for sola
-
Hi All, I have a square object in the middle of circle. and i can move square object using up, down, left, riht arrow keys. I need script for when square object touches circle, then it goes to back, I have use for this below code : var myobjdim:Arra