zjyself 2013-09-05 06:21 采纳率: 100%
浏览 11067
已采纳

sql语句查询存储过程的内容

我是用的oracle数据库 在pl/sql中使用select text from user_source where name='pro_emp';语句查找存储过程的内容结果查出来是空的,换了DBA角色也不行,最后我把text换成*,却查出来了,郁闷。。。。。求解
还有一个问题:我创建的包和包体在右边的packages的文件树形结构下的图标上面都有一个红色的叉号,编译的时候没有错误调用包,提示创建的包无效。。。这是哪里错了?
--包
create or replace package my_pkg is
pragma serially_reusable;
v_sqlcode number;
v_sqlerrm varchar2(2048);
function add_dept(v_deptno number,v_dname varchar2,v_loc varchar2)return number;
function cntdept(v_deptno varchar2);
procedure read_dept;
end my_pkg;

--包体
create or replace package body my_pkg
is
pragma serially_reusable;
v_flag number;
cursor c_mvcursor is select * from dept;
mvcursor c_mvcursor%rowtype;
function cntdeptno(v_deptno dept.deptno%type)
is
begin
select count(*) into v_flag from dept where deptno=v_deptno;
if v_flag>0 then
v_flag:=1;
else
v_flag:=0;
end if;
return v_flag;
end cntdeptno;
function add_dept(v_deptno number,v_dname,varchar2(10),v_loc varchar2(20))
is
begin
if cntdeptno(v_deptno)=0 then
insert into dept values(v_deptno.v_dname,v_loc);
return 1;
else
return 0;
end if;
exception
when others then
v_sqlcode := sqlcode;
v_sqlerrm := sqlerrm;
return -1;
end add_dept;
procedure read_dept
is
begin
for c_mvcursor in mvcursor loop
v_deptno := c_mvcursor.deptno;
v_dname := c_mvcursor.dname;
dbms_output.put_line(v_deptno||' '||v_dname);

end loop;
end read_dept;
end my_pkg;
--调用包
declare
adddept number;
begin
adddept := my_pkg.add_dept(50,'dept1','loc1');
end;

  • 写回答

1条回答 默认 最新

  • WZz_ 2013-10-14 02:19
    关注

    1、select text from user_source where name='pro_emp' 和 select * 应该都是可以的,不过你得注意一下'pro_emp'的大小写的问题,在数据库里面可能是默认大写存的。
    2、你的function cntdept(v_deptno varchar2);函数,在包体里面是不是错了?function cntdeptno(v_deptno dept.deptno%type)??

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?