I know that this is a question asked quite regularly, but still, would like to know on how to go for this.
I am trying to update three values, firstname, middlename,lastname from names table. The emplid is selected from a staging table. I'd like to know, on how to set NVL for this.
The query block will be like this:
update staging_table
set firstname, middlename,lastname =
(select firstname,middlename,last
from names
where names.emplid = staging_table.emplid)
I want to check for the null values, as there are cases where middlename is null.
Part two: I have got a work around for this as of now, but still, would like to know a better technique as performance is getting affected.
As of now, I have used this update query:
update staging_table set first_name = nvl((select first_name from names where emplid = staging_table.emplid),' ')
update staging_table set middle_name = nvl((select middle_name from names where emplid = staging_table.emplid),' ')
Is there a better technique than this?
I have checked for coalesce
function in oracle, but that checks for entire result, and if, any one of the parameter is null, only then, null value is returned. Here, I need to check the null values for individual fields.
Thanks for the guidance.