create or replace FUNCTION macro_If_condition( p_1 varchar2 )
RETURN varchar2 SQL_MACRO is
v_sql varchar2(1000);
BEGIN
if p_1 is not null then
v_sql := q'[ select p_1 from dual ]' ;
else
v_sql := q'[ select 'NULLL' from dual ]' ;
end if;
RETURN v_sql;
END;
SELECT * FROM macro_If_condition( 'input1') t;
Op: NULLL --- its incorrect bcz we have passed input1 but don’t know why it went to ELSE condition
Can anyone explain why the IF condition is not working. You can try the above sample code.