Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SET SERVEROUTPUT ON SET VERIFY OFF

Status
Not open for further replies.

owenyuen

Programmer
Feb 19, 2003
22
0
0
US
SET SERVEROUTPUT ON
SET VERIFY OFF
SET ECHO OFF

ACCEPT p_num PROMPT 'Please enter the number of top money makers: '
DECLARE
Wrong_Input EXCEPTION;
v_num NUMBER(2) := &p_num;
v_ename emp.ename%TYPE;
v_sal emp.sal%TYPE;
v_dept dept.dname%TYPE;
tmp_sal emp.sal%TYPE;
v_count Number;

CURSOR emp_cursor IS
SELECT emp.ename, emp.sal, dept.dname
FROM emp , dept
WHERE emp.sal IS NOT NULL
and emp.deptno = dept.deptno
ORDER BY emp.sal DESC;
BEGIN
Select count(*)
into v_count
from EMP;

If (v_num <= 0) or (v_count < v_num) Then
RAISE Wrong_Input;
End if;

OPEN emp_cursor;
FETCH emp_cursor INTO v_ename, v_sal, v_dept;

tmp_sal := 0;
DBMS_OUTPUT.PUT_LINE('NAME DEPARTMENT SALARY');
DBMS_OUTPUT.PUT_LINE('---- ---------- -------');
WHILE emp_cursor%ROWCOUNT <= v_num AND emp_cursor%FOUND LOOP
DBMS_OUTPUT.PUT_LINE(rpad(v_ename, 20) || rpad(v_dept, 20) || lpad(TO_CHAR(v_sal), 7));
FETCH emp_cursor INTO v_ename, v_sal,v_dept;
If tmp_sal = v_sal Then
v_num := v_num + 1;
else
tmp_sal := v_sal;
End If;
END LOOP;
CLOSE emp_cursor;
EXCEPTION
WHEN Wrong_Input THEN
DBMS_OUTPUT.PUT_LINE('*** Input must be in between 1 to ' || v_count || '. Please try again! ***');
END;
/
SET VERIFY ON
SET ECHO ON

////////////////// OutPut //////////////////////////

Please enter the number of top money makers: 5
NAME DEPARTMENT SALARY
---- ---------- -------
KING ACCOUNTING 5000
FORD RESEARCH 3000
SCOTT RESEARCH 3000
JONES RESEARCH 2975
BLAKE SALES 2850
CLARK ACCOUNTING 2450

PL/SQL procedure successfully completed.

Input truncated to 11 characters

////////////////// QUESTIONS //////////////////////////
Why last line of output has &quot;Input truncated to 11 characters&quot; that kind of message??


 
At the end of the code Press Enter(leaves a blank line) and try running the script again.

/
SET VERIFY ON
SET ECHO ON(Press Enter)


Input truncated to 11 characters - is nothing but the number of letter in the word &quot;SET ECHO ON&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top