Open a cursor containing a nested table?

I have created a table with several nested tables by following the examples in: http://otn.oracle.com/docs/products/oracle8/doc_index.htm
I am now trying to query one of these nested tables using the techniques that are described.
The two techniques are (page 31 of above reference):
(1) "Flattened" query.
(2) Nested cursor
Both of these techniques work by simple SQL queries in SQl*Plus.
However, I get compilation errors when using identical queries when trying to open and return a cursor in a stored procedure.
Can you please help? Is this supported in 8.1.7?
Is there a better way to query and return data using OO4O to a windows client program?
If necessary, I would be glad to provide code samples.
Thank you,
Casey Cummings

Here is a copy of my test code for the question that I posted. Any help on how I can get nested table data back to a windows client would be greatly apreciated.
Thank you.
Casey Cummings
--DDL.
--Original table.
CREATE TABLE MY_TABLE(
MY_KEY INTEGER,
MY_DATA VARCHAR2(2000));
--Basic Object types.
CREATE TYPE MY_NUMERIC_OBJTYP AS OBJECT(
SEQUENCE INTEGER,
DATUM NUMBER);
CREATE TYPE MY_TEXT_OBJTYP AS OBJECT(
SEQUENCE INTEGER,
DATUM VARCHAR2(255));
--Table type. Table of basic objects.
CREATE TYPE MY_NUMERIC_TABTYP AS TABLE OF MY_NUMERIC_OBJTYP;
CREATE TYPE MY_TEXT_TABTYP AS TABLE OF MY_TEXT_OBJTYP;
--Add nested tables to original table.
ALTER TABLE MY_TABLE ADD(
MY_NUMERIC_NTAB MY_NUMERIC_TABTYP)
NESTED TABLE MY_NUMERIC_NTAB STORE AS MY_NUMERIC_TABLE;
ALTER TABLE MY_TABLE ADD(
MY_TEXT_NTAB MY_TEXT_TABTYP)
NESTED TABLE MY_TEXT_NTAB STORE AS MY_TEXT_TABLE;
--Insert test data in the main, unnested table.
INSERT INTO MY_TABLE(
MY_KEY, MY_DATA
)VALUES(
1001, 'RECORD-1001');
COMMIT;
--Create the actual nested tables.
UPDATE MY_TABLE SET
MY_NUMERIC_NTAB = MY_NUMERIC_TABTYP();
UPDATE MY_TABLE SET
MY_TEXT_NTAB = MY_TEXT_TABTYP();
COMMIT;
--Insert test data into the nested tables.
INSERT INTO TABLE(
SELECT X.MY_NUMERIC_NTAB
FROM MY_TABLE X
WHERE MY_KEY = 1001
)VALUES(
1,901);
INSERT INTO TABLE(
SELECT X.MY_NUMERIC_NTAB
FROM MY_TABLE X
WHERE MY_KEY = 1001
)VALUES(
2,902);
INSERT INTO TABLE(
SELECT X.MY_NUMERIC_NTAB
FROM MY_TABLE X
WHERE MY_KEY = 1001
)VALUES(
3,903);
INSERT INTO TABLE(
SELECT X.MY_TEXT_NTAB
FROM MY_TABLE X
WHERE MY_KEY = 1001
)VALUES(
1,'ONE');
COMMIT;
BOTH OF THESE QUERYS WORK WHEN ENTERED IN SQL*PLUS.
--"FLATTENED" QUERY
SELECT X.MY_DATA, N.SEQUENCE, N.DATUM, T.SEQUENCE, T.DATUM
FROM
MY_TABLE X,
TABLE(X.MY_NUMERIC_NTAB) N,
TABLE(X.MY_TEXT_NTAB) T
WHERE X.MY_KEY = 1001;
--"CURSOR" QUERY
SELECT X.MY_DATA,
CURSOR(
SELECT *
FROM TABLE (MY_NUMERIC_NTAB) ),
CURSOR(
SELECT *
FROM TABLE (MY_TEXT_NTAB) )
FROM MY_TABLE X
WHERE X.MY_KEY = 1001;
CREATE OR REPLACE PACKAGE MANAGE_TEST AS
TYPE THE_CURSOR IS REF CURSOR;
PROCEDURE QUERY_TEST(
MY_CURSOR IN OUT THE_CURSOR
END;
CREATE OR REPLACE PACKAGE BODY MANAGE_TEST AS
PROCEDURE QUERY_TEST(
MY_CURSOR IN OUT THE_CURSOR
AS
BEGIN
OPEN MY_CURSOR FOR
--"FLATTENED" QUERY
SELECT X.MY_DATA, N.SEQUENCE, N.DATUM, T.SEQUENCE, T.DATUM
FROM
MY_TABLE X,
TABLE(X.MY_NUMERIC_NTAB) N,
TABLE(X.MY_TEXT_NTAB) T
WHERE X.MY_KEY = 1001;
END;
END;
*****************Errors:
LINE/COL ERROR
8/5 PL/SQL: SQL Statement ignored
11/13 PLS-00201: identifier 'X.MY_NUMERIC_NTAB' must be declared
CREATE OR REPLACE PACKAGE BODY MANAGE_TEST AS
PROCEDURE QUERY_TEST(
MY_CURSOR IN OUT THE_CURSOR
AS
BEGIN
OPEN MY_CURSOR FOR
--"CURSOR" QUERY
SELECT X.MY_DATA,
CURSOR(
SELECT *
FROM TABLE (MY_NUMERIC_NTAB) ),
CURSOR(
SELECT *
FROM TABLE (MY_TEXT_NTAB) )
FROM MY_TABLE X
WHERE X.MY_KEY = 1001;
END;
END;
*****************Errors:
LINE/COL ERROR
11/11 PLS-00103: Encountered the symbol "SELECT" when expecting one of
the following:
( ) - + mod not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
table avg count current exists max min prior sql stddev sum
variance execute multiset the both leading trailing forall
year month DAY_ HOUR_ MINUTE_ second TIMEZONE_HOUR_
TIMEZONE_MINUTE_ time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL stri
12/41 PLS-00103: Encountered the symbol "," when expecting one of the
following:
; return returning and or
null

Similar Messages

  • Open cursor for a nested table

    Hi,
    I want to open a cursor like:
    open c1 for select * from emp;
    BUT
    I what the cursor results to be populated with contents of a nested table or associative array..
    How can this be done???
    Thanks in advance,
    teo

    Well, given a variable YOUR_EMP of nested table type EMP_NT it could be as simple as
    open c1 for select * from TABLE( CAST(your_emp AS emp_nt));Cheers, APC

  • How to delete the NULL entries in nest table

    Hi,
    After I used a loop and open/fetch cursor populated the object table
    I found there are random NULL entries in my object table (nest table)
    The data look like this
    NULL NULL           NULL
    NULL NULL           NULL
    123     03-MAY-04     ACTIVE
    NULL NULL           NULL
    NULL NULL           NULL
    234     21-MAY-04     ACTIVE
    NULL NULL           NULL
    345     11-MAY-04     ACTIVE
    NULL NULL           NULL
    How can I get rid of those NULL entries in my nest table? So it can become
    123     03-MAY-04     ACTIVE
    234     21-MAY-04     ACTIVE
    345     11-MAY-04     ACTIVE
    Additional info:
    create type myType as object
    (id NUMBER (10,0),
    eff_date date,
    status VARCHAR2(17)
    create type myNestTab as table of myType;
    I have tried Delete procedure in following two ways.
    Version 1:
    FOR i IN l_my_nest_tab.FIRST..l_my_nest_tab.LAST
    LOOP
    IF l_my_nest_tab(i).id IS NULL THEN
    l_curr_event_tb.DELETE(i);
                   END IF;                         
    END LOOP;
    Version 2:
    FOR i IN l_my_nest_tab.FIRST..l_my_nest_tab.LAST
    LOOP
    IF l_my_nest_tab(i) IS NULL THEN
    l_curr_event_tb.DELETE(i);
                   END IF;                         
    END LOOP;
    Both of them give me the error “no data found.” And only left me the first NOT NULL entry in the table.
    123     03-MAY-04     ACTIVE
    Thanks in avdance.

    Hi Vishnu,
    u can write a report program for this and in that use the event  :
    AT NEW <field-name> ( use primary key)
    your statements
    ENDAT
    for eg.
    loop at itab ( herfe itab must be of type of table for which u want to track new entries)
    at new matnr
    write:/ new record
    endat
    endloop.
    schedule this report in background to run in every 5 or 10 mins as per your requirement and hence changes can be tracked.
    regards
    Vinod

  • Dissapearing nested tables

    Please see this package, which contains INDD (CC2014, fully updated) and IDML file.
    This file is an excerpt of a catalog which i'm layouting (early phase).
    The table contains some nested tables. Somehow, many of these tables "dissapear". They are there, not in overset, but they aren't visible in InDesign nor when exporting to PDF.
    InDesign seems to need some trigger to make them visible again, by simply cutting the text frame and pasting it again, or by typing some text in the cell which contains the inline table (doesn't always work). Using an IDML to rebuild the INDD also fixes it.
    The INDD is saved with some disappeared nested tables in the right column.
    So... the problem is not how to get them back, but how to prevent them from disappearing...
    It happens all the time. Seems like a bug, but i'm not sure what causes it. I won't risk building the full catalog using these nested tables if they cannot be trusted.
    Any ideas what is causing this behaviour?
    As an alternative I could use tabbed paragraph styles instead of tables, but I prefer nested tables because of more flexible styling options (if they don't dissapear offcourse...).
    Any help appreciated!

    Hm, downloaded your packaged file, opened the InDesign document and the provided IDML file in CC-2014.2.
    I can clearly see the problem.
    Then tried to use the Story Editor Window to check what is going wrong in the InDesign table.
    That crashed my CC-2014.2 instantly:
    Process: Adobe InDesign CC 2014 [3310]
    Path: /Applications/Adobe InDesign CC 2014.2/Adobe InDesign CC 2014.2.app/Contents/MacOS/Adobe InDesign CC 2014
    Identifier: com.adobe.InDesign
    Version: 10.2.0.69 (10200)
    Code Type: X86-64 (Native)
    Parent Process: launchd [171]
    Date/Time: 2015-05-13 11:53:55.150 +0200
    OS Version: Mac OS X 10.7.5 (11G63b)
    Report Version: 9
    Interval Since Last Report: 12325693 sec
    Crashes Since Last Report: 143
    Per-App Interval Since Last Report: 1718998 sec
    Per-App Crashes Since Last Report: 14
    Anonymous UUID: 6B35CF4F-5E5F-486B-BD55-DA0DF8FA5323
    Crashed Thread: 0 Dispatch queue: com.apple.main-thread
    Exception Type: EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
    VM Regions Near 0:
    -->
    __TEXT 000000010b3bc000-000000010b3c2000 [ 24K] r-x/rwx SM=COW /Applications/Adobe InDesign CC 2014.2/Adobe InDesign CC 2014.2.app/Contents/MacOS/Adobe InDesign CC 2014
    Application Specific Information:
    objc[3310]: garbage collection is OFF
    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0 WidgetBinLib.dylib  0x000000010b7431e7 FrameHitTestPolicyCallback::operator()(PMPoint const&, ITableFrame const*, ITableFrame::HitTestData*) + 55
    1 com.adobe.InDesign.Table Model  0x0000000119c04701 0x119b50000 + 739073
    2 com.adobe.InDesign.Text Editor  0x000000011532e274 0x1152ca000 + 410228
    3 com.adobe.InDesign.Text Editor  0x0000000115329b7f 0x1152ca000 + 392063
    4 com.adobe.InDesign.Text Editor  0x000000011533168e 0x1152ca000 + 423566
    5 com.adobe.InDesign.Text Editor  0x000000011533134e 0x1152ca000 + 422734
    6 com.adobe.InDesign.Text Editor  0x00000001153301e6 0x1152ca000 + 418278
    7 com.adobe.InDesign.Text Editor  0x000000011532febd 0x1152ca000 + 417469
    8 com.adobe.InDesign.Text Editor  0x00000001152f0f13 0x1152ca000 + 159507
    9 com.adobe.InDesign.Application UI  0x0000000115a6fd37 0x115a68000 + 32055
    I suspect, that something in your InDesign table is very, very wrong. May be the table is corrupt.
    Exporting to IDML and working on with the IDML file would be my recommendation.
    Uwe

  • How to DEREF a nested Table of REFs?

    Can someone provide an example of how to deference, DEREF, a nested table of refs? (i.e. in order to access the attributes of the objects whose references appear in the nested table)
    I'm creating object views based on relational tables. One of my object views contains a nested table of refs which represents a FK relationship, (1:M).
    We're running ORACLE 8.1.7
    EXAMPLE DDL:
    /* FORWARD DECLARATIONS SO THINGS COMPILE */
    CREATE TYPE TEST_DAY_T AS OBJECT
    CREATE TYPE TEST_SECTION_T AS OBJECT
    /* COLLECTION TYPES */
    CREATE OR REPLACE
    TYPE TEST_SECTION_REFTAB_T AS TABLE OF REF TEST_SECTION_T
    /* OBJECT TYPES */
    CREATE OR REPLACE
    TYPE TEST_DAY_T AS OBJECT
    (TEST_ID NUMBER(12)
    ,TEST_DAY NUMBER(1)
    ,TEST_SECTIONS TEST_SECTION_REFTAB_T
    CREATE OR REPLACE
    TYPE TEST_SECTION_T AS OBJECT
    (TEST_ID NUMBER(12)
    ,TEST_DAY NUMBER(1)
    ,SECTION_SEQ NUMBER(3)
    ,SECTION_NAME VARCHAR2(32)
    /* TABLE DEFS */
    CREATE TABLE test_day
    test_id NUMBER(12) NOT NULL,
    test_day NUMBER(1) NOT NULL
    ALTER TABLE test_day
    ADD CONSTRAINT test_day_pk PRIMARY KEY (test_id,test_day)
    CREATE TABLE test_section
    test_id NUMBER(12) NOT NULL,
    test_day NUMBER(1) NOT NULL,
    section_seq NUMBER(3) NOT NULL,
    section_name VARCHAR2(32) NOT NULL
    ALTER TABLE test_section
    ADD CONSTRAINT test_section_pk PRIMARY KEY (test_id,test_day,section_seq)
    ALTER TABLE test_section
    ADD CONSTRAINT test_section_fk01 FOREIGN KEY (test_id,test_day)
    REFERENCES TEST_DAY(test_id,test_day)
    /* OBJECT VIEWS */
    CREATE OR REPLACE VIEW v_test_section_obj
    OF TEST_SECTION_T
    WITH OBJECT OID (TEST_ID, TEST_DAY, SECTION_SEQ)
    AS
    SELECT TS.TEST_ID,
    TS.TEST_DAY,
    TS.SECTION_SEQ,
    TS.SECTION_NAME
    FROM TEST_SECTION TS
    CREATE OR REPLACE VIEW v_test_day_obj
    OF TEST_DAY_T
    WITH OBJECT OID (TEST_ID, TEST_DAY)
    AS
    SELECT TD.TEST_ID,
    TD.TEST_DAY,
    CAST(MULTISET(SELECT ref(tso)
    FROM v_test_section_obj tso
    WHERE tso.test_id = td.test_id
    AND tso.test_day = td.test_day) AS TEST_SECTION_REFTAB_T)
    FROM TEST_DAY TD
    /* CLEANUP */
    DROP VIEW v_test_day_obj
    DROP VIEW v_test_section_obj
    DROP TYPE TEST_SECTION_REFTAB_T
    DROP TYPE TEST_DAY_T
    DROP TYPE TEST_SECTION_T
    DROP TABLE TEST_SECTION
    DROP TABLE TEST_DAY

    Martin,
    You can check out an example online at http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96594/adobjvew.htm#436463.
    Regards,
    Geoff
    Can someone provide an example of how to deference, DEREF, a nested table of refs? (i.e. in order to access the attributes of the objects whose references appear in the nested table)
    I'm creating object views based on relational tables. One of my object views contains a nested table of refs which represents a FK relationship, (1:M).
    We're running ORACLE 8.1.7
    EXAMPLE DDL:
    /* FORWARD DECLARATIONS SO THINGS COMPILE */
    CREATE TYPE TEST_DAY_T AS OBJECT
    CREATE TYPE TEST_SECTION_T AS OBJECT
    /* COLLECTION TYPES */
    CREATE OR REPLACE
    TYPE TEST_SECTION_REFTAB_T AS TABLE OF REF TEST_SECTION_T
    /* OBJECT TYPES */
    CREATE OR REPLACE
    TYPE TEST_DAY_T AS OBJECT
    (TEST_ID NUMBER(12)
    ,TEST_DAY NUMBER(1)
    ,TEST_SECTIONS TEST_SECTION_REFTAB_T
    CREATE OR REPLACE
    TYPE TEST_SECTION_T AS OBJECT
    (TEST_ID NUMBER(12)
    ,TEST_DAY NUMBER(1)
    ,SECTION_SEQ NUMBER(3)
    ,SECTION_NAME VARCHAR2(32)
    /* TABLE DEFS */
    CREATE TABLE test_day
    test_id NUMBER(12) NOT NULL,
    test_day NUMBER(1) NOT NULL
    ALTER TABLE test_day
    ADD CONSTRAINT test_day_pk PRIMARY KEY (test_id,test_day)
    CREATE TABLE test_section
    test_id NUMBER(12) NOT NULL,
    test_day NUMBER(1) NOT NULL,
    section_seq NUMBER(3) NOT NULL,
    section_name VARCHAR2(32) NOT NULL
    ALTER TABLE test_section
    ADD CONSTRAINT test_section_pk PRIMARY KEY (test_id,test_day,section_seq)
    ALTER TABLE test_section
    ADD CONSTRAINT test_section_fk01 FOREIGN KEY (test_id,test_day)
    REFERENCES TEST_DAY(test_id,test_day)
    /* OBJECT VIEWS */
    CREATE OR REPLACE VIEW v_test_section_obj
    OF TEST_SECTION_T
    WITH OBJECT OID (TEST_ID, TEST_DAY, SECTION_SEQ)
    AS
    SELECT TS.TEST_ID,
    TS.TEST_DAY,
    TS.SECTION_SEQ,
    TS.SECTION_NAME
    FROM TEST_SECTION TS
    CREATE OR REPLACE VIEW v_test_day_obj
    OF TEST_DAY_T
    WITH OBJECT OID (TEST_ID, TEST_DAY)
    AS
    SELECT TD.TEST_ID,
    TD.TEST_DAY,
    CAST(MULTISET(SELECT ref(tso)
    FROM v_test_section_obj tso
    WHERE tso.test_id = td.test_id
    AND tso.test_day = td.test_day) AS TEST_SECTION_REFTAB_T)
    FROM TEST_DAY TD
    /* CLEANUP */
    DROP VIEW v_test_day_obj
    DROP VIEW v_test_section_obj
    DROP TYPE TEST_SECTION_REFTAB_T
    DROP TYPE TEST_DAY_T
    DROP TYPE TEST_SECTION_T
    DROP TABLE TEST_SECTION
    DROP TABLE TEST_DAY

  • Multi block validation in a form using nested tables

    Hi,
    I have a tables that contains 3 nested tables plus some other varchar2 columns.
    I have created a form with 4 blocks, three of them based on views on the 3 nested tables, the forth containing the other columns from the table.
    I have created relationships between the 4th block and each of the first three.
    The records in the nested tables (multi record blocks) depend on some values outside them (from the 4th block) and viceversa.
    How can I perform the validation?
    Thanks,
    Leontin

    I always use child tables rather than nested tables so this might not be applicable, but I like to use a constraint on a materialzed view when I have to validate multiple records or complicated relationships between blocks.
    This example is for inserting ranges on separate records and ensuring the start and end values match up:
    Re: need some help

  • Help with Nested Table

    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 AM

    Something 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.

  • Expoting/Importing Oracle BLOB, CLOB, Nested Tables datatypes

    I am trying to export the database containing BLOB, Nested Tables etc. and wants to import the same. But i am getting an error. Pleease help as to how i will proceed with it. This is something very urgent. please reply . i will be very thankful to you

    I believe this error is only associated with LONG data type. I have been using data pump to export/import table with LOB type without any problem.
    Data pump been having issue with LONG type check this bug
    Bug 5598333 - EXPDP/IMPDP corrupts the data for a LONG column
    Doc ID: Note:5598333.8
    It's fixed in 11.1.0.6

  • How to Export/Import Composite Objects(CLOB,Nested Table)

    I am trying to export the database containing BLOB, Nested Tables etc. and wants to import the same. But i am getting an error. Pleease help as to how i will proceed with it. This is something very urgent. please reply . i will be very thankful to you

    The only solution I've found so far as a workaround is rather convoluted.
    1. I took an export using datapump's expdp of SCHEMA1 (in 10g it will skip the table with the xmltype).
    2. I imported the data to my empty schema (SCHEMA2) using impdp. To avoid the error that the type already exists with another OID, I used the TRANSFORM=oid:n parameter e.g.
    impdp user/pwd dumpfile=noxmltable.dmp logfile=importallbutxmltable.log remap_schema=SCHEMA1:SCHEMA2 TRANSFORM=oid:n directory=MYDUMPDIR
    3. I then manually created my xmltype table in the SCHEMA2 and did a select into to load it (make sure you have the select privileges to do so):
    INSERT INTO SCHEMA2.XMLTABLE2 SELECT * FROM SCHEMA1.XMLTABLE1;
    4. I am still taking an export with exp of the xmltable as well even though I'm not sure I can do anything with it.
    Thanks!
    Edited by: stacyz on Jul 28, 2009 9:49 AM

  • How to use nested table types with XDK

    Im using Oracles XDK (xml development kit) to create xml-documents from data in database.4
    Problem: I need to use nested tables but when trying to create nested table types I get error: A Table type may not contain a nested table type or VARRAY.
    Hope I make myself clear! Are there any solutions or workarounds to this problem?
    Help appreciated, thanks!

    Jesper,
    I asked similar question last year (search for Tapsell, you will see my posting). Under 8.1.7 the "nesting" seems restricted to one level down. Thus you cannot create a type using another object that itself includes a nested table. Under Oracle 9, against which most current examples seem based, this limitation is removed making things easier. Under 8.1.7 the workaround I have used is to use the CAST syntax. This is not as neat, but it works.

  • Bind ordered pair of nested tables into cursor

    Hello,
    I'd like to ask you for help. I was searching for this topic, but haven't found any answer.
    This is a very simple example that works with HR schema.
    I have a stored type:
    CREATE TYPE t_ids AS TABLE OF NUMBER(9);
    and simple procedure. There is a cursor with paremeter that accepts nested table and uses MEMBER OF operator.
    CREATE OR REPLACE PROCEDURE m_test
    AS
    CURSOR mycur (a_ids t_ids)
    IS
    SELECT last_name
    FROM employees
    WHERE employee_id MEMBER OF a_ids;
    some_ids t_ids;
    TYPE t_result IS TABLE OF employees.first_name%TYPE;
    result_table t_result;
    BEGIN
    some_ids := t_ids(100,101,102);
    OPEN mycur (some_ids);
    FETCH mycur BULK COLLECT INTO result_table;
    CLOSE mycur;
    DBMS_OUTPUT.PUT_LINE('count: ' || result_table.COUNT);
    END m_test;
    This example works fine. BUT - What I need is to modify the cursor in this way:
    CURSOR mycur (a_ids t_ids)
    IS
    SELECT last_name
    FROM employees
    WHERE *(employee_id,manager_id)* MEMBER OF (a_ids,a_ids);
    Well - this does not function - and is't my question - which operator should I use to compare ordered pair with two nested tables?
    Thank you!
    Pavel Ruzicka
    Edited by: user8117512 on 28.8.2009 6:12

    user8117512 wrote:
    No, no, pls. don't look at repeating a_ids. This is only an example. There could be two different nested tables.
    There is, lets say,
    (employee_id,manager_id) MEMBER OF (a_fist_table,a_second_table);But this syntax doesn't have a meaning (yet). So you'll have to explain what you mean with that syntax.
    Possibilities:
    - Treat the two independent collections a_first_table and a_second_table as a collection containing elements that are a tuple. Only use the ones with a subscript occuring in both collections. Then check if the tuple (employee_id,manager_id) occurs within that set.
    - Check if employee_id or manager_id occurs within the set a_first_table UNION ALL a_second table. If so, then it's a member.
    You'll have to be more specific, before we start guessing.
    Regards,
    Rob.

  • Retrieving nested table columns through a REF CURSOR in php

    Hello.
    I have been able to execute REF CURSORS returned by pl/sql functions succesfully with php. I have also been able to bind collections to the input/output of pl/sql functions/procedures.
    However, what I am unable to do, is to execute a cursor returned by a pl/sql function that has one of the columns a named datatype (a simple one-dimensional nested table):
    create type stab is table of varchar2(255);
    create table lp_landing (
    token varchar2(255),
    text varchar2(512),
    country varchar2(255),
    creator varchar2(255),
    is_active char(1),
    css_file char(1),
    autofollowing stab default stab(),
    constraint lp_landing_pk primary key (token)) organization index
    nested table autofollowing store as lp_landings_af_nt
    (constraint autofollowing_pk primary key (nested_table_id,column_value)) organization index compress
    function landings_usercountry (in_uname in lp_users.uname%type, in_country in lp_country.cname%type) return Landing_curType
    is
    ret Landing_curType;
    begin
    open ret for
    select * --token,text,country,creator,is_active,css_file,tab2str(autofollowing) as autofollowing
    from lp_landing
    where country = (select country
    from lp_permissions
    where country = in_country and uname = in_uname);
    return ret;
    end landings_usercountry;
    here is the php:
    $sql = 'BEGIN :res := LP_PKG.landings_usercountry(:user, :country); END;';
    $stmt = oci_parse($c, $sql);
    $cursor = oci_new_cursor($c);
    oci_bind_by_name($stmt,':user',$name, 32);
    oci_bind_by_name($stmt,':country',$country, 32);
    oci_bind_by_name($stmt,':res', $cursor, -1, OCI_B_CURSOR);
    $name = "root";
    $country = "Spain";
    try {
       @oci_execute($stmt);
       $m = oci_error($stmt);
       if($m){
           throw new Exception($m['message'], $m['code']);
       }else{
           @oci_execute($cursor);
           $m = oci_error($cursor);
           if($m){
               throw new Exception($m['message'], $m['code']);
           }else{
               while ( $entry = oci_fetch_object($cursor) ) {
                    var_dump($entry);
    } catch (Exception $e) {
       print_r($e);
    With "select *" in the function, the autofollowing column (of datatype stab) fails to bind, giving an ORA-932 error. The workaround for the moment is to convert the nested table to a comma delimited string (via the tab2str function).
    However, I would like to be able to tell php to accept a collection within the cursor, but I cannot figure out how to do this.
    Any ideas?
    thx in advance

    yes, it is an ORA-932:
    Warning: oci_fetch_object() [function.oci-fetch-object]: ORA-00932: inconsistent datatypes: expected CHAR got ADT in /home/apolion/apache2/htdocs/old/test1.php on line 104

  • NESTED TABLE BIND VARIABLE IN A REF CURSOR

    Hi,
    this works:
    open c_ref for v_sql using cp_asset_type
    where cp_asset_type is a nested tables passed into the proc as an 'in' parameter, but since the number of passed tables varies I loaded the nemes into an a nested table and tried the following:
    -- ELSIF BIND_COUNT.COUNT = 8 THEN
    -- OPEN C_REF FOR V_SQL
    -- USING BIND_COUNT(1),BIND_COUNT(2),BIND_COUNT(3),BIND_COUNT(4),BIND_COUNT(5),BIND_COUNT(6),BIND_COUNT(7),BIND_COUNT(8);     
    -- END IF;     
    which produced :
    ORA-22905 CANNOT ACCESS ROWS FROM A NON-NESTED TABLE ITEM
    my guess is that I'm passing the varchar2 names of the nested tables and the 'using' statement needs the actual table ????
    if this is true is there any way to pass a pointer for the bind variable nested tables?
    Thanks,
    Victor

    <br>i removed the AND...but m still getting the same error.
    <br>Is this a versioning problem...since urs is 9i and m using
    <br>Oracle8i Enterprise Edition Release 8.1.7.4.0
    <br> PROCEDURE sp_SearchByDriverName(i_C in varchar2,
    i_F in varchar2,
    i_LN in varchar2,
    i_FN in varchar2,
    o_Result out ABC_CURTYPE) is
    <br> tm_corp varchar2(2);
    <br> tm_fleet varchar2(6);
    <br> dc ABC_curtype;
    <br> begin
    <br> tm_c := getformattedc(i_C);
    <br> tm_f := getformattedf(i_f);
    <br> if i_FN is not null then
    <br> open dc for
    <br> SELECT distinct b.bus_ref_access_value,
    <br> i.individual_id,
    <br> br.mf_driver_last_name LN,
    <br> br.mf_driver_first_name FN,
    <br> substr(b.bus_ref_access_value, 4, 6) FLEET1,
    <br> (select '4444' from dual) --error is still coming here
    <br> FROM bus_ref_access_values b,
    <br> bus_ref_list brl,
    <br> individual i,
    <br> unit_contact_list f,
    <br> unit u,
    <br> bus_ref_current_prop br
    <br> WHERE b.bus_ref_id = br.bus_ref_id AND
    <br> b.bus_ref_id = brl.bus_ref_id AND
    <br> brl.reference_id = u.reference_id AND
    <br> u.unit_id = f.unit_id(+) AND
    <br> i.individual_id = f.individual_id AND
    <br> f.contact_type_ref = 'DR' AND
    <br> br.mf_driver_last_name like i_LN || '%' AND
    <br> br.mf_driver_first_name like i_FN || '%' AND
    <br> substr(b.bus_ref_access_value, 1, 2) = tm_c AND
    <br> substr(b.bus_ref_access_value, 4, 6) = tm_f AND
    <br> b.bus_ref_access_label = 'UNIT NUMBER'
    <br> ORDER BY 4, 3, 2;
    <br> close dc;
    <br>end if;

  • OCI doc says Cursor and Nested table have the same bind type SQLT_RSET but they don't

    5 Binding and Defining in OCI
    PL/SQL REF CURSORs and Nested Tables in OCI
    says SQLT_RSET is passed for the dty parameter.
    If I use SQLT_RSET for the return value of a function that returns a table and pass a statement handle's address for the OCI parameter data pointer, I expected that the statement handle will be instantiated as a result of executing the function on which I can further perform fetch, similar to a cursor. But it throws exception PLS-00382: expression is of wrong type ORA-06550: line 2, column 3. Is the above documentation wrong?
    From the OCI header file I see that for varray and nested table it mentions to use SQLT_NCO. I could find no example in the OCI documentation on how to pass or receive as return value a nested value when using SQLT_NCO.
    Please help before I shoot myself.

    So the Nested table I quoted in the doc is not actually used to mean a table type below?
    create type t_resultsetdata as object (
    i int, d decimal, c varchar(10)
    create type t_nested_resultsetdata as table of t_resultsetdata;
    create function Blah return t_nested_resultsetdata  is . . .
    For this you are saying to use SQL_NTY and not SQL_NCO. Can you tell where this usage is documented, because ocidfn.h says
    #define SQLT_NTY  108                              
    /* named object type */
    #define SQLT_NCO  122 
    /* named collection type (varray or nested table) */
    Another question - Because of the original document I said I followed, I thought I could treat cursor and nested table similarly in the calling application, i.e. I could repeatedly do a fetch on the OCIStmt* which will be bound for nested table. Now from what you say I understand I can't really bind a OCIStmt* for nested table but have an object type. That means it will get all the data of that collection in one go, right? LIke I said, lack of examples is making this tough. I don't want to look into OCI source code, as that will be too much.

  • 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,
    Rekha

    You 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'
    /

Maybe you are looking for

  • Website not displaying in Firefox. Works fine in IE 10 & Chrome. Windows 8/x64

    Using Firefox 21.0 on Windows 8/x64. I am experiencing some sites where Firefox displays an odd looking graphic but none of the UI that displays in Chrome or IE 10. I can re-create it for example by going to http://www.basspay.com. I'm stumped. I rem

  • Calling a stylesheet from content server

    Greetings i have a webcenter application and i have uploaded all my resources (images,flash animations and stylesheets) to a content server, i am trying to use the style sheets so i am doing this <link rel="stylesheet" type="text/css" afrres="true" h

  • Can someone help with transfer to iPod

    I have several home movies that I converted to mpeg4 with Handbrake but only one of them will transfer to my iPod. I keep getting a prompt that says it won't play on the iPod. It plays beautifully in iTunes. Can someone help? Thanks, Judy

  • Best lens for T4i for shooting at night with bright lights?

    I am looking for a lens for my Canon Rebel T4i. I am a news photographer and I shoot fire, police, and ambulance scenes at night where there are flashing lights like this: https://farm4.staticflickr.com/3857/15157183675_9500a2f415_b.jpg. My current l

  • EMac needs Safari 2.0.4

    Hi, I am using an eMac 10.3.9 and we have a shared calendar in Google for our business. We need a minimum of Safari 2.0.4 for this. Do I need to update to a higher version of OS X, 10.4.? to make this happen? How do I go about doing this? Thank you,