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 ...
随机推荐
- java-继承进阶_抽象类_接口
概要图 一, 继承的进阶 1.1,成员变量 重点明确原理. 特殊情况: 子父类中定义了一模一样的成员变量. 都存在于子类对象中. 如何在子类中直接访问同名的父类中的变量呢? 通过关键字 super来完 ...
- PHP配置环境中如何开启伪静态
1.在httpd.conf中引入httpd-vhosts.conf 2.在httpd.conf中开启mod_rewrite.so 3.在httpd-vhosts.conf中配置虚拟主机 AllowOv ...
- vue学习之组件(component)(一)
组件 (Component) 是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码.在较高层面上,组件是自定义元素,Vue.js 的编译器为它添加特殊功能.在有些情况下, ...
- 【纯手工】整理豆瓣热点推荐列表-财经&自我管理
[纯手工]整理豆瓣热点推荐列表-财经&自我管理 简七君 2013-10-27 09:40:06 豆瓣君的首页热点推荐实在难以捉摸,只有正好跳出推荐贴时才能按图索骥找列表.简七和小伙伴 ...
- OpenLayers使用弹出窗口
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head ...
- ELK学习目录
DAY1.elasticsearch和kibana环境搭建以及简单介绍 A:环境搭建配置 (1)java虚拟机安装:https://www.cnblogs.com/studybrother/p/108 ...
- 2013B题碎纸片拼接
Photo1_1: clear;clc; path='E:\B\附件1\'; files=dir('E:\B\附件1\*.bmp'); % objdir='E:\B\附件1\'; % bgfile=[ ...
- NOIP模拟 17.8.17
NOIP模拟17.8.17 A 小 G 的字符串文件名 输入文件 输出文件 时间限制 空间限制str.pas/c/cpp str.in str.out 1s 128MB[题目描述]有一天,小 L 给小 ...
- 如何用maven tycho构建自己的Eclipse RCP应用
在你写了一个Eclipse插件之后,也许你就会想如何把它变成一个P2的项目或者是一个Java App让大家可以安装到自己的Eclipse上,dangdangdang~~ 这是你就可以利用maven-t ...
- 使用HashMap编写一程序实现存储某班级学生信息
1. 使用HashMap编写一程序实现存储某班级学生信息,要求在屏幕上打印如下列表 学号 姓名 性别 年龄 001 张三 男 23 002 李四 男 ...