oracle遍历表更新另一个表(一对多)
declare
cursor cur_test is
select t.txt_desig,
m.segment_id,
s.code_type_direct,
case
when s.uom_dist_ver_lower = 'FL' then
s.uom_dist_ver_lower || s.val_dist_ver_lower
else
to_char(s.val_dist_ver_lower)
end as val
from nvduser11.en_route_rte t
right join nvduser11.rte_seg s
left join fmap2.segment m
on s.segment_id = m.segment_id on
t.en_route_rte_id = s.en_route_rte_id;
begin
for c in cur_test loop
update fmap2.segment
set first =
(case
when first is null or first = '' then
c.txt_desig
else
to_char(first)
end),
second =
(case
when (first is not null or first != '') and
(second is null or second = '') then
c.txt_desig
else
to_char(second)
end),
third =
(case
when (second is not null or second != '') and
(first is not null or first != '') and (third is null or third = '') then
c.txt_desig
else
to_char(third)
end),
firstdirect =
(case
when first is null or first = '' then
c.code_type_direct
else
to_char(firstdirect)
end),
firstaltitude =
(case
when first is null or first = '' then
c.val
else
to_char(firstaltitude)
end),
seconddirect =
(case
when (first is not null or first != '') and
(second is null or second = '') then
c.code_type_direct
else
to_char(seconddirect)
end),
secondaltitude =
(case
when (first is not null or first != '') and
(second is null or second = '') then
c.val
else
to_char(secondaltitude)
end),
thirddirect =
(case
when (second is not null or second != '') and
(first is not null or first != '') and (third is null or third = '') then
c.code_type_direct
else
to_char(thirddirect)
end),
thirdaltitude =
(case
when (second is not null or second != '') and
(first is not null or first != '') and (third is null or third = '') then
c.val
else
to_char(thirdaltitude)
end)
where segment_id = c.segment_id;
end loop;
commit;
end;
oracle遍历表更新另一个表(一对多)的更多相关文章
- 如何使用MySQL一个表中的字段更新另一个表中字段
[本文出自:https://www.jb51.net/article/150323.htm] 这篇文章主要介绍了如何使用MySQL一个表中的字段更新另一个表中字段,需要的朋友可以参考下 1,修改1列 ...
- mySQL:两表更新(用一个表更新另一个表)的SQL语句
用一个表中的字段去更新另外一个表中的字段, MySQL 中有相应的 update 语句来支持,不过这个 update 语法有些特殊.看一个例子就明白了. create table student ( ...
- mysql用一个表更新另一个表的方法
Solution 1: 修改1列(navicate可行) update student s, city c set s.city_name = c.name where s.city_code = ...
- oracle 用一个表的一个字段更新另一个表的一个字段
案列: 想更新A表的name字段,由于失误,在写这个表的时候,这个字段没有写,发现的时候,已经写了一个多月的数据了.改了之后的过程,会正常的写这个字段, 可是已经写了的数据也不能铲了,重新计算. 好在 ...
- oracle 根据一个表更新另一个表内容
declarecursor c_col is select * from xtgl_jgmcbm where substr(v_jgbm,0,2)in('41');--v_sjbm in( selec ...
- sql 根据一个表更新 另一个表的例子及可能遇到的问题
例子: update a set a.name=b.name1 from a,b where a.id=b.id 例子延伸:更新的时候会把字符串 转为科学计数法 怎么办? 答:用 cast 转换一下 ...
- 【数据库】SQL两表之间:根据一个表的字段更新另一个表的字段
1. 写法轻松,更新效率高:update table1 set field1=table2.field1,field2=table2.field2from table2where table1.id= ...
- oracle插入或更新某一个指定列来执行触发器
表结构: create table TZ_GXSX ( ID VARCHAR2(15), PROJECT VARCHAR2(50), TXYX NUMBER(22) default '0', CDAT ...
- SQL两表之间:依据一个表的字段更新还有一个表的字段
1. 写法轻松.更新效率高: update table1 set field1=table2.field1, field2=table2.field2 from table2 where table1 ...
随机推荐
- Circular Buffer
From:http://bradforj287.blogspot.com/2010/11/efficient-circular-buffer-in-java.html import java.util ...
- MacBook安装双系统(Windows多分区)
分区 ---------- 启动电脑,放入mac os安装盘,按alt选择光盘启动. 1. 在工具菜单里选择磁盘工具对整个硬盘进行分区: ----------- 第一个是 exFAT.Msdos 格 ...
- Ubuntu 安装php+mysql 环境
新系统安装完毕后,首先运行apt-get update 更新apt库. 然后安装ssh,输入apt-get install openssh-server,安装ssh是为了可以远程操作,不然坐在机房实在 ...
- code vs 1098 均分纸牌(贪心)
1098 均分纸牌 2002年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description 有 N 堆纸牌 ...
- PHP 链接多种数据库 的方法
数据库中 单词之间的空格(一个语句前面和后面做字符串拼接的时候最好留空格 ) 可以随便加 其他地方 禁止随便加空格!!(加了 就报错)! =====================总结=== ...
- ecshop不同文章分类调用不同文章分类模板
根据需要,不同的文章分类会有不一样的页面风格.也就是说根据文章分类ID来判断,输出不同的文章分类模板. 重点就是文章分类的ID. 打开:article_cat.php $smarty->disp ...
- ASP.NET获取客户端IP地址
public static string GetRealIP() { string ip; try { ...
- Linux 相关面经
都说没用过Linux都不要说自己搞过开发.我因为项目就是Linux没办法才接触Linux的,不过用了一段时间大黑屏外人看不懂的样子感觉还是屌屌的,虽说用过但知道也仅限于权限内的一些知识,还是一起看下面 ...
- C#重启IIS指定网站和指定应用程序池
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- SQL Server架构 -- 数据库文件和文件组
在SQL SERVER中,数据库在硬盘上的存储方式和普通文件在Windows中的存储方式没有什么不同,也是在特定文件夹下创建不同的文件,然后经过文件存储系统去抓取数据信息.理解文件和文件组的概念可以帮 ...