November 14th, 2008
Introduction to ANSI Scalar Functions, Part 2 of 2
Posted by
admin in
G. ANSI Scalar Functions
For example: SELECT EXTRACT(YEAR FROM DUE_DATE)
FROM ACCOUNTS_PAYABLE_TBL;
SELECT EXTRACT(YEAR FROM DUE_DATE)
FROM ACCOUNTS_PAYABLE_TBL
WHERE EXTRACT(YEAR FROM DUE_DATE) = 2051;
or
SELECT EXTRACT(YEAR FROM DUE_DATE)
FROM ACCOUNTS_PAYABLE_TBL
HAVING EXTRACT(YEAR FROM DUE_DATE) = 2051;
The results of scalar functions do not have headings in the result table because they are not existing and unmodified columns in the base table. A scalar argument can be a column name, a column function, or another scalar function.
NULL values that are used in a scalar function will result in a NULL value. If actual values are to be returned, then the column must be defined as NOT NULL WITH DEFAULT so that a default of zero or spaces will be used in the scalar function or a VALUE scalar function may also be used for this purpose.
Comments Off