j_param                     json;
jl_keys json_list; -- 创建json对象j_param
j_param := json(p_in_str);
-- 校验param域是否缺少必填参数
jl_keys := json_list('["userId","queryId", "tCardNo","cardNo","cardPwd"]');
if false = json_util_extra.containKeys(j_param, jl_keys) then
p_out_str := '{"resultCode":"30", "resultMsg":"param域Json缺少必填参数"}';
return;
end if;

创建package

create or replace package json_util_extra is
function containKeys(p_v1 json,
p_v2 json_list,
exact boolean default false) return boolean; function containEmptyValues(p_v1 json,
p_v2 json_list,
exact boolean default false) return boolean;
end json_util_extra;

创建 package body

create or replace package body json_util_extra is
function containKeys(p_v1 json, p_v2 json_list, exact boolean)
return boolean as
begin for i in 1 .. p_v2.count loop
if (not p_v1.exist(p_v2.get(i).get_string)) then
return false;
end if;
end loop; return true;
end; function containEmptyValues(p_v1 json, p_v2 json_list, exact boolean)
return boolean as
v_key varchar2(1024);
begin for i in 1 .. p_v2.count loop
v_key := p_v2.get(i).get_string; if (not p_v1.exist(v_key)) then
return false;
end if; if (p_v1.get(v_key).value_of is null) then
return false;
end if;
end loop; return true;
end; begin
-- Initialization
null;
end json_util_extra;
-- 获取字符串类型
json_ext.get_string(j_param, 'queryId');
-- 获取数字类型
json_ext.get_number(j_param, 'userId');    
-- 生成标准md5
CREATE OR REPLACE FUNCTION MD5(V_INPUT_STRING IN VARCHAR2) RETURN VARCHAR2 IS
BEGIN
RETURN LOWER(UTL_RAW.CAST_TO_RAW(DBMS_OBFUSCATION_TOOLKIT.MD5(INPUT_STRING => V_INPUT_STRING)));
END MD5;
-- select md5(1) from dual
v_sqltext := 'select e.card_type as "cardType",
case
when e.card_type=to_char('''') then to_char(''获得卡片'')
when e.card_type=to_char('''') then to_char(''购买'')
when e.card_type=to_char('''') then to_char(''查看卡密'')
when e.card_type=to_char('''') then to_char(''解绑'')
when e.card_type=to_char('''') then to_char(''送出'')
when e.card_type=to_char('''') then to_char(''取消赠送'')
when e.card_type=to_char('''') then to_char(''赠送退回'')
when e.card_type=to_char('''') then to_char(''获赠'')
when e.card_type=to_char('''') then to_char(''解绑找回'')
when e.card_type=to_char('''') then to_char(''提货申请'')
else to_char(''其它'') end "cardTypeName",
e.mark as "mark",
to_char(e.opt_date,''yyyy-mm-dd hh24:mi:ss'') as "optDate"
from (select d.*, rownum as rn
from (select ubcl.card_type,ubcl.mark,ubcl.opt_date
from xshe_user_band_card_log ubcl
where ubcl.user_id =' || v_user_id || '
and ubcl.card_no =''' ||v_card_no ||'''
and ubcl.status = 1 order by ubcl.opt_date asc,ubcl.id asc
) d
where rownum <= ' || v_end_rownum || ') e
where rn > ' || v_begin_rownum;
-- update huzhiyang 2019-10-14 10:38:47 ,卡号为字符串
-- 执行SQL语句并返回josn_list数据
jl_card_list := json_dyn.executeList(v_sqltext);
-- 拼接字符串时注意引号数量
-- 拼接json
p_out_str := '{"resultCode":"' || v_ret ||
'", "resultMsg":"' || v_des ||
'","page":"' || v_page ||
'","pageSize":"' || v_page_size ||
'","totalPage":"' ||v_total_page ||
'","totalCount":"' ||v_total_count ||
'",' || v_single_info || '}';
-- 打印输出错误信息
DBMS_OUTPUT.put_line('sqlcode : ' ||sqlcode);
DBMS_OUTPUT.put_line('sqlerrm : ' ||sqlerrm);
-- 创建数组
type card_no_tab is table of varchar2(2000) index by BINARY_INTEGER;
v_card_no_tab_info card_no_tab; v_card_no_tab_info(vv_count) := '{"cardNo":"' || r.cardNo ||
'","background":"' ||r.background || '"}';
for k in 1 .. vv_count loop
if k < vv_count then
v_single_info := v_single_info || v_card_no_tab_info(k) || ',';
else
v_single_info := v_single_info || v_card_no_tab_info(k);
end if;
end loop;

最新文章

  1. 浅谈angular2+ionic2
  2. Linux Distribution / ROM
  3. 使用VS Code开发 调试.NET Core 应用程序
  4. MVC文件上传和下载
  5. linux中授予普通用户root权限
  6. SharePoint 2013 搜索爬网功能
  7. TreeNode动态邦定事件
  8. 错误号码2003 Can&amp;#39;t connect to MySQL server &amp;#39;localhost&amp;#39; (0)
  9. Android 自定义View可拖动移动位置及边缘拉伸放大缩小
  10. 【AngularJS入门】用ng-repeat指令实现循环输出
  11. TCP/IP详解之:UDP协议
  12. C# List&lt;T&gt;中Select List Distinct()去重复
  13. phpcmsV9常用标签
  14. 【fhq Treap】bzoj1500(听说此题多码上几遍就能不惧任何平衡树题)
  15. 51 nod 1439 互质对(Moblus容斥)
  16. php禁用函数设置及查看方法详解
  17. .NET MVC 简单的插件式开发
  18. Jquery 一个页面单个倒计时 实现
  19. unicode 编解码记录
  20. jquery引入

热门文章

  1. Django 配置JWT验证
  2. Pyhon中迭代器与生成器
  3. css 关于&quot;浮动边距加倍&quot;及其解决方法-------解决方案是在这个div里面加上display:inline;
  4. Go 字符串使用
  5. Join 和 App
  6. flask的多个url对应同一个视图函数
  7. Python爬虫之用脚本登录Github并查看信息
  8. java - day010 - 基本类型包装,自动装箱和拆箱,日期,集合
  9. IDEA光标跟随原因是jdk载入的问题BUG 修正 需要I安装最新版本1.8JDK 1.9之后的不清楚 谨慎
  10. Java字节码方法表结构深度剖析