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 loop through query result and print each row in stored procedure?

591556Oct 20 2007 — edited Oct 20 2007

I have this query which returns a set of rows, How can I loop through each row and display them using dbms.output.put_line? Please notice in the where clause there is a variable 'v_trainer_id', the variable value is known (retrieved from a column of a current row of another cursor). please help

select 
customer.id as customer_id, 
membership.join_date, 
membership.join_fee,
round(months_between(sysdate, membership.join_date),0) as months_joined, 
membership_plan.monthly_price, 
membership.monthly_discount, 
(membership_plan.monthly_price- membership.monthly_discount) * round(months_between(sysdate, membership.join_date),0) as total_paid
from 
membership,membership_plan,customer
where 
membership.membership_plan_id = membership_plan.id and
customer.id=membership.customer_id and
membership.trainer_id = v_trainer_id
order by
customer.id;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 17 2007
Added on Oct 20 2007
2 comments
5,341 views