How to create Function/Procedure in Oracle?
2007-06-01 15:18
429 查看
create or replace function Fun_FindNameAndDept
(
/*
Date: Liu JueJue @ June 1, 2007 14:50
Summary: 根据职员ID查找其姓名和所在科室,中间用标志 ‘*’ 隔开
*/
V_EmployeeID number -- Ö°Ô±ID
)
return varchar2
as
DepartmentName Varchar2(100); -- 职员ID
EmployeeName varchar2(100); -- 职员姓名
Begin
DepartmentName := '未知';
EmployeeName := '未知';
select name into EmployeeName from base_employee_property t where t.employee_id = V_EmployeeID;
if EmployeeName <> '未知' then
select ( select l.name from base_dept_property l where l.dept_id = k.dept_id ) into DepartmentName from base_emp_dept_role k where k.employee_id = V_EmployeeID;
end if;
EmployeeName := EmployeeName || '*' || DepartmentName;
return EmployeeName;
End;
create or replace procedure test_20070601_1
(
V_ID In varchar2,
c Out pa_test_20070601.c_sr
/*
create or replace package pa_Test_20070601
is
type c_sr is ref cursor;
end;
*/
)
as
/*
here for define local variables
*/
Begin
open c for
select * from sr_itemtype s where s.id = V_ID;
exception
when others then
rollback;
RAISE_APPLICATION_ERROR(-20001, '查询出错' );
End;
相关文章推荐
- [ASP.NET2.0][数据库更新]How to troubleshoot 'Procedure or function has too many arguments specified' in asp.net 2.0
- [置顶] How to create Oracle 11g R2 database manually in ASM?
- How to use Oracle 11g ODP.NET UDT in an Oracle Stored Procedure's Where clause
- How to Use a Function or a Procedure as a Parameter in another Function
- How To Use a DataReader Against an Oracle Stored Procedure in Visual C# .NET
- How to create a File-Compare function in Visual C#
- How to use Oracle 11g ODP.NET UDT in an Oracle Stored Procedure's Where clause
- How to debug stored procedure/function in TOAD
- How to create function polymorphism in C
- Learn How To Create Trigger In Oracle Forms
- How to troubleshoot 'Procedure or function has too many arguments specified' in asp.net 2.0
- How to create Oracle 11g R2 database manually in ASM?
- Know How To Use ID_NULL Function To Search An Object In Oracle Forms
- How to create Oracle ASM devices using device-mapper multipath devices in Red Hat Enterprise Linux 6
- How to call Oracle function or stored procedure using spring persistence framework?
- How To Collect Diagnostic Data to Troubleshoot Create Accounting in Oracle Assets?
- How to create a function in SQL
- How to create a PictureMarkerSymbol (Picture Symbol)in ArcGIS server with C#
- How to change the language of oracle sqlplus from chinese to english in windows(如何将oracle sql plus中的中文变成英文版)
- How to Use Oracle Restart in Oracle 11gR2