wrap用法

本文介绍了一个用于Oracle数据库的SQL函数get_deptno的创建与调用过程,该函数根据部门编号返回部门名称,并展示了如何通过SQL*Plus进行操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

get_deptno.sql:

create or replace function get_deptno
(p_deptno in varchar2)
return varchar2
is
p_deptname     varchar2(10);          
begin
 select dname into p_deptname from dept where deptno = p_deptno;
 return p_deptname ;
end;         
/

select get_deptno(20) from dual

wrap iname=get_deptno.sql oname=get_deptno.plb

drop function get_deptno;

@get_deptno.plb;

select get_deptno(20) from dual;


/////////////////////////////////////////////////////////////////

ora10glin->ls
Desktop  get_deptno.sql
ora10glin->sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Nov 27 11:54:28 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL> conn scott/tiger
Connected.
SQL> @get_deptno.sql;

Function created.

ora10glin->wrap iname=get_deptno.sql oname=get_deptno.plb

PL/SQL Wrapper: Release 10.2.0.1.0- Production on Fri Nov 27 11:55:22 2009

Copyright (c) 1993, 2004, Oracle.  All rights reserved.

Processing get_deptno.sql to get_deptno.plb
ora10glin->ls
Desktop  get_deptno.plb  get_deptno.sql
ora10glin->cat get_deptno.plb
create or replace function get_deptno wrapped
a000000
1
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
8
c7 c2
OT3ACF+2ruL4CpD94I6vluqVGPkwgy7cf8vWZ3QebuowRjsBADJTGURXvdOO5toztZ1NTcs3
SdotYv4TFJbFBLSdWB8fY8kmdOmlSqfUEUwM1LwxQg7CCSrUWC2GMCrQEv24rId6jqjYelLA
XaoO49XRRO0pX0zugsJ//EbB7rNnTbbRJmdWrWg/T69/dw==

/

SQL> drop function get_deptno;

Function dropped.

SQL> @get_deptno.plb;

Function created.

SQL> select get_deptno(20) from dual
  2  ;

GET_DEPTNO(20)
--------------------------------------------------------------------------------
RESEARCH


/////////////////////////////////////////////////////////////////
如果出现如下错误:

kgepop: no error frame. to pop to for error 1801


则需要设置正确的环境变量:NLS_LANG
例如在WIndows下可以如下设置:
C:/oracle/ora92/bin>set NLS_LANG=CHINESE_CHINA.ZHS16GBK(根据具体环境确定)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值