Solved

Update Query

Posted on 2011-02-16
4
367 Views
Last Modified: 2012-06-22
I'm having quite the day, I'm unable to turn this access query into a pl/sql update query.

Please help :)
UPDATE CDB.PRJ_LM TIE 
    SET REC_CHNG_CD = 'U',
    MODIFIED_BY_ID = PARAM_0,
    MODIFIED_DT = SYSDATE,
    STAT_CD = 'I'
    WHERE EXISTS (SELECT T.P_ID P_ID, TIE.LM_ID ID, T.NM NAME,
'N/A' DEF_TX, FROM CDB.PRJ_T T LEFT JOIN CDB.PRJ_LM TIE ON (T.PUB_ID = TIE.PUB_ID) 
AND (T.ID = TIE.ID)
WHERE (((T.P_ID)= 1) 
AND ((T.CHNG_CD)='U') 
AND ((T.TMPLT_STAT_CD)='I') 
AND ((TIE.TIELM_STAT_CD)='A'))

Open in new window

0
Comment
Question by:lulubell-b
4 Comments
 
LVL 1

Accepted Solution

by:
hraja77 earned 250 total points
Comment Utility
UPDATE CDB.PRJ_LM TIE
    SET REC_CHNG_CD = 'U',
    MODIFIED_BY_ID = PARAM_0,
    MODIFIED_DT = SYSDATE,
    STAT_CD = 'I'
    WHERE EXISTS (SELECT T.P_ID P_ID, TIE.LM_ID ID, T.NM NAME,
'N/A' DEF_TX, FROM CDB.PRJ_T T where (T.PUB_ID = TIE.PUB_ID
AND T.ID = TIE.ID)
WHERE (((T.P_ID)= 1)
AND ((T.CHNG_CD)='U')
AND ((T.TMPLT_STAT_CD)='I')
AND ((TIE.TIELM_STAT_CD)='A'))
0
 
LVL 28

Expert Comment

by:Naveen Kumar
Comment Utility
There are lot of parenthesis missing/incorrect in the above version of your query. So corrected the same.

Try this to see if it works for you.

UPDATE CDB.PRJ_LM TIE
    SET REC_CHNG_CD = 'U',
    MODIFIED_BY_ID = PARAM_0,
    MODIFIED_DT = SYSDATE,
    STAT_CD = 'I'
WHERE EXISTS (SELECT 1 FROM CDB.PRJ_T T
WHERE T.PUB_ID = TIE.PUB_ID
AND T.ID = TIE.ID
and T.P_ID= 1
AND T.CHNG_CD='U'
AND T.TMPLT_STAT_CD='I'
AND TIE.TIELM_STAT_CD='A' )
0
 
LVL 15

Assisted Solution

by:Aaron Shilo
Aaron Shilo earned 250 total points
Comment Utility
1. you had 1 " , " in you inner query just before the FROM key word.
2. when using EXIST no need to retrive all these column you will not use them your just checking for an existance of a value SO i changed that to a constant " 1 ".

enjoy .

UPDATE CDB.PRJ_LM TIE
    SET REC_CHNG_CD = 'U',
    MODIFIED_BY_ID = PARAM_0,
    MODIFIED_DT = SYSDATE,
    STAT_CD = 'I'
    WHERE EXISTS (SELECT1 FROM CDB.PRJ_T T LEFT JOIN CDB.PRJ_LM TIE ON (T.PUB_ID = TIE.PUB_ID)
AND (T.ID = TIE.ID)
WHERE (((T.P_ID)= 1)
AND ((T.CHNG_CD)='U')
AND ((T.TMPLT_STAT_CD)='I')
AND ((TIE.TIELM_STAT_CD)='A'))
0
 

Author Comment

by:lulubell-b
Comment Utility
Thank you
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now