CREATE OR REPLACE FUNCTION
CREATE OR REPLACE FUNCTION SF_Taishou_Ksai_Date(v_receiptNum IN CHAR,
v_his IN CHAR)
RETURN VARCHAR2 DETERMINISTIC IS
RESULT VARCHAR2(50);
v_result_t VARCHAR2(50);
v_tmp_code VARCHAR2(100);
v_uriage_sha_code VARCHAR2(50);
v_Adv_Sha_Code VARCHAR2(50);
v_Taishou_Ksai_Date date;
BEGIN
select *
INTO v_tmp_code, v_uriage_sha_code
from (select REPLACE(atom_concat(Ksai_Sha_Code), ',', ''),
tafd.uriage_sha_code
from TB_ADV_FEE_DETAIL tafd
where tafd.receipt_num = v_receiptNum
and tafd.his = v_his
group by tafd.receipt_num, tafd.his, tafd.uriage_sha_code)
where rownum = 1;
IF (INSTR(v_tmp_code, v_uriage_sha_code) = 0) THEN
IF (INSTR(v_tmp_code, '1') = 0) THEN
v_result_t := '';
ELSE
v_result_t := '1';
END IF;
IF (INSTR(v_tmp_code, '2') = 0) THEN
v_result_t := v_result_t || '';
ELSE
v_result_t := v_result_t || '2';
END IF;
IF (INSTR(v_tmp_code, '3') = 0) THEN
v_result_t := v_result_t || '';
ELSE
v_result_t := v_result_t || '3';
END IF;
IF (INSTR(v_tmp_code, '4') = 0) THEN
v_result_t := v_result_t || '';
ELSE
v_result_t := v_result_t || '4';
END IF;
IF (INSTR(v_tmp_code, '5') = 0) THEN
v_result_t := v_result_t || '';
ELSE
v_result_t := v_result_t || '5';
END IF;
v_uriage_sha_code := substr(v_result_t, 0, 1);
END IF;
/**対象掲載日*/
SELECT Ksai_Date, Adv_Sha_Code
INTO v_Taishou_Ksai_Date, v_Adv_Sha_Code
FROM TB_ADV_FEE_DETAIL
WHERE Receipt_Num = v_receiptNum
AND His = v_his
AND Ksai_Sha_Code = v_uriage_sha_code
AND rownum = 1;
IF (v_Taishou_Ksai_Date = null) THEN
v_Taishou_Ksai_Date := sysdate;
END IF;
/**広告会社名略2 Adv_Sha_Name_Ryaku2*/
SELECT Adv_Sha_Name_Ryaku2
INTO RESULT
FROM TB_ADV_SHA
WHERE Adv_Sha_Code = v_Adv_Sha_Code
AND v_Taishou_Ksai_Date between Apply_Start_Date and Apply_End_Date;
RETURN(RESULT);
END SF_Taishou_Ksai_Date;
/*SELECT BEFORE HOSEI*/
select tafd.Adv_Sha_Name,
SF_Taishou_Ksai_Date(tafd.receipt_num, tafd.his),
tafd.*
from TB_ADV_FEE_DETAIL tafd
where tafd.Adv_Sha_Name <>
SF_Taishou_Ksai_Date(tafd.receipt_num, tafd.his)
/*HOSEI SQL*/
update TB_ADV_FEE_DETAIL tafd
set tafd.Adv_Sha_Name = SF_Taishou_Ksai_Date(tafd.receipt_num, tafd.his),
tafd.Del_Per_Code = 'founder'
where tafd.Adv_Sha_Name <>
SF_Taishou_Ksai_Date(tafd.receipt_num, tafd.his),
/*SELECT AFTER HOSEI*/
select tafd.Adv_Sha_Name,
SF_Taishou_Ksai_Date(tafd.receipt_num, tafd.his),
tafd.*
from TB_ADV_FEE_DETAIL tafd
where tafd.Adv_Sha_Name <>
SF_Taishou_Ksai_Date(tafd.receipt_num, tafd.his),
and tafd.Del_Per_Code = 'founder';
/*CLEAR HOSEI FLG*/
update TB_ADV_FEE_DETAIL tafd
set tafd.Del_Per_Code = null
where tafd.Del_Per_Code = 'founder';
/*HOSEI SQL*/
CREATE OR REPLACE FUNCTION的更多相关文章
- GreenPlum学习笔记:create or replace function创建函数
原始表数据如下: 需求:现要求按分号“;”将rate_item列进行分割后插入到新的数据表中. CREATE OR REPLACE FUNCTION fun_gp_test_xxx_20181026( ...
- 新建体(2):create or replace object创建存储包、存储过程、函数
http://heisetoufa.iteye.com/blog/366957/ 创建一个package(包) 声明: create or replace package mpay_route is ...
- orcle自定义类型type/create or replace type
一.type / create or repalce type 区别联系 相同: 可用关键字create type 或者直接用type定义自定义类型, 区别: create type 变量 as ta ...
- How to create DB2 user function easily by DB Query Analyzer 6.03
How to create DB2user function easily by DB Query Analyzer 6.03 Ma Genfeng (Guangdong Unitoll Servic ...
- Azure - Create your first function using Visual Studio
Azure Functions lets you execute your code in a serverless environment without having to first creat ...
- MySQL 5.7 create VIEW or FUNCTION or PROCEDURE
1.视图 a. CREATE ALGORITHM = UNDEFINED DEFINER = `root`@`localhost` SQL SECURITY INVOKER VIEW `sakila` ...
- How can I create an Asynchronous function in Javascript?
哈哈:)我的codepen 的代码笔记是:http://codepen.io/shinewaker/pen/eBwPxJ --------------------------------------- ...
- learning scala How To Create Variable Argument Function - varargs :_ *
Scala collection such as List or Sequence or even an Array to variable argument function using the s ...
- behavior planning——11 create a cost function speed penalty
A key part of getting transitions to happen when we want them to is the design of reasonable cost ...
随机推荐
- day37 05-HIbernate二级缓存:一级缓存更新同步到二级缓存及二级缓存配置文件
一级缓存的更新会自动同步到二级缓存. @SuppressWarnings("all") @Test // 将内存中的数据写到硬盘 public void demo7(){ Sess ...
- 如何制作可以在 MaxCompute 上使用的 crcmod
之前我们介绍过在 PyODPS DataFrame 中使用三方包.对于二进制包而言,MaxCompute 要求使用包名包含 cp27-cp27m 的 Wheel 包.但对于部分长时间未更新的包,例如 ...
- 【Codeforces Round #430 (Div. 2) B】Gleb And Pizza
[链接]点击打开链接 [题意] 在这里写题意 [题解] 根据圆心到原点的距离这个东西判断一下圆在不在那个环里面就好 [错的次数] 0 [反思] 在这了写反思 [代码] #include <cst ...
- arcgis几何对象
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 使用mpvue开发github小程序总结
前言 最近有点闲,想起关注已久的mpvue写小程序,所以稍微肝了半个多月写了个github版的微信小程序,已上线.现在总结一下遇到的坑. 扫码体验. 项目地址.https://github.com/c ...
- phpcms 允许英文目录有空格
大家都用过phpcm添加栏目吧,在添加栏目里面,有个选项是 英文目录,这里目录可以用作伪静态功能.这么英文不能有空格等特殊字符.但是如果页面中需要引用包含空格的字符呢,例如,关于我们页面,我要显示英文 ...
- placeholder颜色更改
::-webkit-input-placeholder { /* WebKit browsers */ color:#999; } :-moz-placeholder { /* Mozilla Fir ...
- 大数据心法来了!一站式玩转MaxCompute,还有开发者资源等你领!
阿里云大数据计算平台开发者版2019年3月推出,MaxCompute正在成为开发者的免费大数据平台.今天,MaxCompute在企业构建自己的数据处理平台实践中起到了至关重要的作用,我们特别精选了企业 ...
- Codeforces 404B
毫无疑问这题不是难题,但是这种题目最让人纠结 打心里对这种题目就比较害怕,果然,各种WE 这里贴上代码,用Python写的,比较偷懒: def cur_pos(a, d): if 0 <= d ...
- PostgreSQL 给数组排序
PostgreSQL 支持数组,可是没有对数据内部元素进行排序的一个函数. 今天我分别用PLPGSQL和PLPYTHONU写了一个.演示样例表结构: t_girl=# \d test_array; ...