首页 \ 问答 \ Oracle中的复杂更新查询问题(Issue with complex Update Query in Oracle)

Oracle中的复杂更新查询问题(Issue with complex Update Query in Oracle)

UPDATE CHILD_COND
    SET S_TRD=
      (SELECT S_TRD
      FROM
        (SELECT MAX(TV.S_TRD)            AS S_TRD,
        TV.TRADEID                        AS TRADEID,
        TV.TRD_VER             AS TRD_VER,
        TV.TIMEST                 AS TIMEST,
        TV.SOURCENAME                     AS SOURCENAME,
        STG_TRADE.SP_COND AS SP_COND
        FROM MASTER_T TV,
        T_STG_TRADE_VERSION STG_TRADE
        WHERE TV.SOURCENAME       = STG_TRADE.SOURCENAME
        AND TV.TRADEID            = STG_TRADE.TRADEID
        AND TV.TRD_VER = STG_TRADE.TRD_VER
        AND TV.TIMEST     = STG_TRADE.TIMEST
        AND TRADESETID            = '91004'
        GROUP BY TV.TRADEID,
        TV.TRD_VER,
        TV.TIMEST,
        TV.SOURCENAME,
         STG_TRADE.SP_COND
        )TRD WHERE CHILD_COND.SP_COND = TRD.SP_COND AND S_TRD IS NOT NULL
     ) 

我需要根据主表中的主键更新子表中的外键。 但是当子表中没有值时,所有子外键值都会更新为null。 在MASTER_T中插入新的主记录时,S_TRD被设置为null,但CHILD_COND中没有相应的子记录


UPDATE CHILD_COND
    SET S_TRD=
      (SELECT S_TRD
      FROM
        (SELECT MAX(TV.S_TRD)            AS S_TRD,
        TV.TRADEID                        AS TRADEID,
        TV.TRD_VER             AS TRD_VER,
        TV.TIMEST                 AS TIMEST,
        TV.SOURCENAME                     AS SOURCENAME,
        STG_TRADE.SP_COND AS SP_COND
        FROM MASTER_T TV,
        T_STG_TRADE_VERSION STG_TRADE
        WHERE TV.SOURCENAME       = STG_TRADE.SOURCENAME
        AND TV.TRADEID            = STG_TRADE.TRADEID
        AND TV.TRD_VER = STG_TRADE.TRD_VER
        AND TV.TIMEST     = STG_TRADE.TIMEST
        AND TRADESETID            = '91004'
        GROUP BY TV.TRADEID,
        TV.TRD_VER,
        TV.TIMEST,
        TV.SOURCENAME,
         STG_TRADE.SP_COND
        )TRD WHERE CHILD_COND.SP_COND = TRD.SP_COND AND S_TRD IS NOT NULL
     ) 

I need to update the foreign key in the child table based on the primary key from the master table. But when there is no value in the child table, all the child foreign key value is getting updated to null. S_TRD is being set to null when new master records are inserted in MASTER_T but there are no corresponding child records in CHILD_COND


原文:https://stackoverflow.com/questions/17749238
更新时间:2022-11-18 20:11

最满意答案

你可以使用? 用于匹配单个字符的通配符:

sudo dtrace -p "$(pgrep run)" -n 'pid$target:QtCore:QCoreApplication??sendPostedEvents*:entry { ustack(3); }'

问号将匹配“::”但不匹配“Private ::”。


You can use the ? wildcard to match single characters:

sudo dtrace -p "$(pgrep run)" -n 'pid$target:QtCore:QCoreApplication??sendPostedEvents*:entry { ustack(3); }'

The question marks will match "::" but not "Private::".

相关问答

更多
  • 这是美元符号,在makefile中,您必须键入$$才能获得单个美元符号: M_ARCH := $(shell g++ -dumpmachine | awk '{split($$1,a,"-");print a[1]}') It's the dollar sign, in makefiles you'll have to type $$ to get a single dollar sign: M_ARCH := $(shell g++ -dumpmachine | awk '{split($$1,a,"- ...
  • 到目前为止,获奖者是: Addressable :: URI#normalize :“返回一个规范化的URI对象。注意:此方法并不试图完全符合规范。它主要用于纠正其他人读取规范的失败,并且还处理缓存问题,因为几个不同URI可能代表相同的资源,不应多次缓存。“ Addressable :: URI.heuristic_parse :“将输入转换为URI。输入不必是有效的URI - 该方法将使用启发式方法来猜测URI的用途。这不符合标准,只是用户友好“。 So far, the winners are: Add ...
  • 转义它们会激活它们的元字符属性并将它们转换为GNU grep中的单词边界: $ grep 'foo' file foo foobar $ grep '\' file foo 上面的第二个grep没有查找字符串 ,它正在寻找字符串foo不会在字构成字符之前或之后立即成功。 一般来说,如果不确切知道这意味着什么,就逃脱角色是不安全的。 这是另一个例子: $ printf 'aa\na{2}b\n' aa a{2}b $ printf 'aa\na{2}b\n' ...
  • 者; 是一个XML功能。 它不允许在HTML 4.x中使用,并且不受Internet Explorer支持。 Firefox支持它作为其标记汤解析器的一部分,以处理作为text / html提供的XHTML。 使用' 代替。 另见XHTML 1.0附录C. ' is an XML feature. It isn't allowed in HTML 4.x and isn't supported by Internet Explorer. Firefox supports it as par ...
  • 你不想要StringEscapeUtils.escapeJava()你想要Pattern.quote() 。 You do not want StringEscapeUtils.escapeJava() You want Pattern.quote().
  • 你可以使用? 用于匹配单个字符的通配符: sudo dtrace -p "$(pgrep run)" -n 'pid$target:QtCore:QCoreApplication??sendPostedEvents*:entry { ustack(3); }' 问号将匹配“::”但不匹配“Private ::”。 You can use the ? wildcard to match single characters: sudo dtrace -p "$(pgrep run)" -n 'pid$targ ...
  • 一样的东西? 不,你不能像sys.settrace那样做那些装饰者没有的魔法。 (技术上不一定是sys.settrace,但是使用别的东西 - 比如字节码重写 - 不会是一个改进。)通过这样做可以使它变得更简单,例如: def Property(f): fget, fset, fdel = f() fdoc = f.__doc__ return property(fget, fset, fdel, fdoc) class Foo(object): @Property ...
  • 他们是不同的,我认为你正确地得到了区别。 编码是指将文本的逻辑表示(“逻辑字符串”,例如Unicode)转换为明确定义的二进制数字序列(“物理字符串”,例如ASCII,UTF-8,UTF-16)。 转义是一个特殊字符(通常是反斜杠:'\'),它启动对转义字符后面的字符的不同解释; 当您需要将更多数量的符号编码为更少数量的不同(和有限)比特序列时,必须进行转义。 They're different, and I think you're getting the distinction correctly. E ...
  • 如果您要执行的只是运行此特定DTrace脚本,只需将其保存到.d脚本文件并使用如下命令对您编译的可执行文件运行它: sudo dtrace -s dtracescript.d -c [Path to executable] 用脚本文件名替换dtracescript.d地方。 这假设您将DTrace作为系统的一部分(我正在运行Mac OS X,自Leopard以来已经使用它)。 如果你对这是如何工作感到好奇的话,我写了一篇关于在不久前使用DTrace for MacResearch的两部分教程,可以在这里和 ...
  • 编码您的参数: url = url + "?post=" + encodeURIComponent(document.myform.post.value); Encode your parameter: url = url + "?post=" + encodeURIComponent(document.myform.post.value);

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)