Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 
 

ORA-00947: not enough values tips

Oracle Error Tips by Burleson Consulting

 

Oracle docs note this about ORA-00947:

  • ORA-00947 not enough values

    Cause: This error occurs when a SQL statement requires two sets of values equal in number, but the second set contains fewer items than the first set. This can occur in a WHERE or HAVING clause in which a nested SELECT returns too few columns as in:

    WHERE (A,B) IN (SELECT C FROM ...)


    Another common cause of this error is an INSERT statement in which the VALUES or SELECT clause does not contain enough values needed for the INSERT, as in

    INSERT INTO EMP(EMPNO,ENAME) VALUES('JONES')


    Action: Check the number of items in each set and change the SQL statement to make them equal.

     
  • On Oracle DBA-Forums, has a great example of ORA-00947, and a resolution. 
  • Question:
  • How do I resolve ORA-00947 in this situation?
  • SQL> run 1
    1 merge into aim m1
    2 using flataim m2 on (m2.sn = m1.snam)
    3 when matched then update set m1.snam = m2.sn,
    4 m1.fnam = m2.fn, m1.lnam = m2.ln, m1.midnam = m2.mn,
    5 m1.maidn = m2.md, m1.cntry = m2.na, m1.st = m2.st,
    6 m1.city = m2.cy, m1.empt = m2.mt, m1.nick = m2.nk,
    7 m1.zip = m2.zp, m1.street = m2.rd
    8 when not matched then insert ((select aimsq.nextval from dual),
    9 m1.fnam, m1.lnam, m1.midnam,
    10 m1.maidn, m1.cntry, m1.state, m1.city, m1.nick,
    11 m1.zip, m1.street, m1.snam, m1.empt)
    12 values ( m1.fn, m2.ln, m2.mn, m2.md, m2.na, m2.st, m2.cy
    13* m2.nk, m2.zp, m2.rd, m2.sn, m2.mt);
    when not matched then insert ((select aimsq.nextval from dual),
    *
    ERROR at line 8:
    ORA-00947: not enough values

     
    Answer:

    Because the ORA-00947 error signifies that there are not enough values passing through INSERT, the insert in the aim table should match all columns.  Here is an example, using snam:

    when not matched then insert
    (m1.snam,
    m1.fnam, m1.lnam, m1.midnam,
    m1.maidn, m1.cntry, m1.state, m1.city, m1.nick,
    m1.zip, m1.street, m1.snam, m1.empt)
    values
    (imsq.nextval,
    m1.fn, m2.ln, m2.mn, m2.md, m2.na, m2.st, m2.cy,
    m2.nk, m2.zp, m2.rd, m2.sn, m2.mt);

     

    Also, keep in mind while troubleshooting for ORA-00947, that the (select aimsq.nextval from dual) needs to be on the VALUES side.

    MOSC also offers information on ORA-00947 when it occurs along with attempting to add an insert statement, with all necessary columns properly stated. Here is an example:

    SQL> create table mytab (c1 date, c2 number);

    Table created.

    SQL> insert into mytab values(to_date('01-MAY-95',1));
    insert into mytab values(to_date('01-MAY-95',1))
    *
    ERROR at line 1:
    ORA-00947: not enough values

    In this ORA-00947 case, you need to keep in mind that your parenthesis need to be meticulously placed and counted in order for ORA-00947 to be resolved.  


  •  

     

    ??
     
      
     
     
     

     
     
     

    Oracle training Excel
     
    Oracle performance tuning software 
     

     

    Burleson is the American Team

    Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

    Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

    Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                        









    Burleson Consulting

    The Oracle of Database Support

    Oracle Performance Tuning

    Remote DBA Services


     

    Copyright ? 1996 -  2014

    All rights reserved by Burleson

    Oracle ? is the registered trademark of Oracle Corporation.


    Hit Counter