Hi, I have some problems using the host variable with like operator. I have a situation wherein I have to extract rows with a particular column matching different patterns. e.g
SELECT *
FROM MYTABLE
WHERE COLUMN1 LIKE ATTERN;
I am embedding the above SQL in my COBOL code as part of the cursor definition. I have declared the host variable PATTERN in the working-storage section. In the program I move a literal '%NM%' (inclusive of quotes) to PATTERN hoping that DB2 will substitute this in the above SQL statement. But when the SQL executes, it returns no rows (SQLCODE = 100). The problem is - PATTERN is derived from some other inputs and also the no. of times I want to execute the SQL depends on other factors. What do I do in this scenario??
Any help is highly appreciated.
Thanks,
Jay.
SELECT *
FROM MYTABLE
WHERE COLUMN1 LIKE ATTERN;
I am embedding the above SQL in my COBOL code as part of the cursor definition. I have declared the host variable PATTERN in the working-storage section. In the program I move a literal '%NM%' (inclusive of quotes) to PATTERN hoping that DB2 will substitute this in the above SQL statement. But when the SQL executes, it returns no rows (SQLCODE = 100). The problem is - PATTERN is derived from some other inputs and also the no. of times I want to execute the SQL depends on other factors. What do I do in this scenario??
Any help is highly appreciated.
Thanks,
Jay.