Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 7th, 2008, 12:09 PM   #1
A.K.Al Shamsi
Programmer
 
A.K.Al Shamsi's Avatar
 
Join Date: Mar 2008
Posts: 35
Rep Power: 0 A.K.Al Shamsi is on a distinguished road
Pl/sql

hi guys

how are you??

i am coding for project and i got errors but i don't know what is the wrong??

here is the code
set serveroutput on

declare 
h00019852_depid :=departments.department_id%type;

begin
select max(h00019852_depid) into department_id
from departments
group by department_id;

dbms_output.put_line('The maximum department id is: '||h00019852_depid);
end;

this is the error:
(h00019852_depid :=departments.department_id%type;
*

ERROR at line 2:
ORA-06550: line 2, column 17:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table LONG_ double ref
char time timestamp interval date binary national character
nchar
The symbol "<an identifier>" was substituted for "=" to continue. )

==========================================================

and this too
set serveroutput on
accept h00019852_depid prompt'Enter department id:'

declare
h00019852_depid Number:= employees.department_id%type;
h00019852_empid employees.employee_id%type;

begin 
select (count(h00019852_empid)) into  employee_id
from employees
where departments.department_id=employees.department_id;

dbms_output.put_line(h00019852_empid||'employee(s) work for department number'||depid);

end;

and this is the error for code

(h00019852_depid Number:= employees.department_id%type;
*

ERROR at line 2:
ORA-06550: line 2, column 50:
PLS-00208: identifier 'TYPE' is not a legal cursor attribute
ORA-06550: line 2, column 17:
PL/SQL: Item ignored
ORA-06550: line 8, column 7:
PL/SQL: ORA-00904: "DEPARTMENTS"."DEPARTMENT_ID": invalid identifier
ORA-06550: line 6, column 1:
PL/SQL: SQL Statement ignored
ORA-06550: line 10, column 81:
PLS-00201: identifier 'DEPID' must be declared
ORA-06550: line 10, column 1:
PL/SQL: Statement ignored )


could you help me, please?!
A.K.Al Shamsi is offline   Reply With Quote
Old May 9th, 2008, 8:24 AM   #2
A.K.Al Shamsi
Programmer
 
A.K.Al Shamsi's Avatar
 
Join Date: Mar 2008
Posts: 35
Rep Power: 0 A.K.Al Shamsi is on a distinguished road
Re: Pl/sql

thank you guys for helping me
A.K.Al Shamsi is offline   Reply With Quote
Old May 9th, 2008, 1:04 PM   #3
Druid
Programmer
 
Join Date: Mar 2006
Posts: 40
Rep Power: 0 Druid is on a distinguished road
Re: Pl/sql

You're problem is this line.

h00019852_depid :=departments.department_id%type;

This is not how you properly state the variable type in PL/SQL.

This way is more accurate....
h00019852_depid departments.department_id%type;

Considering you have a table named departments with a field named department_id.
Druid is offline   Reply With Quote
Old May 12th, 2008, 1:22 AM   #4
A.K.Al Shamsi
Programmer
 
A.K.Al Shamsi's Avatar
 
Join Date: Mar 2008
Posts: 35
Rep Power: 0 A.K.Al Shamsi is on a distinguished road
Re: Pl/sql

could somebody check this code for me?

declare 

h00019852_salary employees.salary%type;

begin
select salary,last_name into h00019852_salary
from employees
where last_name=&h00019852_gv_empname;

update employees
set salary = salary +500
where if salary < 3000 then 
dbms_output.put_line(h00019852_gv_empname||' 's salary updated'); 
else 
dbms_output.put_line(h00019852_gv_empname||' earns salary of '|| h00019852_salary); 
end if;

end;


i get this error

old 8: where last_name=&h00019852_gv_empname;
new 8: where last_name=Pataballa;
ERROR:
ORA-01756: quoted string not properly terminated
A.K.Al Shamsi is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PL/SQL - get DB name Gumby Other Programming Languages 7 Jun 1st, 2006 10:08 AM
PL/SQL code question java_roshan Other Programming Languages 5 Oct 12th, 2005 2:25 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:34 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC