Home » SQL & PL/SQL » SQL & PL/SQL » Assigning the value of count(*) to a variable?
Assigning the value of count(*) to a variable? [message #678] Tue, 26 February 2002 06:14 Go to next message
Greg Horton
Messages: 37
Registered: February 2002
Member
I have the following piece of code below, and when executed id like to assign the count(*) value of distinct honours_points into a different variable. Do you have any ideas?

DECLARE
CURSOR c_frequent_items IS
SELECT distinct honours_points, count(*) count_star
from students
group by honours_points
having count(*) >= :mine_data.support_value_text;
--
BEGIN
go_block('frequent_items');
FOR cursor_rec IN c_frequent_items
LOOP
create_record;
:frequent_items.honours_points:=cursor_rec.honours_points;
:frequent_items.count_star:=cursor_rec.count_star;
END LOOP;
END;

Thanks :-)

Greg
Am i nearly there?! [message #680 is a reply to message #678] Tue, 26 February 2002 06:51 Go to previous message
Greg Horton
Messages: 37
Registered: February 2002
Member
Ive attempted to answer my own question using the code below:

DECLARE
v_records_found NUMBER;
--
BEGIN
select count(distinct honours_points)
into v_records_found
from students
group by honours_points
having count(*) >= :mine_data.support_value_text;
--
go_block('frequent_items');
--
:frequent_items.records_found_text:=v_records_found;
--
END;

Im not getting the correct output even though the trigger compiles. Can you suggest where i may have gone wrong?

Thank you..

Greg
Previous Topic: trigger
Next Topic: Error with code?
Goto Forum:
  


Current Time: Wed Apr 24 14:17:19 CDT 2024