查询包中子程序的参数
对于一个数据库开发人员来说,知道存储过程、函数中有哪些参数是比较重要的。
可以通过user_arguments来获取相关信息:
可以通过user_arguments来获取相关信息:
--统计当前用户下有哪些存储过程、函数、触发器,其中有哪些参数(包括返回值)
--提示:需要考虑重载,根据overload列判断
--user_arguments中函数有一行position=0的记录,而存储过程则没有。
--该特性可以作为判断存储过程和函数的区分条件。
select t.package_name,t.object_name,
case
when t.position=0 and t.argument_name is null then 'OUTPUT_VALUE_OF_FUNCTION'
when t.position=1 and t.argument_name is null and t.in_out='IN' then '\'
else t.argument_name
end "PARAMETER_NAME",
t.position,
case when t.overload is not null then '重载'||t.overload
else null
end OVERLOAD,
t.data_type,t.data_length "DATA_LENGTH",t.in_out "IN_OUT"
from sys.user_arguments t
where t.package_name is not null
order by 1,2,4
--提示:需要考虑重载,根据overload列判断
--user_arguments中函数有一行position=0的记录,而存储过程则没有。
--该特性可以作为判断存储过程和函数的区分条件。
select t.package_name,t.object_name,
case
when t.position=0 and t.argument_name is null then 'OUTPUT_VALUE_OF_FUNCTION'
when t.position=1 and t.argument_name is null and t.in_out='IN' then '\'
else t.argument_name
end "PARAMETER_NAME",
t.position,
case when t.overload is not null then '重载'||t.overload
else null
end OVERLOAD,
t.data_type,t.data_length "DATA_LENGTH",t.in_out "IN_OUT"
from sys.user_arguments t
where t.package_name is not null
order by 1,2,4
在我的测试环境中运行后的结果见图片“查询结果(temp.JPG)”
可以看到存储过程pck_emp.p2的参数vc_enamelst数据类型是table,而与其位置对应的有一个空参数。这是由于vc_enamelst声明的是一个集合类型,
该集合的类型为table of varchar2(50).
该集合的类型为table of varchar2(50).
以上语句虽然可以大致得到各个包中子程序的参数,但对于集合类型的参数,显示的信息不够准确。需要改进。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26451536/viewspace-768330/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26451536/viewspace-768330/