| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> How to display MIN/MAX values in a cursor
I wrote a quick PL/SQL statement to display the range of values in a table
but am having trouble with the DBMS_OUTPUT line. It runs fine as a standalone
SELECT statement but not in this. Any ideas on what's wrong?
Thanks in advance!
BEGIN
DECLARE
CURSOR rcpt_num_cur IS
SELECT SUBSTR(receipt_number, 1, 1) INIT,
MIN(receipt_number) MIN_NUM,
MAX(receipt_number) MAX_NUM
FROM remitter
WHERE SUBSTR(receipt_number, 1, 1) IN('A', 'D', 'E', 'N')
GROUP BY SUBSTR(receipt_number, 1, 1);
BEGIN
FOR v_rcpt_num IN rcpt_num_cur LOOP
DBMS_OUTPUT.put_line(v_rcpt_num.init || ' ' || v_rcpt_num.min_num || ' ' || v_rcpt_num.max_num);
END LOOP;
![]() |
![]() |