1. Create a process to add a new record to the table dept. (In parameters)
Creation process:
createorreplaceprocedure Insert_dept
( num_dept in number
,v_ename in varchar3)isbegininsertinto dept
values(num_dept,v_ename);commit;end insert_dept;
transfer:
begin
insert_dept(66,'人事');end;
2. Query from scott.emp given in the table staff (Hint: Use & to input employee number) names and salaries of employees. (Requirements: out mode using parameter values to the caller.)
Creation process:
createorreplaceprocedure query_emp
(num_empno in emp.empno%type,emp_name out emp.ename%type,emp_salary out emp.sal%type)isbeginselect ename,sal into emp_name,emp_salary
from emp where empno = num_empno;
exception
when no_data_found then
dbms_output.put_line('查询错误');end query_emp;
3. Create a process, in the implementation of the calling process, randomly enter the name of an employee in the emp table, according to the employee's name, the return value of the employee's salary, and output. (Out parameters)
Creation process:
createorreplaceprocedure select_emp
(emp_name in emp.ename%type,emp_salary out emp.sal%type)isbeginselect sal into emp_salary from emp
where ename = emp_name;
exception
when no_data_found then
dbms_output.put_line(‘查询错误’);end select_emp;
4. The preparation process, implement the functions of the exchange value of two variables. Two output values before and after the switching and exchange. (In out parameters)
declare
a number:=666;
b number:=999;begin
dbms_output.put_line('Befor:'||a||' '||b);
swap_number(a,b);
dbms_output.put_line('Now:'||a||' '||b);end;
5. Create a stored procedure, remove scott.emp table records the employee number. (Hint: employee number provided by the caller statement to delete records, requires that employee numbers be random input.).
Creation process:
createorreplaceprocedure delete_emp
(emp_no dept.empno%type)isbeginDeletefrom dept where empno = emp_no;end delete_emp;