Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL : Probleme with not existence of result in temporary table
> PL/SQL : Probleme with not existence of result in temporary table
>
> Hi, i have a problem with this request :
>
> update
> TABLE_U
> set field_u = (
> select PV.res
> from
> TABLE_1
> ,
> (
> SELECT
> CI4.cd_mkp,
> SUM(CI4.mt_pvp) res
> FROM
> INTRA_IFT_CAT CI4
> WHERE
> CI4.ind_netting = 0
> GROUP BY
> CI4.cd_mkp,
> ) TABLE_2
>
> where
> TABLE_1.val = TABLE_U.val
> AND TABLE_2.cd_mkp = TABLE_U.cd_mkp
> )
> where
> TABLE_1.val = TABLE_U.val
> AND TABLE_2.cd_mkp = TABLE_U.cd_mkp
> ;
>
> With this, i want this result :
>
> When 'res' exists, the field must be update whith PV.res.
> When 'res' doesn't exist (the request that generate TABLE_2 give no
> line), the field 'fild_u' must not be changed.
>
> In fact the resut is :
> When 'res' exists, the field must be update whith PV.res.
> When 'res' doesn't exist, the field 'fild_u' IS UPDATED BY NULL.
Which version of Oracle are you using? How do your tables look like? What data do they contain? Here's something for everybody posting questions related to SQL: Please add DDL statements (create table x (...)) and DML statements (insert into x values(...)) so as to make your case as easy reproducible as it can be.
Anyway, maybe this statment helps you:
update table_u set field_u = (
select
case when res is null then table_u.field_u else res end
from table_1, (
select cd_mkp, sum(mt_pvp) res from intra_ift_cat group by cd_mkp ) table_2
select cd_mkp, sum(mt_pvp) res from intra_ift_cat group by cd_mkp ) table_2
hth
Rene Nyffenegger
-- Projektleitung und Entwicklung in Oracle/C++/C# Projekten http://www.adp-gmbh.ch/cv.htmlReceived on Sat Mar 08 2003 - 07:47:58 CST
![]() |
![]() |