Live ORACLE

if you are Oracle Developer ,than this Blog most likely will make you happy.

About my Blog

This Blog particularized for Oracle Developers ... you will see interesting Codes for SQL , PL/SQL as well as new ideas for Developer Suite and Client Tools that will help you in your professional life ... and I hope I reach for your satisfaction.

About Me

I'm Hany Freedom , 25 years old , I live in EL-Minia City in Egypt , I'm Moderator at ArabOUG.org the best Arabic Forum for ORACLE on the Net. if you interested to know more about me .... just Click Here.

Using the IF-THEN_ELSE and CASE Statement for Conditional Control


DECLARE

jobid employees.job_id%TYPE;

empid employees.employee_id%TYPE := 115;

sal employees.salary%TYPE;

sal_raise NUMBER(3,2);

BEGIN

SELECT job_id,

salary

INTO jobid,sal

FROM employees

WHERE employee_id = empid;



CASE

WHEN jobid = 'PU_CLERK' THEN IF sal < 3000 THEN

sal_raise := .12;

ELSE

sal_raise := .09;

END IF;

WHEN jobid = 'SH_CLERK' THEN IF sal < 4000 THEN

sal_raise := .11;

ELSE

sal_raise := .08;

END IF;

WHEN jobid = 'ST_CLERK' THEN IF sal < 3500 THEN

sal_raise := .10;

ELSE

sal_raise := .07;

END IF;

ELSE BEGIN

dbms_output.Put_line('No raise for this job: '

||jobid);

END;

END CASE;



UPDATE employees

SET salary = salary + salary * sal_raise

WHERE employee_id = empid;



COMMIT;

END;

/



Share/Save/Bookmark

0 comments:

Post a Comment



Newer Posts Older Posts Home Page
 
http://www.dpriver.com/images/sqlpp-banner-2.png

Thanks for reading my Blog ... you Visitor Number :-