i have the below query which return blank values for the column property_value :
select target_name,target_type,property_name,property_value from oracle_properties where target_name like 'DY01EPI%' and property_name like 'DataGuardStatus'
output from sql developer:
How can i get a default value like ‘primary’ if the the row in Property_value is blank.
I have tried using NVL(property_value,'Primary')
and COALESCE(property_value,'Primary')
which didnt give expected result.Please suggest.Thanks.
Advertisement
Answer
Presumably, the value is not NULL
. You might use regular expressions for this:
select target_name, target_type, property_name, (case when regexp_like(property_value, '[a-zA-Z0-9]') then property_value else 'primary' end) as property_value from oracle_properties where target_name like 'DY01EPI%' and property_name like 'DataGuardStatus'