Bobby Sandhu
asked on
handling nulls
Hi there,
I am trying to put 1800-01-01 if date is null else populate what ever date is there
seems like it dont like nvl
Any idea why?
Thanks
SELECT
nvl(DTL_REC_CRE_DATE,'1800 -01-01')
,nvl(DTL_UPDT_DATE,'1800-0 1-01')
from aa
I am trying to put 1800-01-01 if date is null else populate what ever date is there
seems like it dont like nvl
Any idea why?
Thanks
SELECT
nvl(DTL_REC_CRE_DATE,'1800
,nvl(DTL_UPDT_DATE,'1800-0
from aa
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Data type is date
but getting errors
SQL0440N No authorized routine named "COALESE" of type "FUNCTION" having
compatible arguments was found. SQLSTATE=42884
SQL0440N No authorized routine named "COALESE" of type "FUNCTION " having compatible arguments was found.
Explanation:
This occurs in a reference to routine "<routine-name>", when the
database manager cannot find a routine it can use to implement
the reference. There are several reasons why this could occur:
but getting errors
SQL0440N No authorized routine named "COALESE" of type "FUNCTION" having
compatible arguments was found. SQLSTATE=42884
SQL0440N No authorized routine named "COALESE" of type "FUNCTION " having compatible arguments was found.
Explanation:
This occurs in a reference to routine "<routine-name>", when the
database manager cannot find a routine it can use to implement
the reference. There are several reasons why this could occur:
Hi nav,
Check your spelling. :) COALESCE....
Kent
Check your spelling. :) COALESCE....
Kent
ASKER
my bad thanks
Hi nav,
It's amazing how many people miss this subtlety about the COALESCE function, but it can take more than 2 arguments. The function searches the parameter list and returns the first value that is not NULL. Most people use it to convert a single value to non-null.
SELECT coalesce (accounting_date, posting_date, transaction_date, current_date) FROM mytable;
That query will check the accounting_date, posting_date, and transaction_date for each row and return the first one in the list that is not NULL. If they are all NULL, the current date is returned.
Good Luck,
Kent
It's amazing how many people miss this subtlety about the COALESCE function, but it can take more than 2 arguments. The function searches the parameter list and returns the first value that is not NULL. Most people use it to convert a single value to non-null.
SELECT coalesce (accounting_date, posting_date, transaction_date, current_date) FROM mytable;
That query will check the accounting_date, posting_date, and transaction_date for each row and return the first one in the list that is not NULL. If they are all NULL, the current date is returned.
Good Luck,
Kent
ASKER