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 ...
随机推荐
- [正则表达式]PCRE环视功能
设想一下这个问题,假设为了方便长串数字的阅读性,需要为其添加逗号作为分隔,需要怎么做呢? 2569836495 => 2,569,836,495 正则表达式的匹配通常是从左往右的,这导致无法使用 ...
- css3-columns多列布局
/*css3中的布局*/ .wrapper{ margin:auto; width:300px; height:200px; border:2px dotted blue; -webkit-colum ...
- ios .a和.framework
创建Aggregate来合并模拟器和真机通用的framework 然后在Build Phases下New Run Script Phase创建合并脚本: # Constants SF_TARGET_N ...
- asp.net 读取导入的project(mpp)文件
公司项目有用到读取project文件(.mpp)并保存到指定数据库类似的功能. 查了一下大家总结的方法. 找到一哥们代码,初步判断可行,特此收藏. using System.IO; using Mic ...
- Ajax文件上传
- mysql命令行修改字符编码
1.修改数据库字符编码 mysql> alter database mydb character set utf8 ; 2.创建数据库时,指定数据库的字符编码 mysql> create ...
- JavaOO面向对象中的注意点(三)
1.接口 a.关键字:interface public interface Serviceable{ //TODO } b.属性:只能是 公共 静态 常量 属性--就算不写这三个关键字,也是默认这种情 ...
- android中如何用代码来关闭打开的相机
场景描述: 比如你再应用中打开了系统相机,然后需要在几分钟后自动关闭这个系统相机(不是手动关闭) 1.在activityA中利用startActivityForResult(intent,reques ...
- windowsservice
1.创建 windows服务 项目 文件 -> 新建项目 -> 已安装的模板 -> Visual C# -> windows ,在右侧窗口选择"windows 服务 ...
- 通过sql server 连接mysql
图文:通过sql server 连接mysql 1.在SQL SERVER服务器上安装MYSQL ODBC驱动; 驱动下载地址:http://dev.mysql.com/downloads/con ...