Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL TEMP TABLES.,CAN YOU CHECK IF A VALUES EXISTS
PL/SQL TEMP TABLES.,CAN YOU CHECK IF A VALUES EXISTS [message #37440] Thu, 07 February 2002 11:35 Go to next message
bhasker
Messages: 5
Registered: February 2002
Junior Member
i need to return the count ofdistinct values that i get from multiple querries.
I am copying these values into temp table
it's like this scenario
if i have value 1, i copy it into temp pl/sql table
if i have value 2, i copy 2 into temp pl/sql table
if i have value 1 again, i copy 1 into temp pl/sql table.
if i have value 3, i copy 3 again into temp table.
if i have value 2, i copy 2 again into temp table.
if i have value 3, i copy 3 again into temp table.
now temp table has 1,2,1,3,2,3 values
the first value is 1
********************
v_temp is the name of the table, counter is the name
of the column,
v_holdacctgrp contains the first value(i.e 1),
v_returnvalue is initially 1
code i am using

BEGIN
-- loop all the accounting groups in the temp table
v_Counter := 0;
For v_counter IN 0..v_temp.Count LOOP
v_tempacctgrp := v_temp(v_Counter);
-- Compare the accounting group with the first one
If v_holdacctgrp != v_tempacctgrp Then
v_returnvalue := v_returnvalue + 1;

End If;

End Loop;
**************************************
what i need to return is count of distinct values
in my pl/sql tables, i.e distinct values are 1,2,3
and the count is 3.
but i can't select on the pl/sql tables.
does any of you have any ideas.
May be i am not very clear,
you can email me if i am not clear
at bhasker.garlapati@cingular.com
thanks
bhasker
Re: PL/SQL TEMP TABLES.,CAN YOU CHECK IF A VALUES EXISTS [message #37449 is a reply to message #37440] Fri, 08 February 2002 01:51 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
hi,

now your logic is as follows
-------------------------------
if i have value 1, i copy it into temp pl/sql table
if i have value 2, i copy 2 into temp pl/sql table
if i have value 1 again, i copy 1 into temp pl/sql table.
if i have value 3, i copy 3 again into temp table.
if i have value 2, i copy 2 again into temp table.
if i have value 3, i copy 3 again into temp table.

change your logic to
--------------------
if i have value say "a" then search the pl/sql table if not exist then add otherwise not (u can write a procedure to test if it exist or not)

hope it helps!!!

cheers
pratap
Previous Topic: select query
Next Topic: valid column names
Goto Forum:
  


Current Time: Wed Apr 24 02:48:43 CDT 2024