Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:42:53+00:00 2026-06-07T12:42:53+00:00

While this works as expected: SQL> DROP TABLE TEST1; Table dropped. SQL> CREATE TABLE

  • 0

While this works as expected:

SQL> DROP TABLE TEST1;

Table dropped.

SQL> CREATE TABLE TEST1 (COL1 INTEGER, COL2 INTEGER);

Table created.

SQL> INSERT WHEN 1=1
  2  THEN INTO TEST1 (COL1, COL2)
  3  SELECT 1, 0 FROM DUAL;

1 row created.

SQL>

I receive a strange “ORA-00918: column ambiguously defined” error attempting this with more than two columns:

SQL> DROP TABLE TEST1;

Table dropped.

SQL> CREATE TABLE TEST1(COL1 INTEGER, COL2 INTEGER, COL3 INTEGER);

Table created.

SQL> INSERT WHEN 1=1
  2  THEN INTO TEST1 (COL1, COL2, COL3)
  3  SELECT 1, 0, 0 FROM DUAL;
THEN INTO TEST1 (COL1, COL2, COL3)
          *
ERROR at line 2:
ORA-00918: column ambiguously defined

SQL>

Why am I receiving ORA-00918 errors here? Is there a limit on how many columns I can SELECT in an INSERT WHEN … THEN INTO … SELECT pattern?

Note: I’m using Oracle 11.2.0.1.0, and the actual query I’m attempting to execute in production is more complex and references other tables (and using “VALUES” would not suffice). This is just the simplified case…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:42:56+00:00Added an answer on June 7, 2026 at 12:42 pm

    Use aliases :

    SQL> CREATE TABLE TEST1(COL1 INTEGER, COL2 INTEGER, COL3 INTEGER);
    
    Table created.
    
    SQL> INSERT WHEN 1=1
      2    THEN INTO TEST1 (COL1, COL2, COL3)
      3    SELECT 1 "1", 0 "2", 0 "3" FROM DUAL;
    
    1 row created.
    

    The reason you get this ambiguous column error is because when you don’t provide an alias, Oracle will use a set of rules to name each column. In this case the second and third columns have the same name ("0") and thus can not be referenced unambiguously by the outer query:

    SQL> SELECT 1, 0, 0 FROM DUAL;
    
             1          0          0
    ---------- ---------- ----------
             1          0          0
    

    Oracle doesn’t look at the data values when performing semantic analysis.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This works as expected: byte b = 7; var i = (int)b; While this
While this works as expected: trait A trait B extends A object C extends
If a is undefined, this works: if(window.a) {} while this throws an error: if(a)
I have the following code: Bear in mind that while this code works on
Why does this work well: cout << foo; While this doesn't? (&cout)->operator<<(foo); It works
I'm searching a while for this and I can't found something that works for
I have PHP script works without problems, like this : while($row4 = mysql_fetch_array($result4)) {
This foreach loop works fine while testing and only returning 5 rows of data,
This is a problem where firefox works just fine, while chrome has the problem.
I have seen this answer https://stackoverflow.com/a/9243472/563381 And while it works well visual as soon

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.