Link to home
Create AccountLog in
Avatar of it-rex
it-rex

asked on

oracle sql

why this code is not showing sysdate when last_update is null

SELECT NVL(LAST_UPDATE,sysdate) as Date1
FROM myuser.mytab
WHERE rownum = '1'
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Maybe last_update has spaces in it?

SELECT NVL(trim(LAST_UPDATE),sysdate) as Date1
FROM myuser.mytab
WHERE rownum = '1'
Avatar of it-rex

ASKER

trim did not work;
but I foundout that if the table is empty it won't work,
but if I insert some data for some columns and leave update_date as null it will work.

now the thing is I need to do that when the table is empty.

thanks
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of it-rex

ASKER

Great this will do it but before closing the Q
why NVL does not work when the table is empty?
NVL and other functions work on a result.  If the table is empty there is no 'result' to work with.
Avatar of it-rex

ASKER

thanks