目前我必须将以下代码复制到SQL开发人员中,然后再付费粘贴结果。如何嵌套以下SQL以使生活更轻松?
Select * from ir.application where application_number = 'xxxxxxxxxx';
将xxxxxxxxxx转换为实际的应用程序编号 运行此语句。复制到SQL
下面--application ID = aaaaaaa
--aaaaaaa
通过突出显示并按CTRL + C来转置带有ID号的-aaaaaa 将以下SQL复制并粘贴到SQL Developer
中 select * from document where app_id = aaaaaaa;
将ID结果复制到转换为“aaaaaaa”的SQL代码中,其结果来自上面
点击运行
将以下SQL复制并粘贴到SQL Developer
中--document ID = ddddddd
--ddddddd
通过突出显示并按CTRL + C来转置带有ID号的--ddddddd 将以下内容复制并粘贴到SQL Developer
中--aaaaaaa = application ID from 1st query
--ddddddd = document ID from 2nd query
update ir.application set application_number = null where id = aaaaaaa;
update ir.application set ttl_id = null where id = aaaaaaa;
update document set app_id = null where id = ddddddd;
update document set title_number = null where id = ddddddd;
update document set case_number = null where id = ddddddd;
commit;
适当移调 现在依次从“update ...”到“commit”运行每一行通过在每个分号后突出显示并点击“运行”
答案 0 :(得分:2)
我认为你已经大大过度复杂了你的sql。首先,您可以更新update语句中的多个列,因此不需要每列都有更新语句。
我认为你只需要两个陈述:
update ir.application
set application_number = null,
ttl_id = null
where application_number = :app_num;
update document
set app_id = null,
title_number = null,
case_number = null
where app_id = (select app_id from ir.application where application_number = :app_num);
commit;