If tab1 and tab2 are related and can be joined you may be able to use a CASE statement to handle this inside your macro:
SELECT CASE WHEN :ID = 2 THEN tab1.col1 ELSE tab2.col1 END AS col1_ , CASE WHEN :ID = 2 THEN tab1.co2 ELSE tab2.col2 END AS col2_ FROM Table1 tab1 (INNER||LEFT OUTER ||FULL OUTER) JOIN Table2 tab2 ON tab1.colx = tab2.colx ;
(Really wish these forums supported proper code formatting)
A FULL OUTER JOIN might be appropriate here if you wish to make sure that a row is returned. It may not be the most efficient solution, but if you are stuck using a macro it may be the only way. That being said, Carlos' suggestion to use a stored procedure may be more straightforward and efficient to handle this conditional logic.