0

hello I used to work with Postgres and there if I want to see the affected rows after a manipulation I used the key word RETURNING

Example to show all the columns of the affected row(s):

UPDATE tblName 
  SET colName='something' 
WHERE colName='something' 
RETURNING *; 

can anyone tell me how I do the same thing with DB2 ?

Abra
  • 19
  • 3

1 Answers1

1

Example for DB2:

CREATE TABLE MYTABLE (
ID      INTEGER GENERATED ALWAYS AS IDENTITY,
NAME    CHAR(30),
AGE     SMALLINT,
)


SELECT ID, NAME, AGE
FROM FINAL TABLE 
(
    INSERT INTO MYTABLE (NAME, AGE)
    VALUES('Jon Smith', 35)
)

Result: 
ID  NAME        AGE
1   Jon Smith   35
Ramin Faracov
  • 3,032
  • 1
  • 2
  • 8