Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to query a Table type without using Loops(FOR,etc)

801360Mar 27 2012 — edited Mar 28 2012
Hi all,

I am just a beginner working with oracle DB. I have a very fundamental question on TABLE TYPES in oracle.

create table sample(a number,b varchar2(10))
/
set serveroutput on;

declare
TYPE tab_type IS TABLE OF sample%ROWTYPE;
t_tab tab_type := tab_type();
begin

for i IN 0..2
loop
t_tab.extend;
t_tab(t_tab.last).a := i;
t_tab(t_tab.last).b := 'maru';
dbms_output.put_line(t_tab(t_tab.last).a);
end loop;

-- CAN I DO A SELECT * FROM THE TABLE t_tab without using a cursor to iterate row by row
-- Since i need to compare the values of a table called MAIN with this SAMPLE table.i need to check whether all the records present in MAIN table is present in the
--SAMPLE table table type.I dont want to insert into any temp table( as it becomes a overhead) and compare the results.
end;

Kindly help me in this regard and let me know in case you need further more details.

Thanks in Advance.
This post has been answered by Alkaron on Mar 27 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2012
Added on Mar 27 2012
13 comments
641 views