-
SUM at DBMS_OUTPUT.PUT_LINE
DECLARE
CURSOR emp_cur IS
SELECT ename, sal
FROM emp
WHERE deptno = 10
ORDER BY sal DESC;
BEGIN
FOR emp_rec IN emp_cur LOOP
DBMS_OUTPUT.PUT_LINE ('Employee ' || emp_rec.ename || ' earns ' || TO_CHAR (emp_rec.sal) || ' dollars.');
END LOOP;
END;
/
This program generates the following output when executed in SQL*Plus:
Employee KING earns 5000 dollars.
Employee SCOTT earns 3000 dollars.
Employee JONES earns 2975 dollars.
Employee ADAMS earns 1100 dollars.
Employee JAMES earns 950 dollars.
How can I have the sum of emp_rec.sal on the last output line?
Thanks.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|