Home » SQL & PL/SQL » SQL & PL/SQL » code does not get executed, why??????
code does not get executed, why?????? [message #37987] Tue, 12 March 2002 12:12 Go to next message
Sid
Messages: 38
Registered: May 1999
Member
Why does this query not get executed.
I have looked over the code many times to check if I have missed and "end clause" or a semi-colon.

clearly the "/" termination char is there on the very last line of code.

The only way I get ORACLE to respond is by typing / again.

Then it gives error:
/
*
ERROR at line 33:
ORA-06550: line 33, column 2:
PLS-00103: Encountered the symbol "/"

Here is the code

ACCEPT p_emp_number PROMPT 'Please enter employee number: '

DECLARE

v_emp_number empp.empno%TYPE := &p_emp_number;
v_emp_salary empp.sal%TYPE;
v_number_of_astrix NUMBER(2);
v_string_stars empp.stars%TYPE;
v_counter number(2) := 0;
CURSOR empp_cursor IS SELECT * FROM empp FOR UPDATE;

BEGIN
select sal
into v_emp_salary
from empp where empno = v_emp_number;

v_emp_salary := round(v_emp_salary);
v_number_of_astrix := v_emp_salary/100;

FOR i IN empp_cursor LOOP
IF i.empno = v_emp_number then
while v_counter < v_number_of_astrix loop
v_string_stars := v_string_stars || '*';
v_counter := v_counter + 1;
end loop;
update empp
set stars = v_string_stars
WHERE CURRENT OF empp_cursor;
END IF;

END LOOP; --end for loop
COMMIT;
end;
/

DECLARE

v_emp_number empp.empno%TYPE := &p_emp_number;
v_emp_salary empp.sal%TYPE;
v_number_of_astrix NUMBER(2);
v_string_stars empp.stars%TYPE;
v_counter number(2) := 0;
CURSOR empp_cursor IS SELECT * FROM empp FOR UPDATE;

BEGIN
select sal
into v_emp_salary
from empp where empno = v_emp_number;

v_emp_salary := round(v_emp_salary);
v_number_of_astrix := v_emp_salary/100;

FOR i IN empp_cursor LOOP
IF i.empno = v_emp_number then
while v_counter < v_number_of_astrix loop
v_string_stars := v_string_stars || '*';
v_counter := v_counter + 1;
end loop;
update empp
set stars = v_string_stars
WHERE CURRENT OF empp_cursor;
END IF;

END LOOP; --end for loop
COMMIT;
end;
/
Re: code does not get executed, why?????? [message #37997 is a reply to message #37987] Wed, 13 March 2002 00:56 Go to previous message
Pratibha
Messages: 29
Registered: November 2001
Junior Member
Hi,

By looking at the code, it seems to be alright, what i can suggest is put an exception block before end & then try - u can trap the error at runtime.
One more thing is, why have you given the same code twice?

Bye
Previous Topic: simple PL/SQL question
Next Topic: Output file and exit;
Goto Forum:
  


Current Time: Fri Mar 29 02:56:32 CDT 2024