Beruflich Dokumente
Kultur Dokumente
PL/SQL
Procedural Language/Structural Query Language
PL/SQL Procedures
Kamran.Munir@niit.edu.pk
Use of
IN OUT
Example:
Example:
Input
3009504455
Output
(300)950 - 4455
Procedure created.
Declaring variable
Execute Procedure
?
Procedure Execution/OUTPUT
SQL> execute show_summary(10);
Total Number of employees are = 3
Salary Average = 2916.666666666666
Salary Total = 8750
Maximum Salary = 5000
Minimum Salary = 1300
?
Positional
List values in the order in which the parameters are
declared.
Named
List values in arbitrary order, using parameter name.
Combination
We can also use combination of both above.
Example
create or replace procedure add_emp
(v_empno in emp.empno%type
emp.empno%type,,
v_deptno in emp.deptno%type
emp.deptno%type,,
v_ename in emp.empno%type DEFAULT UNKNOWN)
is
begin
insert into emp(empno,deptno,ename
emp(empno,deptno,ename))
values(v_empno,, v_deptno
values(v_empno
v_deptno,, v_ename
v_ename);
);
end;
?
Procedure created.
Positional
SQL> add_emp (1234, 10, TOM);
Named
SQL> add_emp (v_derpno => 10 , v_empno =>1234,
v_ename = > TOM);
SQL> add_emp (v_derpno => 10 , v_empno =>1234)
Combination
SQL> add_emp (1234, v_derpno => 10 );
Procedure Call
Inside procedure
End;
Drop Procedure
Syntax
SQL> Drop procedure <procedure_name
<procedure_name>;
>;
SQL/PLSQL Tips
?
SQL/PLSQL Tips
SQL/PLSQL Tips
Example
SQL> select level, max(sal) from emp
where level = '&n' connect by prior (sal) >
sal
group by level
NULL');
end if;
end;
Privilege
Description
Select
Insert
Ability to add new rows to the table with the insert statement.
Update
Delete
Ability to delete rows from the table with the delete statement.
Ability to change the table definition with the alter table statement.
SQL/PLSQL Tips
SQL/PLSQL Tips
For example, if you wanted to grant select, insert, update, and delete
privileges on a table called suppliers to a user name smithj
smithj,, you would
execute the following statement:
You can also use the all keyword to indicate that you wish all
permissions to be granted. For example:
If you wanted to grant select access on your table to all users, you
could grant the privileges to the public keyword. For example:
SQL/PLSQL Tips
SQL/PLSQL Tips
10
Thanks
Kamran.Munir@niit.edu.pk
11