Refer my installment #1 if you miss it. In this post, I have shared two different ideas to give host-variables in DB2 SQL.
Select Empno, Lastname, Firstname From Emp Where Empno IN (:HV1, :HV2, ;Hv3)
Though it saves time, it needs more Host variables.
If we need to give multiple host variable ,we can put all those in a Temp table and retrieve it.
EXEC SQL DECLARE GLOBAL TEMPORARY TABLE <em>TEST1</em>(COL_LIST INTEGER NOT NULL);
EXEC SQL INSERT INTO TEST1 VALUES(x1,x2,x3);
EXEC SQL COMMIT;
Select Empno, Lastname, Firstname From Emp Where Empno IN (Select COL_LIST from TEST1);
To drop the table:
DROP TABLE TEST1;