当前位置:网站首页>oracle sql中根据条件判断是否插入数据
oracle sql中根据条件判断是否插入数据
2022-08-04 12:28:00 【AntHub】
文章目录
- 根据条件判断是否插入数据 (
insert_new_user.sql):
--用户信息
set serveroutput on;
declare
count_var number(10,0) ;
begin
select count(*) into count_var from tb_user t where input_date=to_char(sysdate, 'yyyymmdd') ;
if count_var <= 0 then
insert into tb_user
(select to_char(sysdate, 'yyyymmdd') input_date,
user_code,
user_name
from tb_user a
where a.input_date = '20220807');
insert into tb_user_detail
(select to_char(sysdate, 'yyyymmdd') input_date,
user_code,
user_desc
from tb_user_detail a
where a.input_date = '20220807');
commit;
else
dbms_output.put_line(chr(10)||'==>> :'||count_var);
end if;
end ;
/
quit;
- 以上sql 使用批处理脚本调用, 可实现当天有数据不插入,没有数据就从历史数据复制并插入用户信息数据;
- 是否有数据是上面的sql 内部判断的,批处理只是一个调用作用
::@echo off
cls
cd /d "D:\workspace\bat_script
SET today=%date:~0,10%
CALL:main >> D:\workspace\bat_script\logs\%today%.log
:main
SET right_now=%today%_%time:~0,2%:%time:~3,2%:%time:~6,2%
SET right_now=%right_now: =0%
echo ============================[%right_now%]===========================
sqlplus root/[email protected]:1521/orcl @D:\workspace\bat_script\insert_new_user.sql
echo.
echo ============================# end [%right_now%] end #===========================
echo.
:end
边栏推荐
- Based on the BiLSTM regression forecast method
- C#控制台退出前操作
- Cool and efficient data visualization big screen, it's really not that difficult to do!丨Geek Planet
- 图像分割方法
- 情人节浪漫3D照片墙【附源码】
- 为什么密码云服务平台是云时代的必然之选?
- UMA & Hong Kong Polytechnic & Ali propose SP-ViT to learn 2D space prior knowledge for visual Transformer!
- 第10章 模块和包
- 【微信小程序】信息管理与信息系统专业社会实习制作项目--垃圾指纹
- Redis(一)安装与配置
猜你喜欢
随机推荐
Flutter 使用 json_serializable 解析 JSON 支持泛型
Cache character stream
飞书更新招聘功能 候选人可选择面试时间
MySQL必知必会(初级篇)
技术分享| 融合调度系统中的电子围栏功能说明
第10章 模块和包
接到“网站动态换主题”的需求,我是如何踩坑的
ECCV 2022 | 通往数据高效的Transformer目标检测器
UMA & Hong Kong Polytechnic & Ali propose SP-ViT to learn 2D space prior knowledge for visual Transformer!
Js获取当前页面url参数
情人节浪漫3D照片墙【附源码】
OAuth2图文快速入门
动规(16)-并查集基础题——亲戚(Relations)
Yolov5 测试和训练自己的数据集
微信服务号调用API实现微信报警
【VSCode】一文详解vscode下安装vim后无法使用Ctrl+CV复制粘贴 使用Vim插件的配置记录
WPF---Grid布局讲解
Motion Rule (16)-Union Check Basic Questions-Grid Game
MATLAB——图像分块
绩效考核带给员工的不能只是压力









