oracle 常用工具类及函数
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 常用工具类及函数的更多相关文章
- [C#] 常用工具类——加密解密类
using System; using System.Configuration; using System.Collections.Generic; using System.Text; using ...
- PHP常用工具类
<?php namespace isslib\Util; use think\Config; /** * 常用工具类 * User: xaxiong * Date: 2016/12/19 * T ...
- javascript常用工具类整理(copy)
JavaScript常用工具类 类型 日期 数组 字符串 数字 网络请求 节点 存储 其他 1.类型 isString (o) { //是否字符串 return Object.prototype.to ...
- JavaEE-实验一 Java常用工具类编程
该博客仅专为我的小伙伴提供参考而附加,没空加上代码具体解析,望各位谅解 1. 使用类String类的分割split 将字符串 “Solutions to selected exercises ca ...
- js常用工具类.
一些js的工具类 复制代码 /** * Created by sevennight on 15-1-31. * js常用工具类 */ /** * 方法作用:[格式化时间] * 使用方法 * 示例: * ...
- IOS开发--常用工具类收集整理(Objective-C)(持续更新)
前言:整理和收集了IOS项目开发常用的工具类,最后也给出了源码下载链接. 这些可复用的工具,一定会给你实际项目开发工作锦上添花,会给你带来大大的工作效率. 重复造轮子的事情,除却自我多练习编码之外,就 ...
- Apache Commons 常用工具类整理
其实一直都在使用常用工具类,只是从没去整理过,今天空了把一些常用的整理一下吧 怎么使用的一看就明白,另外还有注释,最后的使用pom引入的jar包 public class ApacheCommonsT ...
- Android 常用工具类之SPUtil,可以修改默认sp文件的路径
参考: 1. 利用Java反射机制改变SharedPreferences存储路径 Singleton1900 2. Android快速开发系列 10个常用工具类 Hongyang import ...
- 封装一个简单好用的打印Log的工具类And快速开发系列 10个常用工具类
快速开发系列 10个常用工具类 http://blog.csdn.net/lmj623565791/article/details/38965311 ------------------------- ...
随机推荐
- MSPBSL_Scripter编译
The BSL Scripter is a PC application that is available for Windows, Linux and Mac OS X. It is a user ...
- OpenCV手工实现灰度及RGB直方图
手工实现灰度及RGB直方图 !库 1. 灰度图像直方图 算法 1. 图片灰度化: 2. 遍历Mat,统计各灰度级的像素个数: 3. 根据opencv画点线函数,绘制坐标轴及像素分布图 源码(编译环境: ...
- 【SpringMVC】入门
一.概述 1.1 SpringMVC是什么 1.2 MVC在b/s系统的应用 1.3 SpringMVC 原理 二.入门程序 2.1 需求 2.2 引入依赖 2.3 前端控制器 2.4 springm ...
- Sliverlight/WPF 样式使用方法
1,UserControl 页面级样式: UserControl.Resources style setter Property value. TargetType为应用的类型 <UserCon ...
- API接口文档中将Swagger文档转Word 文档
一般的开发工作,尤其是API接口的开发工作,首先要有开发文档,接口说明文档 ok,后来开发完毕了 和页面联调,或者是和第三方联调的时候, 这个时候,SA systeam admin 就会开始直接让开发 ...
- Splay树详解
更好的阅读体验 Splay树 这是一篇宏伟的巨篇 首先介绍BST,也就是所有平衡树的开始,他的China名字是二叉查找树. BST性质简介 给定一棵二叉树,每一个节点有一个权值,命名为 ** 关键码 ...
- 数列分段`Section II`(二分
https://www.luogu.org/problemnew/show/P1182 洛谷上的题目. 以后如果遇到1e5什么的 用二分试试! #include<iostream> # ...
- i p _ i n s e r t o p t i o n s函数
i p _ o u t p u t函数接收一个分组和选项.当 i p _ f o r w a r d调用该函数时,选项已经是分组的一部分,所以 i p _ f o r w a r d总是把一个空选项指 ...
- Java集合--整体框架
Java集合是java提供的工具包,包含了常用的数据结构:集合.链表.队列.栈.数组.映射等.Java集合工具包位置是java.util.*Java集合主要可以划分为4个部分:List列表.Set集合 ...
- [HNOI2009] 有趣的数列——卡特兰数与杨表
[HNOI 2009] 我们称一个长度为2n的数列是有趣的,当且仅当该数列满足以下三个条件: (1)它是从1到2n共2n个整数的一个排列{ai}: (2)所有的奇数项满足a1<a3<…&l ...