当前位置:网站首页>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
边栏推荐
- Redis(一)安装与配置
- 广告电商系统开发
- 【全网首发】Redis系列5:深入分析Cluster 集群模式
- DC-DC电源中前馈电容的选择
- 1314元的七夕礼盒,收割了多少直男?
- Tarjan 求有向图的强连通分量
- Focus!2022 interview must brush 461 interview questions summary + interview + resume template
- Django使用腾讯云发送短信并存入redis
- Share | technology integration electronic fence function of scheduling system
- backbone核心详解系列——RepVGG
猜你喜欢
随机推荐
How to develop small program plug-ins to achieve profitability?
【VSCode】一文详解vscode下安装vim后无法使用Ctrl+CV复制粘贴 使用Vim插件的配置记录
接入华为游戏防沉迷,点击防沉迷弹窗后游戏闪退
为什么密码云服务平台是云时代的必然之选?
编辑器vscode Already included file name ‘xxx‘ differs from file name ‘xxx‘ only in casing报错
03 多线程与高并发 - ReentrantLock 源码解析
Cache character stream
两年独立开发经验程序员告诉我们赚钱的经验(听听真正赚到钱的高手做法)
Js获取当前页面url参数
动规(16)-并查集基础题——亲戚(Relations)
如何治理资源浪费?百度云原生成本优化最佳实践
Chinese valentine's day of young people crazy to make money, earn 140000 a week
高速电路PCB布局布线参考
Yolov5 测试和训练自己的数据集
MOSFET米勒平台(Miller Plateau)
电源输出的Overshoot和Undershoot 测试
Why is Luo Zhenyu's A-share dream so difficult to fulfill?
推荐一款优秀的通用管理后台
常用代码模板1——基础语法
微信服务号调用API实现微信报警









