Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 PL/SQL update rate using having count

Author  Topic 

mydreamadsl
Starting Member

2 Posts

Posted - 2011-12-15 : 09:23:55
Hi am newbie at pl/sql

I need to update rate_per_hour for all projects having less than 5 employee to 500

here is the code what i wrote, but it updates all employee

set serveroutput on

declare
cursor rate_cur is
select * from project
for update of rate_per_hour;
begin
for rate_rec IN rate_cur
loop
update project
set rate_per_hour=500
where current of rate_cur;
end loop;

end;


here is my tables:

CREATE TABLE employee(
empid number(5),
empname varchar(20),
address varchar(20),
no_of_dependents number(5),
deptno number(5),
CONSTRAINT EMPLOYEE_PKEY PRIMARY KEY(empid),
CONSTRAINT EMPLOYEE_FKEY FOREIGN KEY(deptno) REFERENCES department(deptno));

CREATE TABLE project(
projectno number(5),
location varchar(20),
incharge number(5),
rate_per_hour number(5),
CONSTRAINT PROJECT_PKEY PRIMARY KEY(projectno),
CONSTRAINT PROJECT_FKEY FOREIGN KEY(incharge) REFERENCES employee(empid));

CREATE TABLE assignment(
empid number(5),
projectid number(5),
hours number(5),
CONSTRAINT ASSIGNMENT_FKEY FOREIGN KEY(empid) REFERENCES employee(empid),
CONSTRAINT ASSIGNEMNT_FKEY2 FOREIGN KEY(projectid) REFERENCES project(projectno));


please suggest a solution

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-15 : 09:35:11
SQLTeam.com is on Microsoft SQL Server

try dbforums.com or orafaq.com


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

mydreamadsl
Starting Member

2 Posts

Posted - 2011-12-15 : 09:38:59
ok, thx
Go to Top of Page
   

- Advertisement -