Can I select element number from table collection expression?

Hi, I know I can use COLUMN_VALUE to select column values from table collection expression. Is there any way to select the number of the element as well? (with Oracle 11.2.0.1.0)
CREATE OR REPLACE TYPE plch_numbers_nt IS TABLE OF NUMBER;
DECLARE
   l_numbers   plch_numbers_nt
                  := plch_numbers_nt (10,
                                      20,
                                      30,
                                      40,
                                      50);
BEGIN
   -- This would be nice...
   FOR rec IN (SELECT COLUMN_VALUE, VALUE_INDEX FROM TABLE (l_numbers))
   LOOP
      DBMS_OUTPUT.put_line (rec.COLUMN_VALUE, rec.VALUE_INDEX);
   END LOOP;
END;
/

First of all, I would like to thank you all for your replies. I really appreciate your help.
The problem I'm trying to solve is more complicated than what I have shown so far. Right now I'm trying to decompose the problem into smaller problems. Maybe I should show you the full problem and hope that I still get a reply.
I have a spatial column with collections of geometries (SDO_GTYPE 2004) and I have a VARRAY column of objects. For each row, each geometry in the geometry collection has some information in one element in the VARRAY. So I have this table
-- +----+------------------+-----------------------------------------------------------------------------------+
-- | ID | GEOM_COLL        | GEO_INFO                                                                          |
-- +----+------------------+-----------------------------------------------------------------------------------+
-- | 98 | sdo_geom(2004)_1 | ((geo_info_1_1_1; geo_info_2_1_1; ...);(geo_info_1_1_2; geo_info_2_1_2; ...) ...) |
-- +----+------------------+-----------------------------------------------------------------------------------+
-- | 99 | sdo_geom(2004)_2 | ((geo_info_1_2_1; geo_info_2_2_1; ...);(geo_info_1_2_2; geo_info_2_2_2; ...) ...) |
-- +----+------------------+-----------------------------------------------------------------------------------+
--  ...and I need this
-- +----+--------------------+----------------+----------------+-----+
-- | ID | SDO_GEOM           | GEO_INFO_1     | GEO_INFO_2     | ... |
-- +----+--------------------+----------------+----------------+-----+
-- | 98 | sdo_geom(2001)_1_1 | geo_info_1_1_1 | geo_info_2_1_1 | ... |
-- +----+--------------------+----------------+----------------+-----+
-- | 98 | sdo_geom(2002)_1_2 | geo_info_1_1_2 | geo_info_2_1_2 | ... |
-- +----+--------------------+----------------+----------------+-----+
-- +----+--------------------+----------------+----------------+-----+
-- | 99 | sdo_geom(2002)_2_1 | geo_info_1_2_1 | geo_info_2_2_1 | ... |
-- +----+--------------------+----------------+----------------+-----+
-- | 99 | sdo_geom(2001)_2_2 | geo_info_1_2_2 | geo_info_2_2_2 | ... |
-- +----+--------------------+----------------+----------------+-----+
-- ...I need a flat version of the original table, if you will. My original plan was to convert the VARRAY values to rows and extract the geometries into rows. Then join both using their ROWNUMs. But this does not work as i need numbers that start at 1 for each ID and I'm not sure if ROWNUM will give me the right order. Hence my question for consecutive element numbers. I have no idea how to do it with SQL. I'm working on a PL/SQL solution right now. Sample code follows. Sorry for the length of this post.
CREATE OR REPLACE TYPE geo_info AS OBJECT (
  just INTEGER,
  txt  VARCHAR2 (255)
CREATE OR REPLACE TYPE geo_info_array AS VARRAY (10000) OF geo_info;
CREATE TABLE geometries (
  id NUMBER (38) PRIMARY KEY,
  geom_coll SDO_GEOMETRY,
  geo_info geo_info_array
INSERT INTO geometries (id, geom_coll, geo_info) VALUES (
  98,
  sdo_geometry (2004, NULL, sdo_point_type (0, 0, 0),
                sdo_elem_info_array (1, 1, 1, 3, 2, 1, 7, 1, 1, 9, 1, 1),
                sdo_ordinate_array (5408562.081181, 5696027.239777, 5408563.398, 5696028.369, 5408568.192, 5696028.132, 5408562.643029, 5696038.558968, 5408565.328059, 5696027.0783)),
  geo_info_array (geo_info (7, '10.9'),
                  NULL,
                  geo_info (7, '0.0'),
                  geo_info (7, '-4.8-'))
INSERT INTO geometries (id, geom_coll, geo_info) VALUES (
  99,
  sdo_geometry (2004, NULL, sdo_point_type (0, 0, 0),
                sdo_elem_info_array (1, 2, 1, 5, 1, 1, 7, 2, 1, 11, 1, 1, 13, 1, 1),
                sdo_ordinate_array (5408575.262, 5696017.841, 5408575.255, 5696017.341, 5408573.318578, 5696016.67559, 5408575.255, 5696017.341, 5408574.155, 5696017.357, 5408573.359578, 5696017.97359, 5408572.012251, 5696017.299678)),
  geo_info_array (NULL,
                  geo_info (7, '0.5'),
                  NULL,
                  geo_info (7, '0.0'),
                  geo_info (7, '-1.1-'))
/

Similar Messages

  • How can we get the selected line number from JTextArea ?

    how can we get the selected line number from JTextArea ? and want to insert line/string given line number into JTextArea??? is it possible ?

    Praitheesh wrote:
    how can we get the selected line number from JTextArea ?
    textArea.getLineOfOffset(textArea.getCaretPosition());
    and want to insert line/string given line number into JTextArea??? is it possible ?
    int lineToInsertAt = 5; // Whatever you want.
    int offs = textArea.getLineStartOffset(lineToInsertAt);
    textArea.insert("Text to insert", offs);

  • Can you get IMEI number from device ID

    Dear all,
    We have had a user who's phone was stolen so we are trying to get the phon blacklisted. We need the IMEI number but I don't have this obviously so I wondered if Apple can get the IMEI number from the device ID which I can get from office 365.
    Thanks for any help.
    Ed

    greenkomodo wrote:
    I can't unfortunately, we buy a hardware only device and don't register to a number so it isn't tracked on their system for the user what device they last used.
    If the phone was used on a cellular carrier, it is likely that, even though you didn't buy the phone from the carrier, that the IMEI registered with the carrier's system when the phone was activated.

  • Can't remove my number from iMessage on my IPad .

    Can't remove my number from iMessage on my IPad .
    Just bought a new phone with data package , as soon as I turned it on, my iPad asked me to link the iPhone 5 number to my iPad iMessage , I said yes, and that was the mistake, both iPad and iPhone getting messages when I send it to either.
    I tried to switch in between all the other emails registered on my iMessage , but no luck.
    Any One have an idea how to remove the number from iPad?

    When you sign in to your Apple ID with iMessage using an iPhone with iOS 6, your Apple ID is linked to your phone number. This allows you to receive iMessages sent to your phone number on other iOS 6 devices signed in to the same Apple ID. If your phone number is not listed on an iPod touch or iPad, follow this article.
    When another iOS device enables iMessage with your Apple ID, you will receive an alert:
    Email Address Added to "[device name]"
    "[device name]" is now using "[Apple ID]" for iMessage.
    To remove phone number for iPad or iPod:
    On the iPhone and iPad sign out Messages. Then sign into the iPad. Then sign into the iphone

  • How can I select several emails from 3900 on my 5c and delete the rest easily

         How can I select several emails from 3900 on my 5c and delete the rest easily

    We'll I don't think there's a easy way to delete a lot of emails besides deleting all of them. To delete all of them click on inbox them edit then "mark all" then trash/delete. Other than that you will have to specifically deleted the ones you want to delete.

  • Select * into Table1 from Table not working

    Hi,
    How to copy data from one table to other new table using select * into statement.
    I am getting missing keyword error when I use the statement
    select * into Table1 from Table
    Thanks a lot in advance.
    Regards,
    Praveen

    the syntax is
    INSERT INTO table1 SELECT * FROM table2;

  • I put my sim in someone's phone earlier for about 3 minutes, and now they are receiving my iMessages and can't remive my number from their settings, pls help

    I put my sim in someone's phone earlier for about 3 minutes, and now they are receiving my iMessages and can't remive my number from their settings, pls help

    They need to turn off iMessage, power the phone off/on, then activate iMessage again with their SIM.

  • Can I install elements 11 from version 9 or must I install version 10 first.

    can I install elements 11 from version 9 or must I install version 10 first.

    Yes you can upgrade to Elements 11 from 9 without installing 10 first.

  • Can I selectively recover files from my Time Machine Back-up?

    After installing the most current apps from the App Store, OS X 10.8.5, Safari and iTunes,my system became disfunctional. I did not back up my system before this happened. Before these updates, I had the spinning beach ball on opening and closing apps and applications quiting or freezing. Eventually, after trying to repair by various means, I couldn't access my desktop. I went into Recovery mode and did a backup of my corrupt system and reinstalled OS. I have a good basic system now but now I would like to know, "Can I selectively recover files from my Time Machine Back-up?"

    The basic answer is Yes, but it depends on what files. Can you give an example of what type of files and where they were located.

  • Is There Anyway I Can Get The Serial Number From My iPod Without Actually Having The iPod?

    Is There Anyway I Can Get The Serial Number From My iPod Without Actually Having The iPod?

    - Sign in hee and look:
    My Support Profile
    - On your syncing computer go to iTunes>Preferences>Devices and hover the mouse pointer over the iPod backup and the SN will pop up in a box.

  • I lost my Serial number for InDesign and need it to load InDesign not my new iMac. How can I request my number from Adobe?

    I lost my Serial number for InDesign and need it to load InDesign not my new iMac. How can I request my number from Adobe?

    Could it be registered under a different identity? I've used three identities over the years to register stuff, so I have to do some looking around to find stuff. Try old email addresses as possible IDs.

  • Can't select & copy data from inspect element's tab - network

    So, I'm trying to get a direct link to an image on website that deliberately tried to make it hard to get them.
    For example,
    http://www.heavy.com/games/2013/10/nycc-2013-best-video-game-cosplay-gallery/2/
    So, I see the direct link to an image in this page - but I can't select it nor copy it (ctrl + c)
    why??? What's the point of network tab in inspect element if you can't select anything there, except for what's in headers - but there's no link to the image there.

    If you are copying it a URL of image embed in HTML, double click on the link in
    '''SRC=" ----------- Double click here ----------------------- "'''
    then you will be inside the src section, you will be able to edit the link now
    '''select it '''> '''From right click '''menu > select '''copy'''
    or
    Press Control (Ctrl) + c on windows or linux (Command + C on mac)
    If the image is embedded using CSS, click on the Link and do the same as said above.

  • How can we select duplicate records from a table

    Hi
    I desire to use a query to select duplicate columns (based on all the columns of the table) ...
    I am able to write queries which include column names, but when my table contains more than 50 columns, is it advisable for me to mention all the 50 column names in the query or is there any other query by which duplicate rows can be selected without column names being mentioned ?
    Thnx in advance
    Regards

    Basic rule of relational design says that "thy table shalt have a primary key".
    Now assuming that you do not have a primary key constraint and that resulted in duplicates, you should still have a couple of columns that uniquely describes a row in that table.
    To select duplicate rows can then be done by joining rows with the primary key (same set of unique columns), where rows have different rowids (physical addresses).
    E.g.
    select
    t1.*,
    t2.*
    from table t1,
    table t2
    where t1.col1 = t2.col1
    and t1.col2 = t2.col2
    and t1.rowid < t2.rowidIf you do not have a couple of columns (primary key) that uniquely identifies a row, then you do not have duplicates in the table - as there cannot be duplicates without having a means of unique identification.

  • Selecting a value from table

    hi experts,
    i am usng a table in my wd-abap compent. the table has to 2 columns. one of them is a text view and other is a link to action. the table can contain multiple values which are fetched from some database table. now i want that when i click on any one of the link to action, a pop up window is opened which contains data that is fetched from some data base table according to the perticular link clicked.
    eg : say my link in the first row of the table is "link1"
    and  link in the second row of the table is "link2".
    so when i click on link1, a pop up window containing some data gets opened and when i click link2 another pop up window is opened containing different data. How can i do it.....
    According to the requirement i have to set the "selection mode " property of the table as 'none'.
    Plz help.
    regards
    arjun

    Hi Arjun,
    You can proceed as explained in here. In the onAction event of the LinkToAction place the following coding:
    method ONACTIONONLINKCLICK .
      data: lr_element type ref to if_wd_context_element,
              lv_index type i.
      lr_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT'  ).
      lv_index = lr_element->get_index( ).
    Now lv_index will contain the table row number in which the LinkToAction was clicked upon. I guess that you would know as to how to proceed from here. Use this index number to read the internal table which you are using to bind to the table ui element.
    ex:
    read table lt_sflight into wa_sflight index lv_index.
    Thought to try edit my previous post again...  Once you obtain the reference of type if_wd_context_element you can directly read the value of the attribute in the first column. You dont have to read the internal table using a READ or anything as how I had said earlier...  Directly code like as shown below:
    CALL METHOD lr_element->get_attribute
        EXPORTING
          name   = 'MATNR'   " Give the name of your first column in here
        IMPORTING
          value  = lv_matnr.   " Your first columns value would get saved into this variable
    I had declared lv_matnr as a local variable of type mara-matnr & I could get the value of the MATNR which is present in the 1st column of the same row.
    Regards,
    Uday
    Edited by: Uday Gubbala on Oct 10, 2008 4:32 PM

  • Get selected row values from Table view control

    Hi ,
    I am using transaction ME23N, would like to access row values from item table for selected row. I have written a script as in screen shot and its giving me error at java script step two. I want to get the PR number from item table for selected row.
    With Regards
    Vishal Lokapur

    H Vishal,
    Can you please share how you were able to resolve the issue regarding the selected row
    in case of a table control .
    Regards

Maybe you are looking for