Record table Nested sorting

Hello

Can you help me to sort (based on join date) below table nested using the TABLE function?

declare
type is rendered
(emp_id char (20),
date of join_d);
type emp_tbl_type is table of SheikYerbouti;

non_sorted emp_tbl_type;
asc_sorted emp_tbl_type;
Start
-create sample data

non_sorted (1) .emp_id: = '1';
non_sorted (1) .join_d: = sysdate + 5;
non_sorted (2) .emp_id: = '2';
non_sorted (2) .join_d: = sysdate + 1;
non_sorted (3) .emp_id: = '3';
non_sorted (3) .join_d: = sysdate + 7;
non_sorted (4) .emp_id: = '4';
non_sorted (4) .join_d: = sysdate + 7;

for me in non_sorted.first... loop of non_sorted. Last

dbms_output.put_line ('Emp ID :'|| non_sorted (i) .emp_id |) ' Date :'|| non_sorted (i) .join_d);
end loop;

Select emp_id, join_d
LOOSE COLLECTION asc_sorted
table (cast (non_sorted AS emp_tbl_type))
order of join_d;
-can you sort these data and move it to asc_sorted

because me in 1... loop asc_sorted. Count

dbms_output.put_line ('Emp ID :'|| asc_sorted (i) .emp_id |) ' Date :'|| asc_sorted (i) .join_d);
end loop;


end;

Thank you!

Thanks I fixed the issue after reading the oracle documentation.

declare

non_sorted emp_tbl_type: = emp_tbl_type();
asc_sorted emp_tbl_type: = emp_tbl_type();

/ * cursor asc_cur is
Select emp_id, join_d
table (CAST (non_sorted AS emp_tbl_type))
order of join_d; */

Start
-create sample data
non_sorted.extend;
non_sorted (1): = emp_rec('1',sysdate+5);
non_sorted.extend;
non_sorted (2): = emp_rec('2',sysdate+1);
non_sorted.extend;
non_sorted (3): = emp_rec('3',sysdate+7);
non_sorted.extend;
non_sorted (4): = emp_rec('4',sysdate+3);

for me in non_sorted.first... loop of non_sorted. Last

dbms_output.put_line ('Emp ID :'|| non_sorted (i) .emp_id |) ' Date :'|| non_sorted (i) .join_d);
end loop;

dbms_output.put_line ('* UNSORTED data ');

Select emp_rec (emp_id, join_d)
bulk collect into asc_sorted
table (CAST (non_sorted AS emp_tbl_type))
order of join_d;

dbms_output.put_line ('* UNSORTED data ');
because me in 1... loop asc_sorted. Count

dbms_output.put_line ('Emp ID :'|| asc_sorted (i) .emp_id |) ' Date :'|| asc_sorted (i) .join_d);
end loop;

end;

THX

Tags: Database

Similar Questions

  • Table nested @ schema - level how to extract the first clue?

    Hello

    My version of oracle database: 11g

    I present to you the code here and here are the steps by which I created a table and theres a regular column to the number, but the 2nd column is a nested table.

    (1) create or replace type s_def_NT_DepEmployees is table of the varchar2 (100);

    2)

    create the table employees_NT_test

    (number of department_id

    c_of_s_def_NT_DepEmployees s_def_NT_DepEmployees)

    nested as NTs_c_of_s_def_NT_DepEmployees table c_of_s_def_NT_DepEmployees store

    (3) now, I inserted 2 records:

    insert into employees_NT_test values (1, s_def_NT_DepEmployees ('Rahul', 'Myra'));

    insert into employees_NT_test values (2, s_def_NT_DepEmployees ('Rashi', 'Gaurav'));

    (4) now get me this sql allows employees of department_id: 1

    Select column_value

    table (select c_of_s_def_NT_DepEmployees in the employees_NT_test where department_id = 1);

    Output:

    Rahul

    Myra

    Now my question: I want to just choose the first clue: IE: rahul (and not myra) and it should be compatible such that if I select the two departments I should get my output like:

    Department_id | employees

    1                    | Rahul

    2                    | Rashi

    PS: I am looking for a sql query, I hope I presented my question clearly, if there are doubts please let me know.

    Thanks in advance

    Rahul

    Now my question: I want to just choose the first clue: IE: rahul(and not myra) and should be consistent

    You can only do in a deterministic manner, given the current design.

    Unlike PL/SQL, SQL has no way to access the items in the collection of their indices.

    We can think about using ROWNUM (or ROW_NUMBER) in a subquery, but the SCOREBOARD operator and later join operations do not guarantee that the order will remain the same in the different calls.

    You must redefine the collection 's_def_NT_DepEmployees' as an array of objects, and this object would include an index attribute explicitly on which you can filter.

    The alternative is to create a function that takes the collection and the index for the arguments and returns the element at index - but even in this case I'm not sure that oracle could rebuild deterministically collection either.

    Why use a table nested at all?

  • help with tables nested plsql

    Hi all
     DECLARE
       TYPE ty_valid_prfx_sfx_list_nt IS TABLE OF VARCHAR2 (3);
    
       t_vld_prx_sfx_list ty_valid_prfx_sfx_list_nt
             := ty_valid_prfx_sfx_list_nt ('JR',
                                           'SR',
                                           'I',
                                           'II',
                                           'III',
                                           'IV',
                                           'V',
                                           'RN',
                                           'MD',
                                           'MR',
                                           'MS',
                                           'DR',
                                           'MRS',
                                           'PHD',
                                           'REV',
                                           'ESQ') ;
       v_index      NUMBER;
       v_curr_val   VARCHAR2 (10);
       v_prev_val   VARCHAR2 (10);
       v_next_val   VARCHAR2 (10);
    BEGIN
       v_index := t_vld_prx_sfx_list.FIRST;
    
       WHILE v_index IS NOT NULL
       LOOP
          v_curr_val := t_vld_prx_sfx_list (v_index);
          v_prev_val := t_vld_prx_sfx_list.PRIOR (v_index);
          v_next_val := t_vld_prx_sfx_list.NEXT (v_index);
          DBMS_OUTPUT.put_line ('v_prev_val = ' || v_prev_val);
          DBMS_OUTPUT.put_line ('v_curr_val   = ' || v_curr_val);
    
          DBMS_OUTPUT.put_line ('v_next_val = ' || v_prev_val);
          --DBMS_OUTPUT.put_line (t_vld_prx_sfx_list (v_index));
          v_index := t_vld_prx_sfx_list.NEXT (v_index);
       END LOOP;
    END;
    Output:

    v_prev_val =
    v_curr_val = JR
    v_next_val =
    v_prev_val = 1
    v_curr_val = SR
    v_next_val = 1
    v_prev_val = 2
    v_curr_val = I have
    v_next_val = 2
    v_prev_val = 3
    v_curr_val = II
    v_next_val = 3
    v_prev_val = 4
    v_curr_val = III
    v_next_val = 4
    v_prev_val = 5
    v_curr_val = IV
    v_next_val = 5
    v_prev_val = 6
    v_curr_val = V
    v_next_val = 6
    v_prev_val = 7
    v_curr_val = RN
    v_next_val = 7
    v_prev_val = 8
    v_curr_val = MD
    v_next_val = 8
    v_prev_val = 9
    v_curr_val = MR
    v_next_val = 9
    v_prev_val = 10
    v_curr_val = MS
    v_next_val = 10
    v_prev_val = 11
    v_curr_val = DR
    v_next_val = 11
    v_prev_val = 12
    v_curr_val = rsam
    v_next_val = 12
    v_prev_val = 13
    v_curr_val = PhD.
    v_next_val = 13
    v_prev_val = 14
    v_curr_val = REV
    v_next_val = 14
    v_prev_val = 15
    v_curr_val = ESQ
    v_next_val = 15


    I'm getting an unexpected exit, please check and correct my program.
    expected output :
    'JR'
    'SR',
    'I',
    'II',
    'III',
    'IV',
    'V',
    'RN',
    'MD',
    'MR',
    'MS',
    'DR',
    'MRS',
    'PHD',
    'REV',
    'ESQ'
    
    fitst iteration :
    
    v_prev_val  = 
    v_curr_val  = 'JR'
    v_next_val  = 'SR',
    
    second iteration
    
    
    v_prev_val  = 'JR'
    v_curr_val  = 'SR'
    v_next_val  ='I'
    
    Third iteration:
    
    v_prev_val  = 'SR'
    v_curr_val  = 'I'
    v_next_val  ='II'
    
     .
     .
     .
     .
     .
    any help in this regard is highly appreciated




    Thank you
    Prakash P

    Published by: prakash on August 30, 2012 22:01

    An example:

    SQL> declare
      2          type TStringArray is table of varchar2(10);
      3          array TStringArray :=
      4                  new TStringArray( 'Tom', 'Commander', 'Harry', 'Sally' );
      5  begin
      6          for i in 1..array.Count loop
      7                  DBMS_OUTPUT.put_line( '***************' );
      8                  DBMS_OUTPUT.put_line( 'current='||array(i) );
      9
     10                  --//can also use: if array.Exists(i-1) then
     11                  if (i-1) >= 1 then
     12                          DBMS_OUTPUT.put_line( 'previous='||array(i-1) );
     13                  end if;
     14
     15                  --// can also use: if array.Exists(i+1) then
     16                  if (i+1) <= array.Count then
     17                          DBMS_OUTPUT.put_line( 'next='||array(i+1) );
     18                  end if;
     19
     20          end loop;
     21  end;
     22  /
    ***************
    current=Tom
    next=Commander
    ***************
    current=Commander
    previous=Tom
    next=Harry
    ***************
    current=Harry
    previous=Commander
    next=Sally
    ***************
    current=Sally
    previous=Harry
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    The Exist() method is also one that is usually used with associative arrays. Here is an example of associative array. Note that the table is sorted according to the index value. And the index value is a string - not a sequential integer.

    SQL> declare
      2          type TStringArray is table of varchar2(10) index by varchar2(20);
      3          array   TStringArray;
      4          i       varchar2(20);
      5  begin
      6          array('Intel Officer') := 'Tom';
      7          array('Mission Lead') := 'Commander';
      8          array('Radio in Head') := 'Harry';
      9          array('Military Officer') := 'Sally';
     10
     11          i := array.First();
     12          while array.Exists(i) loop
     13                  DBMS_OUTPUT.put_line( '***************' );
     14                  DBMS_OUTPUT.put_line( 'current: '||i||'='||array(i) );
     15
     16                  if array.Exists( array.Prior(i) ) then
     17                          DBMS_OUTPUT.put_line( 'prior: '|| array.Prior(i) );
     18                  end if;
     19
     20                  if array.Exists( array.Next(i) ) then
     21                          DBMS_OUTPUT.put_line( 'next: '|| array.Next(i) );
     22                  end if;
     23
     24                  i := array.Next(i);
     25          end loop;
     26  end;
     27  /
    ***************
    current: Intel Officer=Tom
    next: Military Officer
    ***************
    current: Military Officer=Sally
    prior: Intel Officer
    next: Mission Lead
    ***************
    current: Mission Lead=Commander
    prior: Military Officer
    next: Radio in Head
    ***************
    current: Radio in Head=Harry
    prior: Mission Lead
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • Bulk collect into a Table nested with Extend

    Hi all
    I want to get all the columns of the table emp and dept. So I use bulk collect into the concept of nested table.

    *) I wrote the function in three different ways. EX: 1 and 2 (DM_NESTTAB_BULKCOLLECT_1 & DM_NESTTAB_BULKCOLLECT_2) does not give the desired result.
    *) It only gives the columns of the EMP table. That means it takes DEPT & columns of the EMP table, but it only gives columns of table EMP.
    ) I think, there is something problem with nested table Extend.
    ) I want to know infested.
    Can we use bulk collect into a table nested with extend?
    If it is yes then fix the below codes (EX: 1 & EX: 2) and can you explain me please?


    Codes are given below *.

    CREATE OR REPLACE TYPE NEST_TAB IS TABLE OF THE VARCHAR2 (1000);

    EX: 1:
    ----
    -Bulk collect into a Table nested with Extend-
    CREATE or replace FUNCTION DM_NESTTAB_BULKCOLLECT_1
    RETURN NEST_TAB
    AS
    l_nesttab NEST_TAB: = NEST_TAB();
    BEGIN
    FOR tab_rec IN (SELECT table_name
    From user_tables
    WHERE table_name IN ('EMP', 'Department')) LOOP
    l_nesttab.extend;

    SELECT column_name
    bulk collect INTO l_nesttab
    Of user_tab_columns
    WHERE table_name = tab_rec.table_name
    ORDER BY column_id;
    END LOOP;

    RETURN l_nesttab;
    EXCEPTION
    WHILE OTHERS THEN
    LIFT;
    END DM_NESTTAB_BULKCOLLECT_1;

    SELECT *.
    TABLE (DM_NESTTAB_BULKCOLLECT_1);

    OUTPUT:
    -------
    EMPNO
    ENAME
    JOB
    MGR
    HIREDATE
    SAL
    COMM
    DEPTNO

    * Only the EMP table columns are there in the nested table.
    -----------------------------------------------------------------------------------------------------

    EX: 2:
    -----
    -Bulk collect in the nested with Extend based on County - Table
    CREATE or replace FUNCTION DM_NESTTAB_BULKCOLLECT_2
    RETURN NEST_TAB
    AS
    l_nesttab NEST_TAB: = NEST_TAB();
    v_col_cnt NUMBER;
    BEGIN
    FOR tab_rec IN (SELECT table_name
    From user_tables
    WHERE table_name IN ('EMP', 'Department')) LOOP
    SELECT MAX (column_id)
    IN v_col_cnt
    Of user_tab_columns
    WHERE table_name = tab_rec.table_name;

    l_nesttab. Extend (v_col_cnt);

    SELECT column_name
    bulk collect INTO l_nesttab
    Of user_tab_columns
    WHERE table_name = tab_rec.table_name
    ORDER BY column_id;
    END LOOP;

    RETURN l_nesttab;
    EXCEPTION
    WHILE OTHERS THEN
    LIFT;
    END DM_NESTTAB_BULKCOLLECT_2;

    SELECT *.
    TABLE (DM_NESTTAB_BULKCOLLECT_2);

    OUTPUT:
    -------
    EMPNO
    ENAME
    JOB
    MGR
    HIREDATE
    SAL
    COMM
    DEPTNO

    * Only the EMP table columns are there in the nested table.
    -------------------------------------------------------------------------------------------

    EX: 3:
    -----

    -Collect in bulk in a nested Table to expand aid for loop.
    CREATE or replace FUNCTION DM_NESTTAB_BULKCOLLECT_3
    RETURN NEST_TAB
    AS
    l_nesttab NEST_TAB: = NEST_TAB();
    TYPE local_nest_tab
    THE VARCHAR2 ARRAY (1000);
    l_localnesttab LOCAL_NEST_TAB: = LOCAL_NEST_TAB();
    NUMBER x: = 1;
    BEGIN
    FOR tab_rec IN (SELECT table_name
    From user_tables
    WHERE table_name IN ('EMP', 'Department')) LOOP
    SELECT column_name
    bulk collect INTO l_localnesttab
    Of user_tab_columns
    WHERE table_name = tab_rec.table_name
    ORDER BY column_id;

    BECAUSE me IN 1.l_localnesttab. COUNTING LOOP
    l_nesttab.extend;

    L_NESTTAB (x): = L_LOCALNESTTAB (i);

    x: = x + 1;
    END LOOP;
    END LOOP;

    RETURN l_nesttab;
    EXCEPTION
    WHILE OTHERS THEN
    LIFT;
    END DM_NESTTAB_BULKCOLLECT_3;

    SELECT *.
    TABLE (DM_NESTTAB_BULKCOLLECT_3);

    OUTPUT:
    ------
    DEPTNO
    DNAME
    LOC
    EMPNO
    ENAME
    JOB
    MGR
    HIREDATE
    SAL
    COMM
    DEPTNO

    * Now, I got the desired result set. DEP. and columns of the Emp Table are in the nested Table.




    Thank you
    Ann

    COLLECTION BULK cannot add values to an existing collection. It can only crush.

  • help join you a table nested with ordinary table

    IM creating a nested table object prtcnpt_info codelist. In a block anonymous im saying t_code as type nested table codelist.
    Now when I try to join the table nested to ordinary table oracle DB and I get the error: PL/SQL: ORA-00904: "COLUMN_VALUE": invalid identifier.
    Please help me on this and provide link tutorial about this concepts... Here is the code I wrote

    -Start code.
    create or replace type prtcnpt_info as an object (identification number
    , name varchar2 (200)
    (, code varchar2 (30));


    create type codelist is the prtcnpt_info table;


    declare
    t_code codelist.
    Start

    Select prtcnpt_info (b.pid, b.name, pt.code) in bulk collect into t_code
    party pt
    mc_code b
    where pt.cd in ("AAA", "BBB")
    and pt.ptype_id = b.pt_type_id;


    INSERT INTO table (ID
    RUN_ID
    DATA
    P_ID
    )
    SELECT id
    run_id
    data
    prtct.id-> 1
    IN table_2 t2
    , (by selecting column_value in table (t_code)) prtct
    WHERE prtct.id = t2. P_ID; -> 2

    end;

    -End code;
    also of the anonymous block
    1 = > is this right until you get the id value (b.pid) of the tablet_code nested as prtct alias?
    2 = > is this right until you reach the nested with ordinary table table? I want to join the id column in the tables.

    Published by: 914912 on April 30, 2012 02:11

    Write the insert like this and try

    insert into table
    (
           id
         , run_id
         , data
         , p_id
    )
     select id,
         run_id,
         data,
         prtct.id
       from table_2 t2
         table(t_code) prtct
      where prtct.id = t2.p_id;
    
  • Assistance in creation of objects Table nested in a column

    Hi all

    In our project requirement, we are supposed to create a table1 consisting of such object1 of the column and Object1 has a nested object (object2) as one of the column.

    We are able to create the table (table-name is op_sam) for object1

    create or replace type testobj1 as an object (number of c1, c2 number);
    create or replace type t_testobj in the testobj1 table;

    create table op_sam (obj_id varchar2 (100), workobj t_testobj)
    store workobj table nested as nested_tab back as a value;

    We strive to store op_sam as an object in an another table prepop

    We have created the object for the op_sam

    create or replace type op_sam_obj as an object (obj_id varchar2 (100), workobj t_testobj);
    create or replace type t_op_sam_obj in the op_sam_obj table;



    We gave the following script to create the table with the column as t_op_sam_obj

    create table prepop (ob_id varchar2 (20), t_op_sam_obj object2)
    nested table object2 store like nested_tab1 back as a value;


    ORA-22913: must specify the name of the table for the nested table column or attribute · nested tables ·

    could you please suggest me to fix this?

    Hello

    Each object of type table needs a nested table.
    Subject: object2 has a nested table object: workobj
    Then, who also has a nested table clause.

    CREATE
         TABLE prepop
         (
              ob_id VARCHAR2(20)
         , object2 t_op_sam_obj
         )
         nested TABLE object2 store AS nested_tab1
         (
              nested TABLE workobj store AS nested_tab2
         )
            return as value
    ;
    

    This will create 3 tables:
    nested_tab2 as an embedded table
    nested_tab1 as an embedded table
    prepop

    Kind regards

    Peter

  • EDM campaign... tables nested?

    Hello wonderful people.

    Wondering if anyone could help me with this little doozy...

    one of my clients wants to do an EDM for them. I did like they ask (they wanted as jpg)
    and their it staff have rewritten for me as follows:

    "Most browsers are able to solve problems with these bays, but e-mail clients cope so well." To remedy this, it may be preferable to use tables nested, instead of spanning columns and different lines. for example. "make every line contains a single < td > element and when several are required and then creating a new nested table.

    Here is a screenshot of how it will look like. Is this good? I would have thought the hotspots on the web address, Twitter and Facebook logos could have sufficed.

    Picture 13.png

    The nested tables the way forward for such things?

    Cheers!

    Michael

    Hi Michael, yes you are right the nested tables are the way to go if she'll send using e-mail clients.

    There are a few things to take note however:

    • Use hotspots with care, gmail can not detect hot spots that mean the redirect url does not work... Yahoo, hotmail, and outlook work very well
    • When the code using nested table there is a few rules to follow, such as use inline css, nested tables, no divs, no background image ( is fine but not the background css and html selector)
    • So in your design, I can see the baby with the background images and text... propably will not work unless u export all in one picture.
    • It is important to note images will leave a white space between the two for hotmail user, so be sure to add to the css

    style = "" display: block; "." You can google for more info...

    • An other things is that you need to know how your customers send email Ferragamo, as the use of this software?... for outlook 2003 is more stable, outlook 2007 and especially will probably screw up your layout. If your client uses the third-party e-mail provider then it should be fine...

    and the list continues... I know html email is annoying

  • I can't move a table nested in CS4

    I use Dreamweaver CS4 and I'm trying to move a table nested, either by dragging or by using the arrows, but it does not move. It's very frustrating... Please help...? !

    Thanks in advance!

    Add the following links to your Favorites. You will refer to them often.

    HTML

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

    http://w3schools.com/html/default.asp

    http://www.HtmlDog.com/guides/

    http://www.htmlcodetutorial.com/

    http://alistapart.com/topics/code/

    CSS

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

    http://w3schools.com/CSS/default.asp

    http://www.Projectseven.com/Tutorials/index.htm

    http://www.westciv.com/

    http://www.TJKDesign.com/articles/one_html_markup_many_css_layouts.asp

    Web Design / Dreamweaver

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

    Community standards Web MX Lesson Plan series
    http://www.communitymx.com/abstract.cfm?cid=3D074

    Tables to CSS Web Design part 1-
    http://www.Adobe.com/devnet/Dreamweaver/articles/table_to_css_pt1.html

    Tables to CSS Web Design part 2-
    http://www.Adobe.com/devnet/Dreamweaver/articles/table_to_css_pt2.html

    Holding a model of fireworks to a CSS-based layout in DW
    http://www.Adobe.com/devnet/Fireworks/articles/web_standards_layouts_pt1.html

    Divisions of absolute positioning or DW 'Layers '.
    http://apptools.com/examples/pagelayout101.php http://apptools.com/examples/pagelayout101.php

    Nancy O.
    ALT-Web Design & Publishing
    Web | Graphics | Print | Media specialists
    www.Alt-Web.com/
    www.Twitter.com/ALTWEB
    www.Alt-Web.com/blogspot.com

  • On the Table nested

    Hi all

    Why the following SQLs are unable to work? He told me that:

    ERROR on line 1:
    ORA-02320: failure in the creation of the table of storage for the nested table column
    ACCESS_G
    ORA-22913: must specify the name of the table for the nested table column or attribute

    SQL:

    CREATE or REPLACE TYPE el_type () AS OBJECT
    ip_address VARCHAR2 (16));
    /

    CREATE or REPLACE TYPE el_tab_type AS TABLE OF THE el_type;
    /

    CREATE or REPLACE TYPE re_type () AS OBJECT
    re_name VARCHAR2 (16).
    el_g el_tab_type);
    /

    CREATE or REPLACE TYPE re_tab_type AS TABLE OF THE re_type;
    /

    CREATE TABLE actual_info)
    profile_name VARCHAR2 (16).
    access_g re_tab_type)
    TABLESPACE DBdata
    NESTED TABLE access_g STORE AS access_tab;
    /

    You have a table nested within a nested table, so you must specify the storage
    for both tables nested.
    Tom tells how do:
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:2969385152046

    URS

  • Using record type and Table and sorting out output

    I use a record type

    • TYPE results_rec is RECORD)
    • table_ varchar2 (40),
    • (1) tank Create_: = '-'.
    • (1) tank read_: = '-'.
    • Char (1) warning: = '-'.
    • Delete_ char (1): = '-');

    and a table of this record

    • Results_tab TYPE IS TABLE of results_rec INDEX OF VARCHAR2 (40);
    • tab_res results_tab;
    • table_indx varchar2 (40);

    And when I add values to this table, I do like that, for example, an entry of functioning drop in table:

    • v_check: = instr2 (v_string_fnc, 'DROP');
    • If v_check > 0 then
    • counter: = counter + 1;
    • delete_flag: = ';
    • v_check: = instr2 (v_string_fnc, 'TABLE', v_check);
    • v_check: = v_check + 6;
    • result_table: = substr (v_string_fnc, v_check);
    • rest_string: = result_table;
    • result_table: = substr (result_table, 0, instr (result_table, ' '));
    • result_table: = rtrim (result_table);
    • table_indx: = result_table;
    • tab_res (table_indx) .table_: = result_table;
    • tab_res (table_indx) .delete_: = delete_flag;

    and similar to all other interventions, but how to get while dbms_output.

    For table_indx in? and now, table_indx is a string value, how to get all the in the output, sorted by ASC .table_ tab_res (table_indx) string?

    Well, tab_res. FIRST returns the first index of tab_res which is a VARCHAR2, while an index of the loop is supposed to be a NUMBER.

    You cannot use FOR... LOOP element, you use WHILE... LOOP, for example

    SQL > SET SERVEROUTPUT ON;

    SQL > DECLARE

    2 TYPE Results_rec IS RECORD)

    3 table_ VARCHAR2 (40),

    4 create_ VARCHAR2 (1): = '-'.

    5 read_ VARCHAR2 (1): = '-'.

    6 warning VARCHAR2 (1): = '-'.

    7 delete_ VARCHAR2 (1): = '-');

    8

    9 results_tab TYPE IS an ARRAY OF results_rec

    10-VARCHAR2 INDEX (40);

    11

    12 results results_tab;

    13

    14 variable_name VARCHAR2 (40);

    BEGIN 15

    16 results ('name_a') .table_: = 'name_a ';

    17 results ('name_a') .create_: = 'x '.

    18

    19 results ("name_b') .table_: = 'name_b;

    20 results ("name_b') .update_: = 'x '.

    21

    22 results ("name_c") .table_: = "name_c";

    23 results ("name_c") .read_: = 'x '.

    24 results ("name_c") .delete_: = 'x '.

    25

    26 nom_de_variable: = results. FIRST;

    27

    28 variable_name IS NOT NULL LOOP

    29

    30 DBMS_OUTPUT. PUT_LINE)

    31 results (variable_name) .table_ | ' ' ||

    32 results (variable_name) .create_ |

    33 results (variable_name) .read_ |

    34 results (variable_name) .update_ |

    35 results (variable_name) .delete_);

    36

    nom_de_variable 37: = results. NEXT (variable_name);

    38 END LOOP;

    39 END;

    40.

    name_a x-

    name_b - x-

    name_c - x - x

    PL/SQL procedure successfully completed.

    SQL >

  • Reg: filtering table nested

    Hi Experts,

    I have a table_week, whose structure is:

    create table table_week)

    filter_no,

    d_mon char (1),

    d_tue char (1),

    d_wed char (1),

    d_thu char (1),

    d_fri char (1),

    d_sat char (1),

    d_sun char (1)

    );

    "For every FILTER_NO, it stores a 'Y' or ' n ', in the rest of the columns i.e. D_ * D_MON, D_TUE, etc.

    Now, I need to fill out another nested table that contains just a few days that were marked as 'Y '.

    Let's say, for FILTER_NO = 99, table record looks like: 99 O N O N O N N

    Output - A nested table whose value ('Monday', 'Wednesday', 'Friday')

    declare

    V_1 varchar2 (20);

    V_2 varchar2 (20);

    V_3 varchar2 (20);

    v_4 varchar2 (20);

    VARCHAR2 (20) v_5.

    v_6 varchar2 (20);

    v_7 varchar2 (20);

    type nt_type is table of the varchar2 (20);

    NT nt_type;

    NT1 nt_type: = nt_type();

    Start

    Select

    Decode (d_mon, 'Y', 'Monday', 'x'),

    Decode (d_tue, 'Y', 'Tuesday', 'x'),

    Decode (d_wed, 'Y', 'Wednesday', 'x'),

    Decode (d_thu, 'Y', 'Thursday', 'x'),

    Decode (d_fri, 'Y', 'Friday', 'x'),

    Decode (d_sat, 'Y', 'Saturday', 'x'),

    Decode (d_sun, 'Y', 'Sunday', 'x')

    in v_1, v_2, v_3, v_4, v_5, v_6, v_7

    of table_week

    where filter_no = 99; -/ / Some filter no.

    NT: = nt_type (v_1, v_2, v_3, v_4, v_5, v_6, v_7);

    because me in 1.nt.count

    loop


    . . .


    end loop;

    end;

    Thank you and best regards,

    -Nordine

    (on Oracle 11.2.0.4.0)

    SQL> declare
      2
      3    type    nt_type is table of varchar2(20);
      4    my_nt   nt_type;
      5
      6  begin
      7
      8    select day_name
      9    bulk collect into my_nt
     10    from table_week
     11         unpivot (
     12           day_flag for day_name in (
     13                          d_mon as 'Monday'
     14                        , d_tue as 'Tuesday'
     15                        , d_wed as 'Wednesday'
     16                        , d_thu as 'Thursday'
     17                        , d_fri as 'Friday'
     18                        , d_sat as 'Saturday'
     19                        , d_sun as 'Sunday'
     20                        )
     21         )
     22    where filter_no = 99
     23    and day_flag = 'Y';
     24
     25    for i in 1 .. my_nt.count loop
     26      dbms_output.put_line(my_nt(i));
     27    end loop;
     28
     29  end;
     30  /
    
    Monday
    Wednesday
    Friday
    
    PL/SQL procedure successfully completed.
    
  • Can I return a record/table of records of proceedings aside Java Server?

    I need to get data from a remote service during the execution of a PL/SQL procedure. The first of these calls returns a table, each entry that consists of a number of channels, but the second Gets a master-detail structure, a parent row, and an arbitrary number of records of invoice line.

    Just to make it interesting the PL/SQL must operate on an existing 8i database, which means that I have to encode any Java JDK 1.1.8 (which should be about 1990 vintage).

    The natural way to do this would be to code a java procedure that return an array of records. Unfortunately, I understand that you cannot return a record of PL/SQL returned by a call to jdbc, which suggests that there may be no class in Java or Jave to manage server-side. There is certainly no record type in oracle.sql. *;

    Is it possible to return a record or a table of records or as a return value or OUT of a java PL/SQL function procedure parameter and, if not, what is the best way to return data that can be structured in the PL/SQL code?

    Oracle 8i shouldn't be so bad - you should still have nested table types, and the ability to use a collection in a select... TABLE... MOUNT the statement and return a refcursor, for example - without doubt the best way to return a set of information from a java client.

    However, you can map collections of Oracle to Java arrays using oracle.sql.STRUCT, oracle.sql.ARRAY, oracle.sql.StructDescriptor and oracle.sql.ArrayDescriptor - are they available in the JDK?

    Oracle 8.1.7 documentation is always available online:
    http://Tahiti.Oracle.com/pls/Tahiti/Tahiti.homepage

    See also the Oracle8i - object-relational features applications developer's Guide
    http://download.Oracle.com/docs/CD/A87860_01/doc/AppDev.817/a76976/TOC.htm

    Published by: Dom Brooks on March 8, 2011 11:06

  • Cannot use tables nested in SQL

    Hi, just want to ask questions about the code below:
    SQL> declare
      2      type t_record is record( x number, z number );
      3      v_record t_record;
      4
      5      type t_col is table of t_record;
      6      v_col t_col := t_col();
      7      v_col2 t_col := t_col();
      8  begin
      9      v_record.x := 5;
     10      v_record.z := 6;
     11      v_col.extend;
     12      v_col( v_col.first ) := v_record;
     13
     14      -- returns error PLS-00425
     15      select level, level*2
     16      bulk collect into v_col2
     17      from dual
     18      connect by level <= v_col( v_col.first ).x;
     19  end;
     20  /
        connect by level <= v_col( v_col.first ).x;
                                   *
    ERROR at line 18:
    ORA-06550: line 18, column 32:
    PLS-00425: in SQL, function argument and return types must be SQL type
    ORA-06550: line 18, column 32:
    PLS-00425: in SQL, function argument and return types must be SQL type
    ORA-06550: line 18, column 25:
    PL/SQL: ORA-00904: : invalid identifier
    ORA-06550: line 15, column 5:
    PL/SQL: SQL Statement ignored
    I don't see any function. Oracle sees the nested in a function table?

    The call

    v_col (v_col.first) .x

    Returns a NUMBER - a right to SQL data type data type?

    Bug? Not supported? I'm doing it wrong? =)

    Thank you very much.

    Kind regards
    Rhani

    Published by: triple.r.kear on April 23, 2009 13:58

    Rhani,

    The types that you use are all types of PL/SQL. To be used in a SQL query, the type must be a SQL type. For example, you can declare an object type with the same definition of the level of sql. Then create the type of array.
    -----------------------------------------------------
    SQL > Create or replace type t_record as the object (x, z number);
    3 N

    Type of creation.

    SQL > Create or replace type t_col is table of the t_record;
    3 N

    Type of creation.

    SQL >
    ---------------------------------------------------
    Now, try to use them in the
    ---------------------------------------------------
    SQL > declare
    2 v_col t_col: = t_col();
    3 v_col2 t_col: = t_col();
    4 x number;
    Number 5 z;
    6 start
    7 x: = 5;
    8 z: = 6;
    9 v_col.extend;
    10 v_col (v_col.first): = t_record (x, z);
    11. Select t_record (level * 2)
    in bulk 12 gather in v_col2
    13 of the double
    14 connect by level<= v_col(="" v_col.first="">
    15 end;
    16.

    PL/SQL procedure successfully completed.

    SQL >

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

    Kind regards
    Dipankar.

  • a table column sorting

    When sorting by a column of table with the built-in context menu (CVI2010), I came across two issues, I do not understand:

    (1) I start with a table with a single line and other programmatically insert lines, in this case 2 more for a total of 3. I also checked using the GetCtrlAttribute (, ATTR_NUM_VISIBLE_ROWS,) which also results in three rows, see figure below.

    Interestingly, when you use the sorting, it shows a range of cells that extends up to 13... ?

    (2) by clicking on the OK button of yields the result shown in the figure below, i.e. three empty fields...?

    Thanks, Wolfgang

    .. .or simply go to the box to add, cut, paste, modify the line keys, type 1000 in the line number and press the Tab key: it will be converted to the last row number in the table.

  • Table 2d-sort of string

    Hello, please go easy on me since this is my first post here.  If I'm "hurting" Please let me know nicely.  I have the attached vi, for example from here.  If all goes well, you can see the picture I inserted, otherwise it's in attachments.

    My problem: I need to do to look like the example in table and table to place these data in the output array.  So far, it is that I can get.  Example of a table was analyzed using code 'C', and then was read using a CIN node.  We would like to replace all the code dll (CIN nodes) with labview code. I can arrange the columns later, I just need to know how I can get all the formulas that have been separated as in the example of table.  As you can see, I can get up to #7 line then can't bet line sorted #8.  I do necessarily, according to what I am looking for first of the chips.  I see what happens when I find the first token, then spend the rest of the chain, I am no longer in this column.  I can't place my finger on a path to achieve my goal.  Any suggestions?

    Thank you

    Sam

    I think that it is not possible, as in the code >, =, and< characters are="" being="" checked="" and="" separated="" from="" the="" string.="" but="" i="" have="" updated="" the="" code,="" with="" some="" workaround,="" which="" helps="" to="" escape="" from="" this="">

    I have replace <= and="">= with other characters, which are not used in expressions. You can replace them, if you think you will use them. After searching new characters, I replace their return.

    Thank you

    AREV

    CTO | RAFA solutions

Maybe you are looking for

  • The browser crashes when I try to print from a specific Web site

    When I try to print from a specific website on Mozilla Firefox, the browser crashes. Before that the settings of the printer had been reset to set a new default printer from the browser. I have reset the browser again, updated the browser, confirmed

  • Problem of Windows 7 on my Satellite C660-1F1

    Hello I have a kind of small software problem on my laptop. When I turned it on, it showed a message with options to launch repair system (recommended) or start windows normally. I chose the first option, as seems to be the recommended option and I t

  • HP 8610: Wireless keeps being settled WE

    I have a new printer 8610, and although I put Wireless OFF several times, it returns!  What causes this and how do I make sure the wireless setting is OFF?  The printer is connected by USB and he didn't need a Wi - Fi connection.   In addition, when

  • change usb micro wireless mouse 6000 defective

    My usb adapter as will separate and is unusable

  • Laptop will not turn off by itself

    I have a HP Pavilion 15 - e097sa that is currently running Windows 8.1. When using the battery, it is not usually turned off by itself. I have to press on and hold the power button until it turns off. When the power supply is connected, it shut down