PRAVEEN T
asked on
Need help on update SQL.
Help me on this sql.
I have the two tables
batch_info
document_info
i need to update the STATUS = 'COMPLETED' IN Batch_info table
where the module name is = 'EXPORT' Based on Document_info table
where the release ='1' record.
Here is the example.
Batch_info
EXTERNALBATCHID,NEXTMODULE ,NEXTSTATU S
36267,EXPORT,READY
36264,EXPORT,READY
Document_info
DOCGUID,RELEASED,EXTERNALB ATCHID
{B7FE744A-DE4D-4b1d-AEFA-6 5C3F40B260 8},1,36267
{CDAAD0C0-AF11-4b53-97CF-C 00D62C50F9 8},1,36264
Regards,
Praveen
I have the two tables
batch_info
document_info
i need to update the STATUS = 'COMPLETED' IN Batch_info table
where the module name is = 'EXPORT' Based on Document_info table
where the release ='1' record.
Here is the example.
Batch_info
EXTERNALBATCHID,NEXTMODULE
36267,EXPORT,READY
36264,EXPORT,READY
Document_info
DOCGUID,RELEASED,EXTERNALB
{B7FE744A-DE4D-4b1d-AEFA-6
{CDAAD0C0-AF11-4b53-97CF-C
Regards,
Praveen
ASKER
Result should be Like this ::
Batch_Info Table
EXTERNALBATCHID,NEXTMODULE ,NEXTSTATU S
36267,EXPORT,COMPLETED
36264,EXPORT,COMPLETED
Batch_Info Table
EXTERNALBATCHID,NEXTMODULE
36267,EXPORT,COMPLETED
36264,EXPORT,COMPLETED
or using merge statement
* not tested
Oracle Merge
https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm#SQLRF01606
MERGE INTO batch_info b
USING Document_info d
ON (b.EXTERNALBATCHID = d.EXTERNALBATCHID)
WHEN MATCHED
THEN
UPDATE SET STATUS = 'COMPLETED'
WHERE b.NEXTMODULE = 'EXPORT' AND d.RELEASED = 1
* not tested
Oracle Merge
https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm#SQLRF01606
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Its working .. thank you
Open in new window