函数写法:
create or replace function f_getGoodsKuChun(gdId in varchar2)
return varchar2
as
v_gd_ismany varchar2(1);
v_gd_id_child varchar2(32);
v_amount_num number(12,2);
v_yw_num number(12,2); --业务数量
v_min_num number(12,2);
type refcur_type is REF CURSOR;
pcur refcur_type;
begin
v_gd_ismany := '0';
v_yw_num:=0;
v_amount_num:=0;
select t.GD_ISMANY into v_gd_ismany from t_ec_goods2 t where t.gd_id = gdId;
if v_gd_ismany='1' then --组合商品
open pcur for
select gd_id_child,cd_amount from t_ec_goodschild where gd_id=gdId order by cd_row;
loop
fetch pcur into v_gd_id_child,v_amount_num;
if pcur%notfound then
return v_min_num;
exit;
end if;
select sum(nvl(GD_SL,0) - nvl(frozen_amount,0) - nvl(out_amount,0)) into v_yw_num
from t_jxc_kc_factstock f,t_jxc_da_storeroom s
where f.gd_id=v_gd_id_child
and f.room_bm=s.room_bm and s.room_yn='Y';
v_amount_num := FLOOR(v_yw_num/v_amount_num);
if v_min_num is null then
v_min_num := v_amount_num;
else
if v_amount_num < v_min_num then
v_min_num := v_amount_num;
end if;
end if;
end loop;
Close pcur;
else --普通商品
select sum(nvl(f.GD_SL,0) - nvl(f.frozen_amount,0) - nvl(f.out_amount,0)) into v_min_num
from t_jxc_kc_factstock f,t_jxc_da_storeroom s
where f.room_bm = s.room_bm and s.room_yn = 'Y' and f.gd_id = gdId;
end if;
return v_min_num;
end f_getGoodsKuChun;
Java中调用函数的代码:
public int checkKucun(String gdId) {
Connection con = null;
CallableStatement ps = null;
int re = 0;
try {
con = commerceDao.getCurrentConnection();
// 调用存储过程
ps = con.prepareCall("{?=call f_getGoodsKuChun(?)}");
ps.registerOutParameter(1, Types.INTEGER);
ps.setString(2, gdId);
// 执行
ps.execute();
// 获得输出结果
re = ps.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
} catch (SQLException e1) {
e1.printStackTrace();
}
}
return re;
}
分享到:
相关推荐
Java通过JNI调用C函数Demo 需要的人下载看看
SDK的demo程序,以及基于此SDK上将成员函数作为回调函数demo.
hive自定义函数demo
npapi 插件 js页面调用插件函数Demo
c#的基础知识部分,关于构造函数的相关知识。具体见http://www.cnblogs.com/imstrive/p/8763581.html
CPP调用JAVA函数Demo 需要的可以下载来看看
C++精选代码库。包含常用STL容器模拟实现、algorithm算法头文件函数demo
日常处理数据可以用到的函数,财务工作、日常办公、软件测试工作都可以用到
只是回调函数一个基本的demo,诠释了回调的定义和外部调用,数据传输的过程
时间转换demo,能计算用户浏览器时区,时区时间转换,计算昨天、今天、前天
回调函数在安卓中的使用,简单明了,一个demo入门了解回调机制
回调函数,简易、明了;介绍了如何定义,如何使用
QT中调用dll中的函数,3种方式demo, 1、采用显示链接,调用DLL中全局函数 2、采用显示链接,调用C++类中的类对象、成员函数 3、采用隐式链接方法,通过QLibrary类对DLL中类对象、全局函数的调用
基于 VC++6.0 实现动态库回调函数示例
计算来自所有线性阵元的接收响应,并绘制该响应以及叠加响应
这是使用 CEF 开发时 JavaScript 调用 C++ 函数的例子,详细步骤请见博客文章 http://blog.csdn.net/blackwoodcliff/article/details/78598262
指针函数的一个小demo,指针函数就是函数,返回类型为指针型。
VC MFC 多窗口消息共享同一个消息处理函数。
NULL 博文链接:https://zcw-java.iteye.com/blog/1926045