oracle 数据库 包文件这样创建的
function pf_get_info(id in varchar2,
name out varchar2,
sex out varchar2,
birthdate out date,
cd_no out varchar2) return integer is
e_info_no_found exception;
begin
begin
select name,
decode(sex, '0', '男', '1', '女', '未知'),
birthdate,
nvl(cpr_no, '')
into rs_name, rs_sex, rdt_birthdate, rs_cd_no
from basic_info
where id = id;
exception
when NO_DATA_FOUND then
raise e_info_no_found;
end;
return 0;
--异常处理
exception
when e_info_no_found then
return - 1;
end pf_get_info;
python 使用 cx_Oracle.Cursor.callfunc(proc, returnType, [params]) 调用函数 ,out 为多种类型的多个参数该如何获取呢?我看网上都是返回一个值的函数调用,我的样例代码如下
import cx_Oracle
class HR:
def __enter__(self):
self.__db = cx_Oracle.Connection("user/123@//127.0.0.1:1521/ydyf")
self.__cursor = self.__db.cursor()
return self
def __exit__(self, type, value, traceback):
self.__cursor.close()
self.__db.close()
def pf_get_info(self,id):
l_rs_name = self.__cursor.var(cx_Oracle.STRING)
l_rs_sex = self.__cursor.var(cx_Oracle.STRING)
l_rdt_birthdate = self.__cursor.var(cx_Oracle.DATETIME)
l_rs_cd_no = self.__cursor.var(cx_Oracle.STRING)
# as_sick_id = self.__cursor.var(cx_Oracle.STRING)
self.__cursor.callfunc("PKG_HR.pf_get_info",cx_Oracle.NUMBER,[id])
return l_rs_name,l_rs_sex,l_rdt_birthdate,l_rs_cd_no
ggg=HR
id="2094"
l_rs_name,l_rs_sex,l_rdt_birthdate,l_rs_cd_no=ggg.pf_get_info(id)
1
renmu 2020-03-03 09:07:20 +08:00 via Android
a,b,c=function(),或者 a=function(),这样 a 的话是一个元组
|