?
Solved

How to Get Table type Index in SQL?

Posted on 2014-01-02
2
Medium Priority
?
600 Views
Last Modified: 2014-02-25
Hi ,

I am using below logic to verify whether the given value is present or not in the array. In that I also wanted to fetch the index of the value. Is this possible with the below approach? Please let me know if any other approach to fetch.

set serveroutput on
declare
    tabtype_exist_del_grp_org   FND_TABLE_OF_NUMBER := FND_TABLE_OF_NUMBER ();
    v_row_num       number;
    v_del_grp_exist varchar2(30);
    v_del_exist varchar2(30);
begin
    tabtype_exist_del_grp_org.extend;
    tabtype_exist_del_grp_org (1) := 184;
    tabtype_exist_del_grp_org.extend;
    tabtype_exist_del_grp_org (2) := 185;
    tabtype_exist_del_grp_org.extend;
    tabtype_exist_del_grp_org (3) := 243;
    
    BEGIN
        SELECT  ROWNUM, COLUMN_VALUE, 'Y'
        INTO    v_row_num, v_del_grp_exist, v_del_exist
        FROM    TABLE(tabtype_exist_del_grp_org)
        WHERE   COLUMN_VALUE = 243;
                                
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
        v_del_exist := 'N'; 
                                                         
    WHEN OTHERS
    THEN
        v_del_exist := 'N';
    END;
    
    dbms_output.put_line ('v_del_grp_exist : '||v_del_grp_exist);
    dbms_output.put_line ('v_row_num : '||v_row_num);
    dbms_output.put_line ('v_del_exist : '||v_del_exist);

end;

Open in new window

0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
Alexander Eßer [Alex140181] earned 1500 total points
ID: 39750994
You can & should do this without using SQL within your PL/SQL (faster, no context switches):

...
  v_del_grp_exist := 243;
  v_indx := tabtype_exist_del_grp_org.first;
  while v_indx is not null loop
    if tabtype_exist_del_grp_org(v_indx) = v_del_grp_exist then
      dbms_output.put_line('value found!');
      exit;
    end if;
    v_indx := tabtype_exist_del_grp_org.next(v_indx);
  end loop;
...

Open in new window

0
 

Author Closing Comment

by:Suriyaraj_Sudalaiappan
ID: 39885054
Good
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question