2、;BEGIN SELECT quantity INTO qty_on_hand FROM inventory WHERE product = 'TENNIS RACKET' FOR UPDATE OF quantity; IF qty_on_hand > 0 THEN -- check quantity UPDATE inventory SET quantity = quantity - 1 WHERE pr
3、oduct = 'TENNIS RACKET'; INSERT INTO purchase_record VALUES ('Tennis racket purchased', SYSDATE); ELSE INSERT INTO purchase_record VALUES ('Out of tennis rackets', SYSDATE); END IF; COMMIT;END;在PL/SQL中,可以使用SQL语句来操作Oracle中的数据,并使用流程控制语句来
7、SE;bonus := current_salary * 0.10;wages := gross_pay(emp_id, st_hrs, ot_hrs ) - deductions;第二种,利用数据库中查询的结果为变量赋值:SELECT sal * 0.10 INTO bonus FROM emp WHERE empno = emp_id;第三种,
8、把变量作为一个OUT或INOUT模式的参数传递给子程序,然后由子程序为其赋值。如下例所示,INOUT参数可以为被调用的子程序传递初始值然后子程序将更新后的新值返回给调用程序:DECLARE my_sal REAL(7,2); PROCEDURE adjust_salary (emp_id INT, salary IN OUT REAL) IS ...BE