Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ORA-00905 missing KEYWORD

Posted on 2011-02-16
18
Medium Priority
?
1,626 Views
Last Modified: 2012-06-27
i am trying execute this query
merge into CLIENTE c
using tmp_Solicitud s
on (c.CODIGOUNICO = s.CodUnico)
when not matched then
insert (
        c.CODIGOUNICO,
        c.RAZONSOCIAL,
        c.NUMERODOCUMENTO,
        c.BANCA,
        c.CODIGOGRUPO,
        c.CLASIFICACIONSBS,
        c.CLASIFICACIONFEVE,
        c.RATINGEMPRESA,
        c.SEGMENTO,
        c.CODIGOEJECUTIVO,
        c.NOMBREEJECUTIVO,
        c.CODIGOTIENDA
)
values(
        s.CodUnico,
        s.RazonSocial,
        s.NumeroDocumento,
        s.CodTipoBanca,
        s.CodGrupo,
        s.CodCalificacionSBS,
        s.CodFeve,
        s.Rating,
        s.CodSegmentacion,
        s.CodEjecutivoNegocios,
        s.DesEjecutivoNegocios,
        s.LineaCredTienda
       );
but i have this erros, missing keyword, view file
missingKEYWORD.jpg
0
Comment
Question by:enrique_aeo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 2
  • +1
18 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 34910607
you need to specify the WHEN MATCHED part also
0
 
LVL 4

Expert Comment

by:Alex Matzinger
ID: 34910658
I believe you need the

WHEN MATCHED THEN <update_clause>

but i am not positive it is required
0
 

Author Comment

by:enrique_aeo
ID: 34910693
when this happens
 WHEN MATCHED THEN
 must do nothing
 as would the code please
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Alex Matzinger
ID: 34910716
merge into CLIENTE c
using tmp_Solicitud s
on (c.CODIGOUNICO = s.CodUnico)
WHEN MATCHED THEN ( )
when not matched then
insert (
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34910742
'when matched' is NOT required.

I ran the following code using 10.2.0.3.

drop table tab1 purge;
create table tab1(col1 char(1));

drop table tab2 purge;
create table tab2(col1 char(1));

insert into tab1 values('a');
insert into tab2 values('b');

merge into tab2
using tab1 on (tab1.col1=tab2.col1)
when not matched then
	insert(col1) values('z')
/

Open in new window

0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34910760
What is your database version?
0
 

Author Comment

by:enrique_aeo
ID: 34910902
I run that code for the version of the database?
0
 

Author Comment

by:enrique_aeo
ID: 34910994
I AM USING pl/sql developer
plsqlDEVELOPER.jpg
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34911008
>>I AM USING pl/sql developer

Can you try the code you have from sqlplus?
0
 

Author Comment

by:enrique_aeo
ID: 34911100
THE SAME ERROR from sql plus
sqlPLUS.jpg
0
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 1332 total points
ID: 34911231
You are using a very early release of 9i.  In 10g "when matched" is not required.  It is in 9i.

As the others have said, you must have a WHEN MATCHED.

Try this
merge into CLIENTE c
using tmp_Solicitud s
on (c.CODIGOUNICO = s.CodUnico) 
when not matched then
insert (
        c.CODIGOUNICO,
        c.RAZONSOCIAL,
        c.NUMERODOCUMENTO,
        c.BANCA,
        c.CODIGOGRUPO,
        c.CLASIFICACIONSBS,
        c.CLASIFICACIONFEVE,
        c.RATINGEMPRESA,
        c.SEGMENTO,
        c.CODIGOEJECUTIVO,
        c.NOMBREEJECUTIVO,
        c.CODIGOTIENDA
)
values(
        s.CodUnico,
        s.RazonSocial,
        s.NumeroDocumento,
        s.CodTipoBanca,
        s.CodGrupo,
        s.CodCalificacionSBS,
        s.CodFeve,
        s.Rating,
        s.CodSegmentacion,
        s.CodEjecutivoNegocios,
        s.DesEjecutivoNegocios,
        s.LineaCredTienda
       )
when matched
       update set c.BANCA=c.BANCA;  -- pick a small insignificant column.

Open in new window

0
 

Author Comment

by:enrique_aeo
ID: 34911277
add the sentence
WHEN MATCHED THEN
(
UPDATE
SET   c.RATINGEMPRESA = s.Rating
)
but the error it is the same
plsqlDEVELOPER.jpg
0
 

Author Comment

by:enrique_aeo
ID: 34911312
the same error
sqlPLUS.jpg
0
 

Author Comment

by:enrique_aeo
ID: 34911384
i add
when matched then
but i other error, view file
sqlPLUS.jpg
0
 

Author Comment

by:enrique_aeo
ID: 34911424
after executing the statement merge lose connection, do not understand why
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34912165
9.2.0.1 was pretty buggy.  I suggest you use one of the other methods from your previos question and forget about merge.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 668 total points
ID: 34913548
I would not use MERGE when all you want to do is INSERT ..
INSERT into CLIENTE 
 ( <column list ...> )
SELECT <column list>
  FROM tmp_Solicitud s
 WHERE NOT EXISTS( SELECT NULL FROM CLIENTE c WHERE c.CODIGOUNICO = s.CodUnico)

Open in new window

0
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 1332 total points
ID: 34915713
I still prefer the 'minus' method I posted in your other question:
http://www.experts-exchange.com/Database/Oracle/Q_26826045.html?#a34909809
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question