当前位置:网站首页>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
边栏推荐
- 11. Network planning and design
- Flutter使用 json_serializable 解析 JSON 最佳方案
- 广告电商系统开发之订单处理
- 力扣每日一题-第48天-345. 反转字符串中的元音字母
- 程序猿七夕礼物-如何30分钟给女朋友快速搭建专属语聊房
- Motion Rule (16)-Union Check Basic Questions-Grid Game
- Cool and efficient data visualization big screen, it's really not that difficult to do!丨Geek Planet
- 【黑马早报】尚乘数科上市13天,市值超阿里;北大终止陈春花聘用合同;新东方花近200亿退学费和遣散费;张小泉75%产品贴牌代工...
- Based on the BiLSTM regression forecast method
- Hit the interview!The latest interview booklet of Ali Jin, nine silver and ten is stable!
猜你喜欢
随机推荐
划重点!2022面试必刷461道大厂架构面试真题汇总+面经+简历模板
高速电路PCB布局布线参考
Motion Rule (16)-Union Check Basic Questions-Grid Game
数据中台建设(九):数据中台资产运营机制
全面认识MOS管,一篇文章就够了
年轻人为什么不喜欢买蒙牛、伊利了?
A comprehensive understanding of MOS tubes, an article is enough
分布式链路追踪Jaeger + 微服务Pig在Rainbond上的实践分享
“蔚来杯“2022牛客暑期多校训练营4 N
绩效考核带给员工的不能只是压力
LeetCode每日一题(858. Mirror Reflection)
Access Huawei game anti-addiction, click the anti-addiction pop-up window, the game crashes
Analysis and comparison of mobile cross-end technical solutions
企业应当实施的5个云安全管理策略
How to develop small program plug-ins to achieve profitability?
ES 节点2G内存分析
外置USB供电与内置锂电池供电自动切换电路
Hands-on Deep Learning_LeNet
Matlab记录
MOSFET米勒平台(Miller Plateau)