If you use Firebird server (which was not said, but which looks like by your error text) then you have MERGE
command for it.
However, if you use Interbase server, then I do not know how you can write that statement there, consult Interbase manuals then: http://docwiki.embarcadero.com/InterBase/2017/en/Statement_and_Function_Reference_(Language_Reference_Guide)
You can check the server you work with in IBExpert using Services -> Server Properties and Log menu.
Assuming you use Firebird version 2.1 or newer
For example something like this:
MERGE INTO employee_migration dest
USING (
Select cl.cdclient, em.ID
From clientref cl
Inner Join employee_migration em
ON cl.client like upper(em.name)
) as src
ON dest.ID = src.ID -- or whatever your key columns are
WHEN MATCHED THEN UPDATE SET dest.namecode = src.cdclient
WHEN NOT MATCHED THEN INSERT (namecode, ID, ....)
VALUES ( src.cdclient, ...., ...........)
However without sample data your request seems of little practical sense.
Your join
condition is cl.client like upper(em.name)
- which is "many to many": for every row in clientref
there can be many corresponding rows in employee_migration
and vice versa.
So you would probably be matching and updating rows in employee_migration as dest
with MANY candidate rows from the src
query.
- By SQL standard it should generate an immediate error.
- By Firebird 2.x implementation - it would instead do those updates one after another, overwriting previous updates, and only the last candidate row would have their result persisted.