| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

02-09-12, 16:19
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 5
|
|
|
plsql error 00103-
|
|
hi based on the following information
grade lowsal highsal
------ ----- ------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
for the employee table to assign grade for each employee based on his salary
the following plsql procedure is giving error:
-----------------------------------------------------------
CREATE OR REPLACE PROCEDURE GRADE(EID IN NUMBER,BONUS OUT NUMBER) IS
vGRADE NUMBER(8,2);
vSAL NUMBER(8,2);
BEGIN
vGRADE=1
SELECT SAL INTO vSAL FROM EMP WHERE EMPNO=EMPID;
IF vSAL<= 700 THEN
vGRADE:=1;
ELSEIF vSAL<= 1201 THEN
vGRADE:=2;
ELSEIF vSAL<= 1401 THEN
vGRADE:=3;
ELSEIF vSAL<= 2001 THEN
vGRADE:=4;
ELSEIF vSAL<= 3001 THEN
vGRADE:=5;
ELSE
vGRADE:=0;
END IF;
GRADE:=vGRADE;
END;
---------------------------------------------------------------
8/9 PLS-00103 encountered the symbol "VSAL" when expecting one of the following := . ( @ % ;
10/9 PLS-00103 encountered the symbol "VSAL" when expecting one of the following := . ( @ % ;
12/9 PLS-00103 encountered the symbol "VSAL" when expecting one of the following := . ( @ % ;
14/9 PLS-00103 encountered the symbol "VSAL" when expecting one of the following := . ( @ % ;
20/4 PLS-00103 encountered the symbol ";" when expecting one of the following :
if
|
|

02-09-12, 16:23
|
|
Registered User
|
|
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
|
|
>vGRADE=1
not as above but as below
vGRADE=1;
statements are terminated by semicolon character; but you already knew that didn't you?
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
|
|

02-09-12, 16:30
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 5
|
|
|
plsql 00103
|
|
hi thanks but actually it is like this with the same error
CREATE OR REPLACE PROCEDURE GRADE(EID IN NUMBER,BONUS OUT NUMBER) IS
vGRADE NUMBER(8,2);
vSAL NUMBER(8,2);
BEGIN
SELECT SAL INTO vSAL FROM EMP WHERE EMPNO=EMPID;
IF vSAL<= 700 THEN
vGRADE:='A';
ELSEIF vSAL<= 1201 THEN
vGRADE:='B';
ELSEIF vSAL<= 1401 THEN
vGRADE:='C';
ELSEIF vSAL<= 2001 THEN
vGRADE:='D';
ELSEIF vSAL<= 3001 THEN
vGRADE:='E';
ELSE
vGRADE:='F';
END IF;
GRADE:=vGRADE;
END;
|
|

02-09-12, 16:37
|
|
Registered User
|
|
Join Date: Mar 2010
Location: Vienna, Austria
Posts: 130
|
|
it's not the same error.
Now you are assigning characters ('A', 'B', ..., 'F') to a NUMBER(8,2) variable (vGRADE)
(by the way: a CASE statement would make much more sense)
__________________
If A is a success in life, then A = x + y + z.
Work is x; y is play; and z is keeping your mouth shut. After all the years, I'm still working on the correct value for z.
(Albert Einstein)
|
Last edited by magicwand; 02-09-12 at 16:44.
Reason: CASE hint added
|

02-09-12, 16:41
|
|
Registered User
|
|
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
|
|
>hi thanks but actually it is like this with the same error
Too bad COPY & PASTE are broken for you
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
|
|

02-09-12, 16:45
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 5
|
|
I am sorry for the confusion,I tried out everything but does'nt seem to be working thanks for your help in advance
it's this
------------------------------------------------------------
CREATE OR REPLACE PROCEDURE GRADE(EID IN NUMBER,BONUS OUT NUMBER) IS
vGRADE NUMBER(2);
vSAL NUMBER(8,2);
BEGIN
SELECT SAL INTO vSAL FROM EMP WHERE EMPNO=EMPID;
IF vSAL<= 700 THEN
vGRADE:=1;
ELSEIF vSAL<= 1201 THEN
vGRADE:=2;
ELSEIF vSAL<= 1401 THEN
vGRADE:=3';
ELSEIF vSAL<= 2001 THEN
vGRADE:=4;
ELSEIF vSAL<= 3001 THEN
vGRADE:=5';
ELSE
vGRADE:=0;
END IF;
GRADE:=vGRADE;
END;
------------------------------------------------------------
8/9 PLS-00103 encountered the symbol "VSAL" when expecting one of the following := . ( @ % ;
10/9 PLS-00103 encountered the symbol "VSAL" when expecting one of the following := . ( @ % ;
12/9 PLS-00103 encountered the symbol "VSAL" when expecting one of the following := . ( @ % ;
14/9 PLS-00103 encountered the symbol "VSAL" when expecting one of the following := . ( @ % ;
20/4 PLS-00103 encountered the symbol ";" when expecting one of the following :
if
|
|

02-09-12, 17:24
|
|
Registered User
|
|
Join Date: Mar 2010
Location: Vienna, Austria
Posts: 130
|
|
1.) I'd suggest
Code:
SELECT SAL INTO vSAL FROM EMP WHERE EMPNO=EID;
instead of your
Code:
SELECT SAL INTO vSAL FROM EMP WHERE EMPNO=EMPID;
2.) you should either declare a variable GRADE or assign vGrade to BONUS (which would make more sense)
3.) Because ELSEIF is not a PL/SQL reserved word, the parser treats it as variable and expects an assingment operator (:=).
Try ELSIF instead
4.) i still think, a CASE statement would make the code much more readable
(or - at least - use code tags)
__________________
If A is a success in life, then A = x + y + z.
Work is x; y is play; and z is keeping your mouth shut. After all the years, I'm still working on the correct value for z.
(Albert Einstein)
|
Last edited by magicwand; 02-09-12 at 17:27.
|

02-09-12, 18:11
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 5
|
|
|
@magicwand
  thank you ....it worked
|
|

02-09-12, 18:24
|
|
Registered User
|
|
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
|
|
Consider actually Reading This Fine Manual
Contents
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
|
|

02-09-12, 18:26
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 5
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|