Home > database >  Oracle synchronous data statement
Oracle synchronous data statement

Time:10-05

Two different users, but the same table structure, has good construction of synonyms, table structure sync them now, but the synchronization and some fields in table MainRelation is empty, so I want to make a judgment when matched then the update, if MainRelation table field is empty, is out of sync, insert in the below table structure is all field structure of the two tables, now card when executed for the set if here, prompt lack=number, trouble the great spirit guide, thank you thank you,

The merge into base @ TB b
Using MainRelation c
On (b.e jycode=c.e jycode)
The when matched then
The update
Set the if (c.l ecode & lt;> "' and c.l ecode is not null) then b.l ecode=c.l ecode,
If (c.l ename & lt;> "' and c.l ename is not null) then b.l ename:=c.l ename,
If (Arthur c. reated_date & lt;> "' and Arthur c. reated_date is not null) then biggest reated_date:=Arthur c. reated_date,
If (c.u pdate_date & lt;> "' and c.u pdate_date is not null) then b.u pdated_date:=c.u pdate_date,
If (c.f lag & lt;> "' and c.f lag is not null) then b. lag=c.f lag
When not matched then
Insert
Values
(c.e jycode,
C.l ecode,
C.l ename,
Arthur c. reated_date,
C.u pdate_date,
C.f lag);

CodePudding user response:

 
Set the if (c.l ecode & lt;> "' and c.l ecode is not null) then b.l ecode=c.l ecode,
- try to this, the condition was established, the update for the new value, was not, then update to the original value (indirect achieve the purpose of not update -)
The set b.l ecode=case when c.l ecode & lt;> "' and c.l ecode is not null then c.l ecode else b.l ecode end

CodePudding user response:

The update
Set the if (c.l ecode & lt;> "' and c.l ecode is not null) then b.l ecode=c.l ecode

Rewrite into

The update
Set n b.l ecode=decode (c.l ecode, ' ', b.l ecode, c.l ecode)

CodePudding user response:

refer to the second floor sych888 response:
update
Set the if (c.l ecode & lt;> "' and c.l ecode is not null) then b.l ecode=c.l ecode

Rewrite into

The update
Set n b.l ecode=decode (c.l ecode, ' ', b.l ecode, c.l ecode)


Fix, one more N

The update
Set the if (c.l ecode & lt;> "' and c.l ecode is not null) then b.l ecode=c.l ecode

Rewrite into

The update
The set b.l ecode=decode (c.l ecode, ' ', b.l ecode, c.l ecode
  • Related