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 ------------------------- ...
随机推荐
- jQuery事件绑定和委托实例
本文实例讲述了jQuery事件绑定和委托.分享给大家供大家参考.具体方法如下: jQuery事件的绑定和委托可以用多种方法实现,on() . bind() . live() . delegate ...
- CircularSlider半弧形滑动条
前言 这边文章主要 是写 一.半圆弧型滑块的设计 最近项目中需要用到半圆弧形滑块,其作用和UISlider差不多,用于拖动改变播放音乐的播放进度. 大概样子是这样的: 效果展示 特点如下: 滑动响应区 ...
- 如何用HAProxy+Nginx实现负载均衡
一.什么是HAProxy HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案.HAProxy特别适用于那些负载特大的web站点, ...
- vue作用域插槽
简而言之,作用域插槽就是让插槽内容能够访问子组件中的数据. 案例如下:有CurUser组件 <template> <span> <!-- 在slot 元素上绑定user, ...
- CentOS7安装CDH 第一章:CentOS7系统安装
相关文章链接 CentOS7安装CDH 第一章:CentOS7系统安装 CentOS7安装CDH 第二章:CentOS7各个软件安装和启动 CentOS7安装CDH 第三章:CDH中的问题和解决方法 ...
- Linux命令——umask、setuid、setgid、sticky bit、chmod、chown
umask 权限遮罩码,用于控制文件,文件夹的默认权限 文件默认权限: 666-umask 文件夹默认权限: 777-umask 管理员root: umask= ...
- Python使用selenium模拟点击,进入下一页(三)
嗯,昨天呢,我们已经实现了自动输入百度然后搜索Cgrain,然后点击按钮,进入我的页面,在这里呢,有个问题 ActionChains(seleniumGoo).move_by_offset(-480, ...
- Vue 一些用法
v-model : 数据绑定(多数用于表单元素) ps:同时v-model支持双向数据绑定v-for : 用于元素遍历v-on:事件名称=“方法名” (事件绑定)ps: methods:用于绑定 v- ...
- Sonya and Robots
1 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> ...
- 使用pyinstaller打包使用cx_Oracle模块的程序出现The specified module could not be found的问题
pyinstaller看起来并不会将动态链接库自动打包,所以我们需要告诉pyinstaller要打包哪些动态链接库,步骤如下(假设python文件名为 oracletest.py): 1. 使用pyi ...