Re-coding DB2 SQL to Datacom
search cancel

Re-coding DB2 SQL to Datacom

book

Article ID: 40263

calendar_today

Updated On:

Products

Datacom DATACOM - AD Datacom/AD Datacom/DB

Issue/Introduction

How can the following DB2 example be re-coded to run under Datacom?

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'
    )
;

Environment

Release: All supported releases.
Component: SQL

Resolution

Two separate Datacom SQL statements would be needed. First, and SQL UPDATE statement and then once it is finished, the SELECT statement.

There is no equivalent SQL statement for Datacom.

Note: This DB2 functionality 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 this capability, the UPDATE statement would have to run first, and then only after it finishes, could the SELECT be run to add up the new salary values. Now, instead of multiple statements requiring multiple passes through the data, it can be consolidated into one.