Reputation: 15736
So let's assume I have the following query:
SELECT
CASE
WHEN SOME_PACKAGE.SOME_EXPENSIVE_FUNCTION IS NOT NULL
THEN SOME_PACKAGE.SOME_EXPENSIVE_FUNCTION || ', random string'
ELSE
'something_else'
END
FROM
SOME_TABLE;
Is there a way to prevent this package function from executing more than once without nested queries?
Upvotes: 2
Views: 40
Reputation: 1456
This should work:
SELECT NVL(NULLIF(SOME_PACKAGE.SOME_EXPENSIVE_FUNCTION
||', random string',', random string'),'something_else')
FROM SOME_TABLE;
Upvotes: 3