Hi All, I have a problem with row selection based on a program variable in embedded RPG SQL.
BGABCD is a column, a value is present in all rows. It is char(3).
PCompany is the program variable to select rows. It is char(3).
I want to select rows where BGABCD = PCompany, but if PCompany is blank then select all rows.
Various attempts listed below.
WHERE :PCompany in (BGABCD, ' ')
Selects all rows, no matter what the value of PCompany. I was hoping it would select on value of PCompany if this is not blank.
WHERE ((:PCompany = BGABCD) OR (:PCompany = ' '))
Same as above.
WHERE (BGABCD = SELECT(CASE
WHEN :PCompany = ' ' THEN BGABCD
ELSE :PCompany END))
Selects no rows.
Any help appreciated.