I don't know if this counts, but this is a multi-nested CASE statement in one of my dynamic SQL queries. CASE acts as a if-then-else statement.
case when LIST_TYPE = 1 then case when NEW_TAB = 0 then apex_util.prepare_url('f?p=' || 'INSITE' || ':10000:' || :APP_SESSION || '::::P0_MENU_ID:' || MENU_ID) else 'javascript:apex.navigation.openInNewWindow(' || chr(39) || utl_url.unescape(LINK_TARGET) || chr(39) || ')' end when LIST_TYPE = 2 then case when NEW_TAB = 0 then apex_util.prepare_url('f?p=' || APP_ALIAS || ':' || LINK_TARGET || ':' || :APP_SESSION) else 'javascript:apex.navigation.openInNewWindow(' || chr(39) || 'f?p=' || APP_ALIAS || ':' || LINK_TARGET || ':' || :APP_SESSION || chr(39) || ')' end when LIST_TYPE = 3 then apex_util.prepare_url('f?p=' || 'INSITE' || ':10000:' || :APP_SESSION || ':' || 'APPLICATION_PROCESS=GET_FILE:::P0_MENU_ID:' || MENU_ID) else null end as LINK_TARGET,
I was actually going to see if I could refactor it, but I'm not exactly a SQL pro (see what I did there?)
Thanks for sharing though! Even gave me something new to look at (SQL cases).
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I don't know if this counts, but this is a multi-nested CASE statement in one of my dynamic SQL queries. CASE acts as a if-then-else statement.
I was actually going to see if I could refactor it, but I'm not exactly a SQL pro (see what I did there?)
Thanks for sharing though! Even gave me something new to look at (SQL cases).