sql - ORA-00905: missing keyword in a Merge statement -


i'm writing little piece of code university exercise, can't work. want join impiegato , anagrafica rows on cod when anagrafica's row has no null fields. each row of new temporary table generate string (some_string) , string value of report field in reportimpiegato table. i'm using oracle 11g , sql developer. in advance willing help. :-)

my tables are:

table impiegato cod number(4,0) nome    varchar2(40 byte) cognome varchar2(40 byte) data_assunto    date stipendio   number(8,2) capo    number(4,0)  table anagrafica cod number(4,0) datan   date sesso   char(1 byte) luogon  varchar2(80 byte) provn   char(2 byte)  table reportimpiegato cod number report  varchar2(4000 byte) 

and code is:

merge reportimpiegato r using (select * (     (select *     anagrafica     (a.datan not null , a.luogon not null , a.provn not null , a.sesso not null))      join     (impiegato i)     on (a.cod = i.cod)   )) d on (r.cod = d.cod) when matched     update set r.report = some_string when not matched     insert (cod, report) values (d.cod, some_string) 

output is:

error starting @ line : 1 in command - merge reportimpiegato r using (select * (         (select * anagrafica (a.datan not null , a.luogon     not null , a.provn not null , a.sesso not null))          join         (impiegato i)         on (a.cod = i.cod)       )) d on (r.cod = d.cod) when matched     update set r.report = some_string when not matched     insert (cod, report) values (d.cod, some_string); error @ command line : 14 column : 5 error report - sql error: ora-00905: missing keyword 00905. 00000 -  "missing keyword" *cause:     *action: 

the error message points line , character has issue. if run code posted in question reports against (12, 5), insert.

you're missing then on not-matched branch:

... when not matched    --- missing!     insert (cod, report) values (d.cod, some_string) 

the subsequent ora-00904: "d"."cod": invalid identifier because you're doing select * in using clause. if run subquery on it's own end columns called cod , cod_1, @ least in sql developer, in addition other column names both joined tables; it's client. within merge seems doing different. if do

merge reportimpiegato r using (select a.cod ( 

i.e. selecting columns need, problem goes away.

(i don't know some_string supposed coming from; may literal value in real code).


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -