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;

oracle 常用工具类及函数的更多相关文章

  1. [C#] 常用工具类——加密解密类

    using System; using System.Configuration; using System.Collections.Generic; using System.Text; using ...

  2. PHP常用工具类

    <?php namespace isslib\Util; use think\Config; /** * 常用工具类 * User: xaxiong * Date: 2016/12/19 * T ...

  3. javascript常用工具类整理(copy)

    JavaScript常用工具类 类型 日期 数组 字符串 数字 网络请求 节点 存储 其他 1.类型 isString (o) { //是否字符串 return Object.prototype.to ...

  4. JavaEE-实验一 Java常用工具类编程

    该博客仅专为我的小伙伴提供参考而附加,没空加上代码具体解析,望各位谅解 1.  使用类String类的分割split 将字符串  “Solutions to selected exercises ca ...

  5. js常用工具类.

    一些js的工具类 复制代码 /** * Created by sevennight on 15-1-31. * js常用工具类 */ /** * 方法作用:[格式化时间] * 使用方法 * 示例: * ...

  6. IOS开发--常用工具类收集整理(Objective-C)(持续更新)

    前言:整理和收集了IOS项目开发常用的工具类,最后也给出了源码下载链接. 这些可复用的工具,一定会给你实际项目开发工作锦上添花,会给你带来大大的工作效率. 重复造轮子的事情,除却自我多练习编码之外,就 ...

  7. Apache Commons 常用工具类整理

    其实一直都在使用常用工具类,只是从没去整理过,今天空了把一些常用的整理一下吧 怎么使用的一看就明白,另外还有注释,最后的使用pom引入的jar包 public class ApacheCommonsT ...

  8. Android 常用工具类之SPUtil,可以修改默认sp文件的路径

    参考: 1. 利用Java反射机制改变SharedPreferences存储路径    Singleton1900 2. Android快速开发系列 10个常用工具类 Hongyang import ...

  9. 封装一个简单好用的打印Log的工具类And快速开发系列 10个常用工具类

    快速开发系列 10个常用工具类 http://blog.csdn.net/lmj623565791/article/details/38965311 ------------------------- ...

随机推荐

  1. windows下监控进程的脚本

    相信大家都有这样的需求,某程序(进程)在运行的时候可能挂掉,需要去监控该程序,并在它挂掉的时候重启之,确保该程序能一直运行.比如土net就经常挂,需要监控程序去监控.Linux下面似乎有守护进程的概念 ...

  2. HTML中关于 浮动 的简单说明

    1.首先,标签之所以有存在等级分类,是因为他们处于标准文档流(块级元素,行内元素,行内块元素)当中. 2.如何脱离标准文档流? 浮动 绝对定位 固定定位 这些可以让一个标签脱离标准文档流,而元素一旦脱 ...

  3. 3.Java集合-HashSet实现原理及源码分析

    一.HashSet概述: HashSet实现Set接口,由哈希表(实际上是一个HashMap实例)支持,它不保证set的迭代顺序很久不变.此类允许使用null元素 二.HashSet的实现: 对于Ha ...

  4. Netty UDP 使用采坑

    使用Netty搭建UDP服务收集日志,使用过程中发现,部分日志接收不到,排查发现,都是大日志记录不到,后查询相关文档进行如下修改 EventLoopGroup workerGroup = new Ni ...

  5. 我用Python爬虫挣钱的那点事

    在下写了10年Python,期间写了各种奇葩爬虫,挣各种奇葩的钱,写这篇文章总结下几种爬虫挣钱的方式. 1.最典型的就是找爬虫外包活儿.这个真是体力活,最早是在国外各个freelancer网站上找适合 ...

  6. Const *ptr ptr

    1. const int *ptr = NULL; <=> int const *ptr = NULL; 1) 表示指向符号常量的指针变量,指针变量本身并非const所以可以指向其他变量. ...

  7. Octave基本语法

    基本运算 octave:3> 5+6 ans = 11 octave:4> 3-2 ans = 1 octave:5> 8*9 ans = 72 octave:6> 8/4 a ...

  8. Unknown initial character set index '255' received from server. Initial client character 解决方法

    Unknown initial character set index '255' received from server. Initial client character set can be ...

  9. Spring Bean装配(上)

    Bean:在spring的IOC里面,把配置到IOC容器里面的实体或者是对象都称为Bean Bean配置项 Bean的作用域 Bean的生命周期 Bean的自动装配 Resources&Res ...

  10. Linux使用帮助详解

    主要内容:                    whatis                    command --help                     man and info   ...