sql - Update employees table -



sql - Update employees table -

guys have next problem:

increase salary 15% employees salary less 50% of manager's salary. write pl/sql procedure using cursor, loop , update.

procedure header create or replace procedure inc_salary is:

. exception if salary after increment more 50% of manager's salary.

actually, can straight this:

update emp e set e.salary+=e.salary*0.15 e.salary<(select e.mgr emp e, grouping e.mgr)

here image of table:

but don't understand how utilize procedure. if declare this, create or replace procedure inc_salary, should parameters? can utilize of course of study loop, like

declare r in (select * emp e) loop update emp e set r.salary+=r.salary*0.15; r.salary<r.mgr exception if r.salary >r.mgr*1.15 dbms.output_putline(' can't increase'); end loop; end;

but how combine together?

why need pl/sql procedure? simple query job!

update emp set salary = salary * 1.15 empno in ( select e.empno emp e bring together emp m on e.mgr = m.empno e.salary < m.salary * 0.5 )

that's it!

but, if @ need utilize procedure, have decide want it.

every procedure has set of formal parameters, can empty set. decides pass procedure. consult manager or architect these situations.

sql oracle

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -