#SQL_MACRO
The simpler way to encapsulate complex processing logic directly
within SQL.
SQL Macros allow developers to encapsulate complex
processing within a new structure
called a "macro" which can then be used within SQL
statement.
A New Approach To Simplifying Complex SQL.
Need a function to return to the lowest value of a specified
value vs. a lower
limit boundary vs. an upper limit boundary
• i.e. returns:
-- if x < lower return lower
-- if x > upper return upper
-- Otherwise, return x
create function clip(lo number, x number, hi number)
return varchar2 SQL_MACRO(SCALAR)
is begin
return ‘least(greatest(x, lo), hi)’;
end;
/
SELECT
ename,
CLIP (:lower, sal, :upper)
FROM emp;
Comments
Post a Comment