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 ------------------------- ...
随机推荐
- Templates/Code Combinations
Queries: Templates/Code Combinations sql>select * from gl_dynamic_summ_combinations where CODE_ ...
- MySQL主从复制以及在本地环境搭建
MySQL主从复制原理: master(主服务器),slave(从服务器) MySQL master 将数据变更写入二进制日志( binary log, 其中记录叫做二进制日志事binary log ...
- 使用MySQL审计Plugin
本文来源:http://blog.chinaunix.net/uid-20785090-id-5018977.html 越来越多的企业把应用往mysql上迁移,这时候对数据库的审计又成了一件紧急的事情 ...
- 爬虫如何发现更多的url呢,怎么动态收集新的url连接
大家在做爬虫采集数据的时候很多都会遇到增量采集的问题,有些时候是通过过滤url来进行的,有些是通过爬取网页后再进行分析判断, 以上这些过程也许大部分做爬虫的都会这么做,各位有没有想过, 除了以上的常用 ...
- VM虚拟机?
虚拟机(Virtual Machine)指通过软件模拟的具有完整硬件系统功能的.运行在一个完全隔离环境中的完整计算机系统. 虚拟系统通过生成现有操作系统的全新虚拟镜像,它具有真实windows系统完全 ...
- 【JavaWeb】通过邮件找回密码
前言 本文将介绍忘记密码时通过发送重置密码邮件找回密码的实现思路.整个实现过程中最重要的就是以下三点: 如何发送邮件到用户指定邮箱 邮件中的重置密码链接构成是怎么样的 验证重置密码链接的合法性(是否过 ...
- Vue 循环 [Vue warn]: Avoid using non-primitive value as key
页面中不添加 :key 索引的时候,会不停的提示虚线,但不影响使用 后来加了一个索引,加成了:key= "content" 从后台取出来的contents是一个list,里面有多 ...
- Bert-util安装
转载:https://blog.csdn.net/u013109501/article/details/91987180 https://blog.csdn.net/Vancl_Wang/articl ...
- 【H5】 经纬度位置获取navigator.geolocation.getCurrentPosition
navigator.geolocation.getCurrentPosition(function(){})经度 : coords.longitude 纬度 : coords.latitude 准确度 ...
- ACM-ICPC 2018 南京赛区现场赛 E. Eva and Euro coins (思维)
题目链接:https://codeforc.es/gym/101981/attachments 题意:给出两个只包含01的字符串,每次可以选择连续k个相同的数字进行翻转,问能否通过若干次操作把两个字符 ...