DECLARE
wages NUMBER;
hours_worked NUMBER := 40;
hourly_salary CONSTANT NUMBER := 17.50; -- constant value does not change
country VARCHAR2(64) := 'UNKNOWN';
unknown BOOLEAN;
TYPE comm_tab IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
commissions COMM_TAB;
TYPE jobs_var IS VARRAY(10) OF employees.job_id%TYPE;
jobids JOBS_VAR;
CURSOR c1 IS
SELECT department_id
FROM departments; -- cursor declaration
deptid departments.department_id%TYPE;
emp_rec employees%ROWTYPE; -- do not need TYPE declaration in this case
BEGIN
/* the following are examples of assignment statements */
wages := hours_worked
* hourly_salary; -- compute wages
country := Upper('italy');
unknown := (country = 'UNKNOWN');
Commissions(5) := 20000
* 0.15;
Commissions(8) := 20000
* 0.18;
jobids := Jobs_var('ST_CLERK');
jobids.Extend(1);
Jobids(2) := 'SH_CLERK';
OPEN c1;
FETCH c1 INTO deptid;
CLOSE c1;
emp_rec.department_id := deptid;
emp_rec.job_id := Jobids(2);
END;
/
Declaring and Assigning Values to Variables
0 comments:
Post a Comment