How to write a procedure to recover data in a collection of a table?

create or replace type of subject as object)
number of subject_id,
subject_Desc varchar2 (50)
)
/


create or replace type Subjects_All in the varray (10) of the subject
/


create table (student)
StudentID varchar (10),
Subjects_all topics
);


so, how can I write a procedure to display information like this:


Topics:
101 "Mathematics".
102 'science '.

Topics:
...


I've written a procedure similar to the following, but it didn't work enough :(

CREATE OR REPLACE PROCEDURE StudentLoop AS
all_subj subjects_all;
subject to each_subj;
CURSOR all_subjectsrow IS select * from the student;
BEGIN
FOR all_subj IN all_subjectsrow LOOP
FOR each_subj IN all_subj LOOP
DBMS_OUTPUT. Put_line ('last selected line a ID' | each_subj.subject_id | each_subj.subject_desc);
END LOOP;
END LOOP;
END StudentLoop;


Any advice?

Well, it would help if you post the code that produces this result. I'm suspecting try you at the exit of the integer type and not it's content:

SQL> insert into student(studentid, subjects) values (1, subjects_all(subject(1, 'MATH'), subject(2, 'SCIENCE')));

1 row created.

SQL> select * from student;

STUDENTID |SUBJECTS(SUBJECT_ID, SUBJECT_DESC)
----------|-----------------------------------------------------------------------------------------------------------------------------------
1         |SUBJECTS_ALL(SUBJECT(1, 'MATH'), SUBJECT(2, 'SCIENCE'))

SQL> declare
  2  cursor all_subjectsrow is select * from student;
  3  begin
  4  for rStudent in all_subjectsrow loop
  5    for i in 1..rStudent.subjects.count loop
  6      dbms_output.put_line(rStudent.subjects(i).subject_id||' '||rStudent.subjects(i).subject_desc);
  7    end loop;
  8  end loop;
  9  end;
 10  /
1 MATH
2 SCIENCE

PL/SQL procedure successfully completed.

see you soon

Tags: Oracle Development

Similar Questions

  • How to write a procedure to call and run the custom package backend

    Hi all

    Oracle 10g
    Oracle Apps R12

    I work with here oracle order management, we have a package called (Pick Release) to customize. Due to a problem, we have this concurrent program execution manually giving Route_id as parameter. The route_id comes from the road to the Table. By using this query

    Select distinct route@DB_LINK_APPS_TO_ROADSHOW route_id
    When trunc (route_date) = trunc (sysdate + 2).

    on a daily basis, we have almost 42 routes and we run this simultaneous program manually close times.

    so now how to write a procedure for this

    Step 1 make the route to the routing table. (By cursor we can get the route_id accordingly)

    Step 2 How to trigger custom backend package and run accordingly to this output of the cursor (route_id)

    If 40 routes of cursor get is - that the simultaneous program runs 40 times according to this route_id.


    can some could provide the steps to do this


    Thanks and greetings

    Srikkanth.M

    To submit a competing request from the back - end:

    FND_REQUEST. SUBMIT_REQUEST (Client or server)

    Summary

    function FND_REQUEST. SUBMIT_REQUEST

    (application IN varchar2 default NULL,

    program IN varchar2 NULL by default,

    Description IN varchar2 default NULL,

    start_time IN varchar2 default NULL,

    sub_request IN default boolean FALSE

    Argument1,

    argument2,..., argument99.

    Return to argument100 number);

    Description

    Submits a competing treatment by a simultaneous Manager. If the query is successful, this function returns the ID of the concurrent request; Otherwise, it returns 0.

    ATTENTION: FND_REQUEST needs to know information about the user and accountability whose application is submitted. Therefore, this feature works of concurrent programs or forms within the Oracle Applications.

    The FND_REQUEST. SUBMIT_REQUEST function returns the ID of the concurrent application after successfully. It is up to the caller to issue a commit to complete the application.

    Your code should retrieve and handle the error message generated if there is a problem of presentation (the ID of the concurrent request returned is 0). Use FND_MESSAGE. RETRIEVE and FND_MESSAGE. ERROR to retrieve and display the error (if the application is made on the client side).

    Related essays: overview of the Message dictionary (see page)

    You must call FND_REQUEST. SET_MODE before calling FND_REQUEST. SUBMIT_REQUEST of a database trigger.

    If FND_REQUEST. SUBMIT_REQUEST fails to go anywhere but a database trigger, database changes are cancelled until the time of the function call.

    After a call to the FND_REQUEST. SUBMIT_REQUEST function, installation of all parameters are reset to their default values.

    Arguments (input)

    short name of the application associated with the concurrent request for enforcement.
    short simultaneous program (not the executable) name of the program for which the application must be made.
    Description Description of the application that appears in the form of concurrent requests (optional).
    start_time time during which demand is expected to start running in the (optional) HH24 or HH24:MI:SS format.
    sub_request set to TRUE if the request is made by another application and should be treated as a subquery.
    From version 11, this parameter can be used if you submit requests for in a concurrent program of PL/SQL stored procedure.
    argument1... 100 arguments for the concurrent request; up to 100 arguments are allowed. If the Oracle Forms submitted, you must specify all arguments of 100.

  • How to write a query for the data exchange between two columns?

    How to write a query for the data exchange between two columns?

    I tried a request, does NOT work.
    update tmp t1 set t1.m1=t1.m2 and t1.m2=(select t2.m1 from tmp t2 where t2.student_id = t1.student_id)
    Thank you.

    Published by: user533361 on October 23, 2009 14:04

    Just plain and simple:

    update tmp t1
     set t1.m1=t1.m2,
         t1.m2=t1.m1
    /
    

    SY.

  • How to clear the old cumulative game data in the collection of solitaire Microsoft - Windows 8

    How to clear the old cumulative game data in the collection of solitaire weird... is to say total games, victories, % etc...

    Hello

    Microsoft Solitaire Collection is a combination of card games and he has not a good reset option for all games.

    Some games have the New Deal option when you right click to start a new game.

    However, on some games have the ability to reset the cumulative Scores. Follow the instructions and check if this.

    (a) click here to open the game.

    (b) press on Windows key + C.

    (c) click settings.

    (d) click on Game Options.

    (e) whether specific game and click reset a cumulative Score .

    Let us know the status of the issue. If you need help, please after return. We will be happy to help you.

  • How to run a procedure with parameters in pl/sql collections?

    I created a procedure with parameter from the collection. Can somone help me how to run a procedure in passing the parameters in the collection.
    Package and how to create is successful. But I get the error message when executing the procedure.

    ORA-06550: line 3, column 19:
    PLS-00222: no function with name 'T_TAB' does exist in this scope

    I gave the example of code here. Can someone please help me solve this problem.

    -Spec package

    create or replace package pkg_dist is

    TABLE index IS THE NUMBER of t_tab_num TYPE of PLS_INTEGER;


    procedure prc_test (a t_tab_num IN,
    b IN t_tab_num,
    c IN OUT t_tab_num);
    end pkg_dist;

    -Package body

    create or replace package body is pkg_dist

    procedure prc_test (a t_tab_num IN,
    b IN t_tab_num,
    c IN OUT t_tab_num) is


    Start


    IF (a (16) = 0) then
    (16) c: = 0;
    c (17): = 0;
    c (18): = 0;
    end if;
    c (15): = (14)-(15)-a (16);
    (16) c: = b (16) /b (17);
    c (17): = 50;
    (18) c: = a (16) * 2;

    end prc_test;
    end pkg_dist;

    -executeing procedure

    declare
    TABLE index IS THE NUMBER of t_tab TYPE of PLS_INTEGER;
    x t_tab: = t_tab (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
    y t_tab: = t_tab (0,10,15,20,25,30,35,40,45,50,60,75,100,125,150,200,250,500);
    z t_tab;
    BEGIN
    pkg_dist.prc_test (x, y, z);
    dbms_output.put_line (z (18));
    END;

    Error:
    --------------------------------------------------------------------------------
    ORA-06550: line 3, column 19:
    PLS-00222: no function with name 'T_TAB' does exist in this scope

    My suggestion would be:

    CREATE OR REPLACE PACKAGE pkg_dist IS
    
       PROCEDURE prc_test (a IN SYS.odcinumberlist, b IN SYS.odcinumberlist, c IN OUT SYS.odcinumberlist);
    END pkg_dist;
    
    CREATE OR REPLACE PACKAGE BODY pkg_dist IS
       PROCEDURE prc_test (a IN SYS.odcinumberlist, b IN SYS.odcinumberlist, c IN OUT SYS.odcinumberlist) IS
       BEGIN
          IF (a (16) = 0) THEN
             c (16) := 0;
             c (17) := 0;
             c (18) := 0;
          END IF;
    
          c (15) := a (14) + a (15) + a (16);
          c (16) := b (16) / b (17);
          c (17) := 50;
          c (18) := a (16) * 2;
       END prc_test;
    END pkg_dist;
    /
    
    DECLARE
       x   SYS.odcinumberlist;
       y   SYS.odcinumberlist;
       z   SYS.odcinumberlist;
    BEGIN
       x := sys.odcinumberlist (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
       y := sys.odcinumberlist (0,10,15,20,25,30,35,40,45,50,60,75,100,125,150,200,250,500);
       z := sys.odcinumberlist (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
       pkg_dist.prc_test (x, y, z);
       DBMS_OUTPUT.put_line (z (18));
    END;
    /
    

    See you soon,.
    Manik.

  • How to write a procedure using collections

    How can we define the collections inside the procedure and use it

    I get an error of execution of this proc
    create or replace procedure p_collections
    
    is
    
    type calendar is varray(366) of  date;
    calendar c1;
    
    
    begin
    
    
    for i in 1 .. 100
    loop
    
    select sysdate bulk collect into c1 from dual;
    
    
    end loop;
    DBMS_OUTPUT.PUT_LINE(c1);
    
    end;
    Published by: Rahul_India on Sep 12, 2012 14:54

    Published by: Rahul_India on Sep 12, 2012 15:07

    Hello

    Rahul_India wrote:
    I found the error

    it should be
    c1 calendar;
    

    How can I print the values of 100 dates stored in the varray

    If you had 100 DATEs stored in the array, we can say:

    ... FOR  i  IN  1 .. 100
        LOOP
            dbms_output.put_line (c1 (i));
        END LOOP;
    

    Since you have only 1, which will trigger an error.

    You might be better to use the attributes of the FIRST and the LAST:

    ... FOR  i  IN  c1.FIRST .. c1.LAST
        LOOP
            dbms_output.put_line (c1 (i));
        END LOOP;
    
  • How to write a procedure?

    Hi all

    I am using oracle 11g,

    I have the table as

    EmpID, ename

    1           x

    2         Y

    3         Z

    4         M

    5          N

    6         P

    7         Q

    8          R

    I need a procedure if I pass any column in the procedure, then it should should show all data for a particular column

    as if I spend empid, it should show all emp_id

    Concerning

    Dale

    SQL > create or replace procedure test_proc (p_col_name in varchar2,

    res 2 the sys_refcursor)

    3 is

    4 start

    5. open to

    6 ' select '. p_col_name | "" employee ";

    7 end;

    8.

    Created procedure.

    PL/SQL procedure successfully completed.

    SQL > var res refcursor

    SQL > start

    2 test_proc ('employe_id',: res);

    3 end;

    4.

    PL/SQL procedure successfully completed.

    SQL > print;

    EMPLOYEE_ID

    -----------

    100

    101

    102

    103

    104

    105

    106

    107...

    Hello

    Above code will be useful

    913349 wrote:

    I need a procedure if I pass any column in the procedure, then it should should show all data for a particular column

    as if I spend empid, it should show all emp_id

    Concerning

    Dale

    See you soon,.

    Suri ;-)

    Post edited by: Suri
    Misunderstood the requirement. Now, I fixed it

  • Procedure for recovering data after the lost startup disk

    I just lost my boot drive 2 OCZ 80 gig vertex. The pixelated screen and went to black. I tried to restart without result. I used my system drive to start in revover5y mode. Using the command prompt I could not recognize the boot drive (drive C)

    I dig my OEM drive and is my sticker with the kay. Then, I went out and bought a new Samsung 850 pro (128 GB).  I thought I have to load windows on the new C and go on my different readers of data cleaning. I am a heavy user of photoshop and lightroom and I luckily my backups photo on WD hards, including hd 2 backup (no SSD)

    I built my own computers since the middle of the 1980s, but at 70 I've gotten a little rusty. I am also on some bad drugs that create some short-term memory problems.  I am accepting the unfortunate change of circumstance and I realize it's better to think I could handle everything smoothly. I've never had to reauthorize a boot disc in ofr all these years so I'm a little worried by Microsoft that addresses... This construction was 64 bit win 7 with 12 GB of ram a bunch a ssd 240 GB for ongoing work and a 60 GB SSD as frayed drive 80 GB, and hides.

    I have a 1 to black for data and I also loaded programs essential speed not on my boot drive was loading a touch too fast. I have 2 1 TB backup in ra 4 Bay unit removable unit. Computers can be fun but it's rough having to be an expert every 3 or 4 years.

    I don't know where I have it loaded some of my criticisms (MScontin will do that) programs may be on the C or the 240 GB SSD which still lives. I'm better off which separates data and do a cleanh installation of all programs (photoshop, lightroom and a few other photographic utilities). I have my photo files saved in triplicate, with the exception of my l; AST 2 outputs.  Wise data I should be fine.

    Thanks in advance for your suggestions. I want tro requirments rebuild the wi8th of Microsoft computing for a re authorization in mind. Also I'm not sure if I need to delete all data and reformat disks that have any executable.

    Critical element in terms of licenses is the motherboard, if you change this, then you do not have the right to be re - authenticate the license.

    The other setting used to be cumulative and it was not always clear when the licenses would fail. However, by this time the rule on the motherboard was not clearly defined so now we have this stated limitation then although other changes trigger a new authentication you will be able to do.

    The fact that the exchange of the card has not solved the problem of network would indicate that it is not material. Yes serving drivers can be less easy, but it is more likely to have problems of Protocol if anything. The 32/64 bit point is irrelevant.

    And Yes, I would like to start a new thread to allow the network to identify the issue of the guru.

  • How to write a query for this data?

    In this table, I dob column that is of type DATE, for example, 12 January 89 I want output like this

    Day of the year

    January 12, 89 Thusrs_day

    January 12, 90 Friday

    up to

    12 January 14 Sunday

    Select add_months (d, ((level*12)-12)), to_char (add_months (d, ((level*12)-12)), 'DY')

    de)

    Select d double to_date('12-jan-89','dd-mon-rr')

    )

    connect by level<=>

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

    12.01.1989 GAME

    12.01.1990 FRI

    12.01.1991 SAT

    12.01.1992 SUN

    12.01.1993 MAR

    12.01.1994 SEA

    12.01.1995 GAME

    12.01.1996 FRI

    12.01.1997 SUN

    12.01.1998 LUN

    MAR 12.01.1999

    12.01.2000 SEA

    12.01.2001 FRI

    12.01.2002 SAM

    12.01.2003 SUN

    12.01.2004 LUN

    12.01.2005 WED

    12.01.2006 GAME

    12.01.2007 FRI

    SAM 12.01.2008

    12.01.2009 LUN

    12.01.2010 MAR

    12.01.2011 WED

    12.01.2012 GAME

    24 selected lines

    ----

    Ramin Hashimzade

  • How to write a procedure for setting Out when the condition fails

    Here's my query, it works very well when the condition is fulfilled with the valid user ID and password

    create or replace
    PROCEDURE ISVALIDUSER / * this is procedure created to validate the connection information to users created on 09212012 by Charbonneau * /.
    (
    pUSERID IN VARCHAR2,
    Ppassword IN VARCHAR2,
    pUSERTYPE OUT NUMBER
    )
    AS
    tmpUSERID VARCHAR2 (30);
    tmpPASSWORD VARCHAR2 (150);
    tmpIsative VARCHAR2 (10);
    BEGIN
    SELECT Userid, PASSWORD IN tmpUSERID, tmpPASSWORD FROM USERMASTER WHERE USERMASTER. USERID = pUSERID and USERMASTER. PASSWORD = Ppassword AND isactive = "Y";
    / * Check ID USER Existed or not * / / * PASSWORD verification is Existed or not * /.
    IF tmpPASSWORD = AND tmpuserid = pUSERID THEN pPassword
    USERTYPE of SELECT INTO pUSERTYPE FROM USERMASTER WHERE USERMASTER. USERID = pUSERID and USERMASTER. PASSWORD = pPassword;
    ON THE OTHER
    BEGIN
    1 SELECT INTO pUSERTYPE FROM DUAL;
    END;
    END IF;
    END;


    Here I am facing a problem when I get invalid user or password ID it is failed - 1 in pUSERTYPE which is OUT setting
    Please suggest

    You need to read about the exceptions - {message identifier: = 9360013}

    create or replace
    PROCEDURE ISVALIDUSER /*This is Procedure created to validate Login users information Created on 09212012 by Chakravarthy*/
    (
    pUSERID IN VARCHAR2,
    pPASSWORD IN VARCHAR2,
    pUSERTYPE OUT NUMBER
    )
    AS
         tmpIsative VARCHAR2(10);
    BEGIN
         SELECT USERTYPE INTO pUSERTYPE
         FROM USERMASTER WHERE USERMASTER.USERID=pUSERID
         and USERMASTER.PASSWORD=pPASSWORD AND isactive='Y';
    exception
         when no_data_found then
              pUSERTYPE := -1;
    END;
    

    You store your password without encrypting? One who is to have access to your table will see the password...

  • How 2 call a procedure with the data type for the parameter Ftree.NODE

    Hello

    in this link
    http://Andreas.Weiden.ORCL.over-blog.de/article-29307730.html


    Down in the page after you run the package, I created the procedure and it compiled successfully but when call PR_WTNS in trigger WHEN-TREE-NŒUD-SELECTED

    PROCEDURE PR_WTNE (i_ndNode IN Ftree.NODE);

    as

    PR_WTNE (i_ndNode Ftree.NODE);


    I got the error message; A wrong number or types of argument in the call

    pls I'm stuck can help any one?


    Kind regards

    Abdetu...

    Published by: Abdetu on October 24, 2010 02:36

    Published by: Abdetu on October 24, 2010 02:36

    YKou have to give a variable of type Ftree.NODE when calling this function. If called fromm a WHEN-TREE-NODE-SELECTED-trigger, use: SYSTEM. TRIGGER_NODE

  • How to write the trigger for update or delete multiple columns in a table?

    Hello

    I create one in the form of table of sample_emp. In that, every time I want to change of name, team_id, team_leader_id, supervisor_id, manager_id it must store the update-able and old values of those in the job_history table. When I write the trigger for which it shows "ORA-04082 new or the old value not table level triggers. Here is my emp_table. My table also similar job_history like this. Need your help.

    Header 1 Header 2 Header 3 Header 4 Header 5 Heading 6 Heading 7 8 header Header 9
    EMP_IDEMP_NAMEDESIGNATIONTEAM_IDTEAM_LEADER_IDEMPLOYEEMANAGER_IDHIRE_DATERELIEVED_DATE

    --

    Thank you.

    Hi Joel,.

    Venky_prs wrote:

    Hello

    I create one in the form of table of sample_emp. In that, every time I want to change of name, team_id, team_leader_id, supervisor_id, manager_id it must store the update-able and old values of those in the job_history table. When I write the trigger for which it shows "ORA-04082 new or the old value not table level triggers. Here is my emp_table. My table also similar job_history like this. Need your help.

    Header 1 Header 2 Header 3 Header 4 Header 5 Heading 6 Heading 7 8 header Header 9
    EMP_ID EMP_NAME DESIGNATION TEAM_ID TEAM_LEADER_ID EMPLOYEE MANAGER_ID HIRE_DATE RELIEVED_DATE

    --

    Thank you.

    You can try something like this given below to complete the historical table on update and delete.

    create or replace TRIGGER  "CLONE_EMP_UPDATE_DELETE"
    BEFORE DELETE OR UPDATE ON EMP
    FOR EACH ROW
    DECLARE
        PRAGMA autonomous_transaction;
    BEGIN
    INSERT INTO JOB_HISTORY("EMP_ID","EMP_NAME","DESIGNATION","TEAM_ID","TEAM_LEADER_ID","SUPERVISOR_ID","MANAGER_ID"
    ,"HIRE_DATE","RELIEVED_DATE")
      VALUES(:OLD.EMP_ID,:OLD.EMP_NAME,:OLD.DESIGNATION,:OLD.TEAM_ID,:OLD.TEAM_LEADER_ID,:OLD.SUPERVISOR_ID,
    :OLD.MANAGER_ID,:OLD.HIRE_DATE,
    :OLD.RELIEVED_DATE);
    COMMIT;
    END;
    

    Hope this helps you,

    Kind regards

    Jitendra

  • How to write Modbus data in a file or a matrix?

    Hello:

    I can monitor my data through RS-485 port using 'Master Series MB query', and successfully, I can show signals using the waveform.

    But I can't save the data during the test in a table or write to a file. (see attachment and picture)

    How can I write them to a file or a spreadsheet correctly?

    When I try to read 'file as' and this graph, I can not every graph, there simply a knot!

    is the data type "registers entry" needs a special procedure?

    What is the problem?

    Thank you.

    A fundamental flaw that I see is that you have to write file as configured to rename and replace any existing file when you call the function.

  • How to write data in mode intertwined with TDMS C DLL 2.0?

    Hello

    How to write data in mode intertwined with TDMS C DLL 2.0?

    I use DAQmx features in Visual Studio C++ without Measurment Studio.

    This function returns the data in interlaced mode.

    How can I configure the functions of DLL C TDMS to store this data in the tdms files?

    I see that it is not possible with the PDM version 2.0 with 1.0.

    Thank you

    -TDM C Dll is not able to do

    -TDM header writer may be usable for this but is not able to be used for tdms files.

  • How to recover data images and videos

    How to recover data images and videos of empty Recycle Bin.

    Hello

    Have you looked in the trash?

    Recover files from the Recycle Bin - Vista
    http://Windows.Microsoft.com/en-us/Windows-Vista/recover-files-from-the-Recycle-Bin

    Recover files from the Recycle Bin - Windows 7
    http://Windows.Microsoft.com/en-us/Windows7/recover-files-from-the-Recycle-Bin

    How to restore previous Versions of a file and the folder of Vista (Ultimate, Business and Enterprise)
    http://www.Vistax64.com/tutorials/122127-previous-versions-shadow-copy.html

    How to restore files and folders in Windows 7 with previous Versions
    http://www.SevenForums.com/tutorials/85679-previous-versions-restore-files-folders.html

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

    This could help you recover a file, or a previous version (all versions of Vista and Windows 7).
    http://www.ShadowExplorer.com/

    ShadowExplorer - recover lost files and folders (Vista and Windows 7)
    http://www.SevenForums.com/tutorials/132087-ShadowExplorer-recover-lost-files-folders.html

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

    Recuva - free - recovers files deleted from your Windows computer, Recycle Bin,
    map of the camera digital or MP3 player. And it's free!
    http://www.Piriform.com/Recuva

    Recuva - Forums - help here
    http://Forum.Piriform.com/

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle=""><- mark="" twain="" said="" it="">

Maybe you are looking for