Can you input records to a COLLECTION TYPE object and use it as a table??

My PL/SQL stored procedure creates a list of employee number and phone number records. I don't want to store them in a table. I will be passing this list from one procedure to another in my package.
I created the object type (record) and collection type (table) using this statements.
CREATE TYPE obj_emp_phone_rec AS OBJECT
     emp_number   NUMBER,
     emp_phone    VARCHAR2(100)
CREATE TYPE obj_emp_phone_recs_table AS TABLE OF obj_emp_phone_rec
/Thing is, can I use the obj_emp_phone_recs_table "table type" as a table?
I.e. can I insert records to this in the package procedure and pass reference to it in called sub-procedures.
i.e. something like this
PACKAGE BODY abc IS
  PROCEDURE kdkddk IS
  BEGIN
    -- Insert records to the  obj_emp_phone_recs_table
    obj_emp_phone_recs_table(1).emp_number := '1';
    obj_emp_phone_recs_table(1).emp_phone   := '0774949494';
    obj_emp_phone_recs_table(2).emp_number := '234';
    obj_emp_phone_recs_table(2).emp_phone   := '285494';
    -- Pass the table to the sub procedure
    xyx(obj_emp_phone_recs_table);
  END kdkddk;
END abc;If so how to insert to the obj_emp_phone_recs_table ???
Nothing on the net. In the Net I found only where u define a normal table's column as an object type and then inserting records to it.
Any help would be greatly appreciated.
Edited by: user12240205 on Oct 6, 2011 2:08 AM

mhouri > drop type obj_emp_phone_recs_table;
Type dropped.
mhouri > drop type obj_emp_phone_rec ;
Type dropped.
mhouri > CREATE TYPE obj_emp_phone_rec AS OBJECT
  2    (
  3       emp_number   NUMBER,
  4       emp_phone    VARCHAR2(100)
  5    )
  6  /
Type created.
mhouri > CREATE TYPE obj_emp_phone_recs_table AS TABLE OF obj_emp_phone_rec
  2  /
Type created.
mhouri > create or replace procedure p1(pin_tab IN obj_emp_phone_recs_table)
  2  is
  3   begin
  4     for j in 1..pin_tab.count
  5     loop
  6      dbms_output.put_line('record number '||j ||'-- emp number --'||pin_tab(j).emp_number);
  7     end loop;
  8 
  9  end p1;
10  /
Procedure created.
mhouri > create or replace procedure p2
  2  is
  3  lin_tab  obj_emp_phone_recs_table := obj_emp_phone_recs_table();
  4  begin
  5  FOR i IN 1 .. 5
  6     LOOP
  7        lin_tab.extend;
  8        lin_tab(i) := obj_emp_phone_rec(i, 'i-i-i');
  9     END LOOP;
10 
11    p1(lin_tab);
12 
13  end p2;
14  /
Procedure created.
mhouri > set serveroutput on
mhouri > exec p2
record number 1-- emp number -- 1                                                                                                                                                                                                                         
record number 2-- emp number --2                                                                                                                                                                                                                         
record number 3-- emp number --3                                                                                                                                                                                                                         
record number 4-- emp number --4                                                                                                                                                                                                                         
record number 5-- emp number --5                                                                                                                                                                                                                         
PL/SQL procedure successfully completed.Best Regards
Mohamed Houri

Similar Messages

  • Can you convert a Captivate HTM or SWF file and use it in a website?

    One of my clients wants to know if it's possible to use in a website content you've created in Captivate and save as an HTM or SWF file?

    You cannot access your iWork documents in the cloud through a folder structure as you can on your computer.
    You might want to approach your use of these documents in the cloud in a slightly different way. I tend to use iCloud for my documents "in progress", but once complete I then move them to my regular folder structure on my computer and out of the cloud. This means I have a minimum but relevant number of documents available to me when I open the appropriate app on my mobile device.

  • Can you select the max of a group by and mach it to another table?

    I can't get my little head around this one. I have 2 tables
    table 1:
    T1ID col1 col2 col3
    1 a t e
    2 g y a
    3 h r p
    4 f u w
    and table 2 that has many entries from table 1
    Table 2:
    T1ID ID col1
    1 3 Y
    1 2 M
    1 1 H
    3 2 W
    3 1 E
    I want the contents of table 1 with the value of col1 from table 2 where the ID is the highest?
    so returning table 3:
    ID col1 col2 col3 col1_from_table_3
    1 a t e Y
    2 g y a
    3 h r p W
    4 f u w
    is this easy to do with a select statment?
    Thanks for all of you help(in advance)
    LT

    SQL> create table t1 (t1id,col1,col2,col3)
      2  as
      3  select 1, 'a', 't', 'e' from dual union all
      4  select 2, 'g', 'y', 'a' from dual union all
      5  select 3, 'h', 'r', 'p' from dual union all
      6  select 4, 'f', 'u', 'w' from dual
      7  /
    Tabel is aangemaakt.
    SQL> create table t2 (t1id,id,col1)
      2  as
      3  select 1, 3, 'Y' from dual union all
      4  select 1, 2, 'M' from dual union all
      5  select 1, 1, 'H' from dual union all
      6  select 3, 2, 'W' from dual union all
      7  select 3, 1, 'E' from dual
      8  /
    Tabel is aangemaakt.
    SQL> select t1.t1id id
      2       , max(t1.col1) keep (dense_rank last order by t2.id) col1
      3       , max(t1.col2) keep (dense_rank last order by t2.id) col2
      4       , max(t1.col3) keep (dense_rank last order by t2.id) col3
      5       , max(t2.col1) keep (dense_rank last order by t2.id) col1_from_t2
      6    from t1
      7       , t2
      8   where t1.t1id = t2.t1id (+)
      9   group by t1.t1id
    10  /
       ID COL1  COL2  COL3  COL1_FROM_T2
        1 a     t     e     Y
        2 g     y     a
        3 h     r     p     W
        4 f     u     w
    4 rijen zijn geselecteerd.Regards,
    Rob.

  • When trying to watch a movie via apple tv how can you stop it having to download each time and using up all my internet data?

    I have bought movies from itunes and now they are on my computer why is it that each time I try to watch the movie it re downloads and uses up all my internet data? How do I prevent this and make it so it just plays from my stored version on my computer hard drive? Please help.

    Welcome to the Apple Community.
    Watch it from Computers > movies and not movies > purchased.

  • Can you purchase something from another countries itune store and use it on the US itunes?, if you have a US store account, can you purchase something from another countries itune store and use it on the US itunes?

    Would like purchase movies and some tv shows from another countries itunes store, but not sure if they will work on my US itunes account.
    Keith

    You cannot purchase from any other country's iTunes Store. The content owners will not allow cross-border sales.
    Regards.

  • Can you please record a video from a web cam with inital setting

    Can you please record a video from a web cam that has the
    following specs
    fps: 20
    bitrate: 1000
    Size: 500*400
    can we configure that in code or is it a webcam specs?

    QuickTime Player Pro can't record the screen.
    QuickTime X can record the screen (but only all of it and not just a window). It's a part of Snow Leopard.

  • Can you sort ibookshelf books by collections and list all of the books in each collection?

    can you sort ibookshelf books by collections and list all of the books in each collection?

    The collection changes a little by the criteria you use to view the books, and you can view them by Title, Author, and Category. So, yes, you can.
    The default view is Book view. On the upper right part of the page, you'll see four white blocks - that's the icon for book view. The icon on the right has three white lines; that's where you find Title, Author, and Category view. You can't create folders in any view.

  • Can you set recording time video in Ipad mini?

    When recording videos in my Ipad, they always stop after 2:30min. I wonder how to change the video recording time?

    From another user....
    Two paths -
    One - use an alternative recording app (eg FILMiC Pro) that allows you to record at a lower frame rate and/or smaller image size. (Don't know if it supports iPad 2 on iOS4)
    Two - get an iPad with a larger storage capacity. If you need more space than what a 64GB model gives you, combine it with option 1. (FILMiC Pro is supported on an iPad3 running iOS 6)

  • How can I input read a line from a file and output it into the screen?

    How can I input read a line from a file and output it into the screen?
    If I have a file contains html code and I only want the URL, for example, www24.brinkster.com how can I read that into the buffer and write the output into the screen that using Java?
    Any help will be appreciate!
    ======START FILE default.html ========
    <html>
    <body>
    <br><br>
    <center>
    <font size=4 face=arial color=#336699>
    <b>Welcome to a DerekTran's Website!</b><br>
    Underconstructions.... <br>
    </font> </center>
    <font size=3 face=arial color=black> <br>
    Hello,<br>
    <br>
    I've been using the PWS to run the website on NT workstation 4.0. It was working
    fine. <br>
    The URL should be as below: <br>
    http://127.0.0.1/index.htm or http://localhost/index.htm
    <p>And suddently, it stops working, it can't find the connection. I tried to figure
    out what's going on, but still <font color="#FF0000">NO CLUES</font>. Does anyone
    know what's going on? Please see the link for more.... I believe that I setup
    everything correctly and the bugs still flying in the server.... <br>
    Thank you for your help.</P>
    </font>
    <p><font size=3 face=arial color=black>PeerWebServer.doc
    <br>
    <p><font size=3 face=arial color=black>CannotFindServer.doc
    <br>
    <p><font size=3 face=arial color=black>HOSTS file is not found
    <br>
    <p><font size=3 face=arial color=black>LMHOSTS file
    <br>
    <p><font size=3 face=arial color=black>How to Setup PWS on NT
    <BR>
    <p><font size=3 face=arial color=black>Issdmin doc</BR>
    Please be patient while the document is download....</font>
    <font size=3 face=arial color=black><br>If you have any ideas please drop me a
    few words at [email protected] </font><br>
    <br>
    <br>
    </p>
    <p><!--#include file="Hits.asp"--> </p>
    </body>
    </html>
    ========= END OF FILE ===============

    Hi!
    This is a possible solution to your problem.
    import java.io.*;
    class AddressExtractor {
         public static void main(String args[]) throws IOException{
              //retrieve the commandline parameters
              String fileName = "default.html";
              if (args.length != 0)      fileName =args[0];
               else {
                   System.out.println("Usage : java AddressExtractor <htmlfile>");
                   System.exit(0);
              BufferedReader in = new BufferedReader(new FileReader(new File(fileName)));
              StreamTokenizer st = new StreamTokenizer(in);
              st.lowerCaseMode(true);
              st.wordChars('/','/'); //include '/' chars as part of token
              st.wordChars(':',':'); //include ':' chars as part of token
              st.quoteChar('\"'); //set the " quote char
              int i;
              while (st.ttype != StreamTokenizer.TT_EOF) {
                   i = st.nextToken();
                   if (st.ttype == StreamTokenizer.TT_WORD) {          
                        if (st.sval.equals("href")) {               
                             i = st.nextToken(); //the next token (assumed) is the  '=' sign
                             i = st.nextToken(); //then after it is the href value.               
                             getURL(st.sval); //retrieve address
              in.close();
         static void getURL(String s) {     
              //Check string if it has http:// and truncate if it does
              if (s.indexOf("http://") >  -1) {
                   s = s.substring(s.indexOf("http://") + 7, s.length());
              //check if not mailto: do not print otherwise
              if (s.indexOf("mailto:") != -1) return;
              //printout anything after http:// and the next '/'
              //if no '/' then print all
                   if (s.indexOf('/') > -1) {
                        System.out.println(s.substring(0, s.indexOf('/')));
                   } else System.out.println(s);
    }Hope this helps. I used static methods instead of encapsulating everyting into a class.

  • I am trying to use siri. It was working earlier. Now when I ask it to call name and number it say, Siri keeps saying( SORRY SOMETHINGS GONE WRONG CAN YOU TRY AGAIN) I HAVE TRIED SEVERAL NAMES AND NUMBERS IN MY CONTACTS.   What am I doing wrong or how can

    I am trying to use siri, Siri keeps saying( SORRY SOMETHINGS GONE WRONG CAN YOU TRY AGAIN)
    I HAVE TRIED SEVERAL NAMES AND NUMBERS IN MY CONTACTS.
    What am I doing wrong or how can I correct it.

    Siri Fix
    Turn OFF Siri
    Reset Network Settings
    Turn ON Siri
    Done
    Steps:
    Tap Settings App>General>Siri>Turn OFF
    General>Reset, near bottom>Reset Network Settings
    Tap Settings App>General>Siri>Turn ON
    Done

  • Can you sync two 4S iPhones to one PC and iTunes account?

    Can you sync two 4S iPhones to one PC and iTunes account?

    No you don't. You log into iTunes with your Apple ID but you can use one Apple ID for iTunes and a different Apple ID for iCloud. On your device go:
    Settings > iCloud > Delete Account and sign in with a new Apple ID
    This will only change the Apple ID for iCloud and both devices will continue to download apps and backup to the shared iTunes account.

  • Can you have two seperate acounts on one MAC and if so how do you do it?

    Can you have two seperate acounts on one MAC and if so how do you do it?

    Look at Method One in this document:  How to use multiple iPods, iPads, or iPhones with one computer, http://support.apple.com/kb/HT1495

  • In iMovie 11, how can you cut/paste a clip that has subtitles and actually have the subtitles get cut/pasted. When I try, the subtitles disappear into the void and I have to do the subtitling all over again.

    In iMovie 11, how can you cut/paste a clip that has subtitles and actually have the subtitles get cut/pasted. When I try, the subtitles disappear into the void and I have to do the subtitling all over again.

    If you think this is a bug, you can report it here:
    Apple - Mac OS X - Feedback

  • How can you make your persona show on the top and bottom? Also can you make it bigger at the top to show more of the picture?

    How can you make your persona show on the top and bottom?
    Also can you make it bigger at the top to show more of the picture?

    Add extra empty toolbars if you want to see more of the persona.<br />
    You can create extra toolbars to get extra space via View > Toolbars > Customize<br />
    You have to put something on a toolbar (drag a Space item onto it) before closing the Customize window because empty toolbars are automatically removed.<br />
    See http://kb.mozillazine.org/Toolbar_customization

  • How can you change the font size in the application and system headers?

    How can you change the font size in the application and system headers?  I searched the system and finder prefs to no avail.  Changing the screen density is not a good option.
    Thanks

    I downloaded Tinkertool.  Found the font section and increased the size of most selections.  The only thing that changed that I can see is the window label.  The apple line, bookmarks line, the tool bar in safari are all the same---font size of about 4.  Found the finder "show view options" but that didn't seem to change anything either.  I'll keep working.  Restarted all apps after changes as well.

Maybe you are looking for

  • How to execute a script(.sql) file from a PL\SQL procedure

    I would like to know how to execute a .sql file from a stored procedure and the result of it should update a table. My .sql file contains select statements.

  • ORA-22275: invalid LOB locator specified

    Hello, I use Oracle 11.2.0.3. APEX 4.2.2... Listener 2.0.3 .... Glassfish server 4.0. When I run this procedure ( that is used in this tutorial ) I get ORA-22275: invalid LOB locator specified. The error persists over Glass fish 3.0.2, Listener 2.0.1

  • What is best zip app for mac osx 10.9

    I would like to download a good zip/unzip app on my Mac Pro cpu which should I choose?

  • Why does query do a full table scan?

    I have a simple select query that filters on the last 10 or 11 days of data from a table. In the first case it executes in 1 second. In the second case it is taking 15+ minutes and still not done. I can tell that the second query (11 days) is doing a

  • HOW TO DELETE datafiles of the droped database in asm disgroup

    Hi, I have a issue with ASM diskgroup. I have dropped the database without droping the asm files in diskgroup hopw could i remove those files Please help me on this its very very help fulll..