Solved

Update Query

Posted on 2011-02-16
4
369 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
ID: 34907888
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
ID: 34912432
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
ID: 34933439
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
ID: 34973081
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Encryption Decryption in Oracle 12 120
SQL Retrieve Values 4 69
clob to char in oracle 3 39
ORA-04071: missing BEFORE, AFTER or INSTEAD OF keyword 2 46
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to take different types of Oracle backups using RMAN.

773 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