How to re-code DB2 to DataCom/SQL
search cancel

How to re-code DB2 to DataCom/SQL

book

Article ID: 40263

calendar_today

Updated On:

Products

Datacom DATACOM - AD

Issue/Introduction

Question:

How would I re-code the following DB2 example to run under DataCom/DB?

 

SELECT DOCU_TY, DOCU_NUM, DLR_TY, DLR_STUB, NUM_OF_PL, O_NUM_OF_PL

FROM FINAL TABLE

    (UPDATE DLR_TO_REG_T206

      INCLUDE (O_NUM_OF_PL CHAR (3))

        SET   NUM_OF_PL = '777',

            O_NUM_OF_PL = NUM_OF_PL

WHERE DOCU_TY  = 'NCD'    AND

      DOCU_NUM = '00308N' AND

      DLR_STUB = 'DDD50'

    )

;

 

Answer:

You would need two separate Datacom SQL statements:

The SQL UPDATE statement and then once it is finished the SELECT statement.

There is no equivalent SQL statement for Datacom.

 

Note: That DB2 facility came with DB2 9.0,

SELECT SUM(salary) INTO :SAL-HV FROM FINAL_TABLE (UPDATE EMP SET SALARY=SALARY*1.02 WHERE WORKDEPT='A01'); 


Prior to the capability you would have to run the UPDATE statement, and then only after it finishes, you would run the SELECT to add up the new salary values. Now, instead of multiple statements requiring multiple passes through the data, you can consolidate it into one.



Additional Information:

See IBM Support Knowledge Center for more info about that SQL statement:

https://www.ibm.com/support/knowledgecenter/#!/SSEPEK_10.0.0/com.ibm.db2z10.doc.apsg/src/tpc/db2z_selectvaluesupdate.html 

 

 

Environment

Release:
Component: SQL