当前位置:网站首页>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
边栏推荐
猜你喜欢

他是“中台”之父,凭一个概念为阿里狂赚百亿

第10章 模块和包

Access Huawei game anti-addiction, click the anti-addiction pop-up window, the game crashes

形态学(膨胀、腐蚀)

What is DevOps?Enough to read this one!

聚焦数据来源、数据质量和模型性能构建小微企业信用画像

【黑马早报】尚乘数科上市13天,市值超阿里;北大终止陈春花聘用合同;新东方花近200亿退学费和遣散费;张小泉75%产品贴牌代工...

A Survey of Multi-Label Classification under Supervised and Semi-Supervised Learning

OAuth2图文快速入门

酷开科技 × StarRocks:统一 OLAP 分析引擎,全面打造数字化的 OTT 模式
随机推荐
How to develop small program plug-ins to achieve profitability?
程序猿七夕礼物-如何30分钟给女友快速搭建专属语聊房
What is DevOps?Enough to read this one!
Chinese valentine's day of young people crazy to make money, earn 140000 a week
MySQL - Explain详解
使用Stream多年,collect还有这些“骚操作”?
Nacos手摸手教学【二】Nacos注册中心
集群监控——Zabbix
【PHP实现微信公众平台开发—基础篇】第2章 微信公众账号及申请流程详解
考研数一数二数三之间的具体详细区别
他是“中台”之父,凭一个概念为阿里狂赚百亿
动手学深度学习_LeNet
微信小程序使用腾讯云对象储存上传图片
情人节浪漫3D照片墙【附源码】
Motion Rule (16)-Union Check Basic Questions-Grid Game
免费翻译软件哪个好用
A comprehensive understanding of MOS tubes, an article is enough
Access Huawei game anti-addiction, click the anti-addiction pop-up window, the game crashes
Flutter使用 json_serializable 解析 JSON 最佳方案
Why is Luo Zhenyu's A-share dream so difficult to fulfill?