Collections of SQL / objects - how to store a table within a column?

Hi guys,.

I have a current table on production... I'm only allow you to add a column to her...

The simplified scenario is...

I have a table

CREATE TABLE PLAN_TRANSACTION
(THE ARGUMENT PLAN_ID VARCHAR2 (20) DEFAULT SYS_GUID();)
PLAN_NUMBERS_TYPE COLUMN? );

For the PLAN_NUMBERS column, I want to store all types and numbers associated with the PLAN_ID.


In general, it would be

CREATE TABLE TYPES_AND_NUMBERS
(TYPE VARCHAR2 (20),)
NUMBER OF NUMBERS);
---------------------------------
Type A, 12345
Type B, 12345
Type A, 54211

etc.

Now instead of add another additional column PLAN_ID TYPES_AND_NUMBERS table and create a relationship of foreign key with PLAN_TRANSACTION.
I want to keep the table inside the table PLAN_TRANSACTION column.


I think doing this


CREATE TYPE TYPES_AND_NUMBERS AS OBJECT
(TYPE VARCHAR2 (20),)
NUMBER NUMBERS);

CREATE TABLE AS TN_TAB TYPE OF TYPES_AND_NUMBERS;


CREATE TABLE PLAN_TRANSACTION
(THE ARGUMENT PLAN_ID VARCHAR2 (20),)
PLAN_NUMBERS TN_TAB
)
THE NESTED TABLE PLAN_NUMBERS
STORE AS NESTED_PLAN_NUMBERS;


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

My question is...

Q1) is my way of creating a correct nested table?... creating an object type, then an array of objects, then storing this table within a column in a nested table...

Q2) is otherwise easier to create a nested table as I quite new in object_relational--concepts simply, I felt quite concerned create an object to simulate a line. and create an array of object to store objects, and then put it inside a column.

Q3) possible for me, or is it something like create type TN_TAB as table of (varchar2 TYPE, numbers);


Thanks a lot guys!

Best regards
Noob

A nested table is the easiest way to resolve this condition.
Other solutions might involve some large objects (CLOB or XMLTYPES), but without knowing anything commercially, I think a nested table is the best way.

Tags: Database

Similar Questions

  • Columns of type OBJECT: how to store as SECUREFICHIERS

    I have a large table with a column of OBJECT type, each of which contains a good amount of data. It would be very compressible, if only it was stored as a navigation. Is there a way to specify that the LOB that Oracle uses to implement objects are stored as a navigation?

    Thank you

    Gary

    Hi Gary,.

    You can set the parameter db_securefile, to enforce using securefile.
    You can also consider moving the lob to a compressed lob or dédupliquée.
    ALTER table move lob...
    HTH Mathias

  • How to create a table with editable column values.

    Hello world
    I think it's very simple, but I am unable to find how to do this. This is my requirement. I need to create a table with n columns and 1 line initially. the user must be able to enter data into this table and click of a button must insert the data into the database table. Also, there should be a button at the bottom of the table to add 1 line to the table.

    I know how to do the insertion of data, but can someone please let me know how to create a table which allows the user to enter data and how to create a line button Add 1?


    Thanks in advance!

    Raghu,

    Go through the tutorial of Toolbox Page & Advanced section of the Guide of the OFA table.

    Step 1 - you need to create EO & VO from this EO. This EO will be table of database where you want to insert the data.

    Step 2 - create an advanced table region. (See this section in table advanced for more details)

    Step 3 - attach this VO in the BC4J region advanced Table component.

    Kind regards
    GYAN

  • Entity of PL/SQL object - how to access the PARAMETERS in the OA Page

    Hello

    I have the following pl/sql code that takes 4 entry and inserts values in the database table.

    create or replace procedure is xxfwk_emp_create (p_person_id NUMBER, p_first_name IN VARCHAR2, p_last_name IN VARCHAR2), p_sal in NUMBERS, p_error_msg OUT VARCHAR2
    cursor c1 is select EMPLOYEE_ID of fwk_tbx_employees;
    v_status varchar2 (1): = ';
    BEGIN
    for v_c1 looping c1
    If v_c1.employee_id = p_person_id then
    p_error_msg: = "nobody with this id already exists."
    v_status: = 'e ';
    end if;
    When exit c1% notfound GOLD v_status = "e";
    end loop;
    If v_status = 'e' then
    GoTo error;
    end if;
    INSERT INTO FWK_TBX_EMPLOYEES (EMPLOYEE_ID,
    FIRST NAME,
    LAST_NAME,
    FULL_NAME,
    SALARY,
    CREATION_DATE,
    CREATED_BY,
    LAST_UPDATE_DATE,
    LAST_UPDATED_BY,
    LAST_UPDATE_LOGIN)
    VALUES (p_person_id,
    p_first_name,
    p_last_name,
    P_first_name | » '|| p_last_name,
    p_sal,
    SYSDATE,
    fnd_global.user_id,
    SYSDATE,
    fnd_global.user_id,
    fnd_global.login_id);
    < < error > >
    null;
    END xxfwk_emp_create;
    /


    I have the code in the EO Impl class

    Public Sub::InsertRow()
    {
    Try
    {
    OADBTransactionImpl oadbTrans = (OADBTransactionImpl) getDBTransaction ();
    String s = "start xxfwk_emp_create (p_person_id = >: 1, p_first_name = >: 2, p_last_name = >: 3, p_sal = >: 4, p_error_msg = >: 5); end; » ;
    OracleCallableStatement oraCall (OracleCallableStatement) = oadbTrans.createCallableStatement (s,-1);
    oraCall.setNUMBER (1, getEmployeeId ());
    oraCall.setString (2, getFirstName ());
    oraCall.setString (3, getLastName ());
    oraCall.setNUMBER (4, getSalary ());
    * < /Comment access the setting Out the procedure > *.
    oraCall.execute ();
    }
    catch (SQLException sqlException)
    {
    throw OAException.wrapperException (sqlException);
    }
    catch (System.Exception Exception)
    {
    throw OAException.wrapperException (exception);
    }

    }
    This insertRow, I want to get the error message (on param) and remove this message as exception in page OA.

    What changes I need to make in my page?

    Kind regards
    RAM

    Hi Ram,

    You must first set the out parameters as follows:
    ((OracleCallableStatement) oraCall) .registerOutParameter (5, OracleTypes.VARCHAR, 0, 10);

    Then execute the callable statement. After that, you can get the value as
    String value = oraCall.getString (5);

    Hope that helps.

    Thank you
    Sumit

  • With CVI SQL Toolkit, how to add the new variable param column in a table.

    Dear all:

    I used the CVI Sql toolkit to create a database, but now I don't know how to add a new column to a table in variable param.

    I know, to add a column with the name of constant column could be down by below:

    DBImmediateSQL ((hdbc, "alter table table1 add column1 char [100]");

    But if Column1 is a param variablae how can I write the code? Please advise?  It will be appreciated if you could give me an example.

    Best regards!

    HI -.

    If you look at the parameters that you pass to the SQL function, you can see that the second parameter is a string constant. In your code, you can create an array of characters (string). You can then use sprintf to programmatically determine what will be the contents of this variable. In the function call, you can put the variable instead of the literal string, and you will have a customizable SQL statement.

    Hope this helps-

    John M

  • How to create the Table using the column Drag and Drop feature

    Hello:
    I'm new to Data Modeler tool Oracle SQL dev and would like to know if there is a way to create a new table by reusing existing columns or groups of columns. The idea is to maintain consistency and save time of table design. If the columns created previously can be reused and require, drag and drop column in the right pane, then only new columns must be created manually.

    Any thoughts on this will be appreciated.

    Thank you!

    Yes - just change the name of the model table in the script (t_name = "table_template") then save this new transformation for later use.

    I don't know how to apply only some of the tables. Seems like something you could do to a secondary view level?

    Perhaps someone else on the forum can advise how to change the script to work on a subview only instead of the whole model.

  • How to create a table with a column that is the value in another table?

    Hi all,

    It's my first post n I changed my ODI of DATASTAGE platform. Help me friends n I know basic steps in 11 ODI version which I was training in my company. I hope to have your support and can do everything an action ODI related documents.

    My question is...

    Table T1 > > > > > > > > > >

    service id / / / attr.name / / / attr.value

    S1 / / / product_code / / / P1

    S1 / / / provider / / / pro1

    S2 / / / product_code / / / P2

    S3 / / / provider / / / pro3

    Table T2 > > > > > > > > > > > > > > >

    ID / / / product_code / / / provider

    S1 / / / p1 / / / pro1

    S2 / / / p2 / / / nullvalue

    S3 / / / nullvalue / / / pro3


    I have a table T1 since I should show the table T2 is released. Can we say everything on how to write a logic and steps to follow.

    Thanks in advance.

    Published by: 854662 on April 26, 2011 01:59

    Hello

    U go.

    1 the interface:

    "Put a filter in your 1 on attr.name = array ' PRODUCT_CODE.

    In the map target TABLE2
    SERVICE_ID = TABLE1. SERVICE_ID
    PRODUCT_CODE = TABLE1. ATTR_VALUE

    Use SQL IKM append control

    Interface 2:

    "Put a filter in your 1 on attr.name = array ' PROVIDER '.

    In the map target TABLE2
    SERVICE_ID = TABLE1. SERVICE_ID
    PROVIDER = TABLE1. ATTR_VALUE

    Do SERVICE_ID as KEY (when you click the column target in properties, you can see KEY under properties of the target column) and use the incremental update of the IKM Oracle.

    PS: I assume that Oracle as the source and target.

    And you can refer to the documentation,

    https://Apex.Oracle.com/pls/Apex/f?p=44785:24:4413167952886630:no:24:P24_CONTENT_ID, P24_PREV_PAGE:5185, 29

    http://odiexperts.com/

    And of course this OTN.

    Thank you
    Guru

  • How to find DB tables containing specific columns (ORG_ID / ORGANIZATION_ID)

    Hi all, I would like to know if someone has developed a script to find all tables containing the columns (fields) specific.


    I'm on a migration project where I don't have access to the source of the DB, I just ask for queries and I to reflect all the tables DB containing specific data of organization.

    So the first step was to understand used tables and I get them, now I understand what tables have Org_id / Organization_ID and fields of the SOURCE of the LANGUAGE/LANGUAGE (source DB has much set Org and many languages also, so I need to filter the 100total 6ORG_ID and 2 languages of 8 total installed)

    Can anyone help?

    Thank you

    Best regards

    Pietro

    Hello

    You can see this:

    Find all tables in db with the name of the column of a particular string?

    Kind regards

    MihaiF

  • How to update a table whose name column contains an ampersand?

    Hello

    I need to update a column whose column name contains an ampersand and cannot find a way to do it. Option is not there to have the name of the column changed.

    Ex:

    Aircraft UPDATE
    SET d & f = 1
    WHERE aircraft_code = '737';

    This property returns an error of missing an = sign

    I tried:
    TOGETHER would be ' |' &' | 'f' = 1

    does not work


    Any help is greatly appreciated.

    Thank you
    Laura

    SET DEFINE OFF
    stop to interpret the & sign as from a lexical setting on the client.

    Not sure if you have this problem here.
    & could also has power not characters in the normal column names (didn't test).

    In this case, you will need to put the name of column ".»

    + example +.
    {code}
    Aircraft UPDATE
    The VALUE "d & f" = 1
    WHERE aircraft_code = '737';
    {code}

    Be aware that in this case the column name must be spelled exactly as if it was when the table was created.
    Included case.

    {code}
    Aircraft UPDATE
    THE "D & F" VALUE = 1
    WHERE aircraft_code = '737';
    {code}

  • How to upgrade a table within a trigger

    I have a simple question.
    Suppose I have the table TAB1 with fields F1 and F2 and I created the following trigger;

    create or replace trigger insert_TAB1
    After Insert on TAB1
    for each line
    declare

    Tab1 v_F2. % Of F2 type;

    Start

    ...
    ...
    v_F2: =...;
    ...
    ...

    Update TAB1
    the F2 value = v_F2
    where F1 =: old. F1;

    end;

    If I try to insert a record into TAB1, I get:

    ERROR on line 1:
    ORA-04091: table tab1 is changing, function of triggering/can not see
    ORA-06512: at "INSERT_TAB1", line 47
    ORA-04088: error during execution of trigger 'INSERT_TAB1 '.

    Can you help me?
    What I want is to write a trigger that inserts a value into a field after that insert was performed in the table.

    Thank you!

    Hello

    Thank you for this.

    The trigger can be written like this

    create or replace trigger insert_TAB1
    before insert on TAB1
    for each row when(new.F1 is not null)
    begin
    :new.F2=..;
    end;
    

    see you soon

    VT

  • How print/store in the ref cursor block pl/sql folder?

    How print/store in the ref cursor block pl/sql folder?

    return to the SQL * the method I showed above:

    SQL> create or replace procedure test (p_refcur out sys_refcursor)
      2  is
      3  begin
      4    open p_refcur for select * from dual union all select * from dual;
      5  end test;
      6  /
    
    Procedure created.
    
    SQL> var r refcursor;
    SQL> begin
      2    test(:r);
      3  end;
      4  /
    
    PL/SQL procedure successfully completed.
    
    SQL> print r;
    
    D
    -
    X
    X
    
    2 rows selected.
    
  • I have the table of 3 columns A, B, C. I want to store the sum of columns A B in the C column without using the DML statements. Can anyone help please how to do. ?

    I have the table of 3 columns A, B, C. I want to store the sum of columns A B in the C column without using the DML statements. Can anyone help please how to do. ?

    11.1 and especially you have virtual column

    SQL> create table t
      2  (
      3     a number
      4   , b number
      5   , c generated always as (a+b) virtual
      6  );
    
    Table created.
    
    SQL> insert into t (a, b) values (1, 2);
    
    1 row created.
    
    SQL> select * from t;
    
             A          B          C
    ---------- ---------- ----------
             1          2          3
    

    Before that, a front insert - trigger

    SQL> create table t
      2  (
      3     a number
      4   , b number
      5   , c number
      6  );
    
    Table created.
    
    SQL> create or replace trigger t_default before insert on t for each row
      2  begin
      3    :new.c := :new.a+:new.b;
      4  end;
      5  /
    
    Trigger created.
    
    SQL> insert into t (a, b) values (1, 2);
    
    1 row created.
    
    SQL> select * from t;
    
             A          B          C
    ---------- ---------- ----------
             1          2          3
    
  • How to store values of TextField in table

    Hello

    I am trying to write a code to store values of TextField in a table. I know how to convert entire TextField. But after that, we have different integer variables. I can't understand how to store values of these whole different variables in a table by using a loop.

    public class ArrAvg {}

    Public Shared Sub main (String [] args) {}

    int arr [10] = new int [10];

    inputNumbers (arr);

    }

    void int inputNumbers (int arr [10]) {}

    int i;

    TextField field1 = new JTextField();

    TextField Field2 = new JTextField();

    Field3 TextField = new JTextField();

    String value1 = field1.getText ();

    String value2 = field2.getText ();

    String value3 = field3.getText ();

    val1 = Integer.parseInt (value1);

    val2 = Integer.parseInt (value2);

    val3 = Integer.parseInt (value3);

    for (i = 0; i < 10; ++ I) {}

    arr [i] = val1 (this should be replaced by val2 and after that by val3? I don't know how to do this)

    }

    }

    Some body please guide me.

    Zulfi.

    I have stored text field in ArrayList so i should traverse the ArrayList. But when i am converting the contents of Arraylist into integer, i am getting type mismatch despite the fact that my ArrayList is of String type.
    
    
    

    Yes - the ArrayList to string but you create an iterator for object

    Iterator itr = al.iterator (); getting iterator of arraylist to iterate through the items

    This method of "al.iterator" () returns the iterator; for your use case E-online String. See the API

    https://docs.Oracle.com/javase/8/docs/API/Java/util/ArrayList.html

    You set it to 'Iterator' which is NOT a generic, so only objects are returned.

    So get back to string.

    Create your instance of the iterator Iterator.

    Is it possible to avoid "iterator"?

    Why avoid it? Just use the appropriate iterator.

    The class has a 'size' and a method 'get (int index) '. So you can use a loop from zero to the 'size', but simply use the iterator.

  • How to represent Nested table as variable/object in OIC

    Hi all

    I'm new to the BEAK.

    I now have the nested in my database table.
    Nested table:
    Create the type type1 as an object (name varchar2 (20));
    Create the type type2 as type1 table;
    create table table1 (varchar2 (20) col1, col2 type2) store col2 table nested as table2;

    Can someone help me to col2 as C structure/typedef to use it with OCIDefineObject?

    You can take a look at Chapter 11 of the Guide to the programmer of the OIC. Look at the Collections inside section. You can represent the nested as OCITable table *. In addition, you can generate a representation of the structure of your object using OTT type. Please let us know if that answers your question. In the case where you are not able to proceed please let us know.

    Thank you
    Sumit

  • How to store the output of a statement select * statement in a file?

    How to store the output of a statement select * / statement of dsc in a file?

    As user sys:

    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    /
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /
    

    As myuser:

    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      --
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    

    This allows the header line and the data to write into files separate if necessary.

    for example

    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    
    PL/SQL procedure successfully completed.
    

    Output.txt file contains:

    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10
    

    The procedure allows for the header and the data to separate files if necessary. Just by specifying the file name "header" will put the header and the data in a single file.

Maybe you are looking for