Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Question Unanswered: Error; ORA-00905: missing keyword.

    Can someone tell me where I'm going wrong?

    INSERT into "HR"."BALANCE" ("CUSTOMER_ID","LAST", "FIRST", "TOTAL_BALANCE")
    select "HR"."CUSTOMER"."CUSTOMER_ID", "HR"."CUSTOMER"."LAST", "HR"."CUSTOMER"."FIRST", SUM("HR"."ORDERS"."PRICE")
    FROM "HR"."CUSTOMER" INNER JOIN "HR"."ORDERS"
    WHERE "HR"."CUSTOMER"."CUSTOMER_ID" eq "HR"."ORDERS"."CUSTOMER_ID"

  2. #2
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Hi,

    First check the select statement in isolation from the insert statement. I think you'll find you need to do a group by on the selected columns.

    PHP Code:
    select "HR"."CUSTOMER"."CUSTOMER_ID",   
           
    "HR"."CUSTOMER"."LAST"
           
    "HR"."CUSTOMER"."FIRST"
           
    SUM("HR"."ORDERS"."PRICE")
    FROM   "HR"."CUSTOMER" INNER JOIN "HR"."ORDERS"
    WHERE  "HR"."CUSTOMER"."CUSTOMER_ID" eq "HR"."ORDERS"."CUSTOMER_ID"
    GROUP BY "HR"."CUSTOMER"."CUSTOMER_ID",   
             
    "HR"."CUSTOMER"."LAST"
             
    "HR"."CUSTOMER"."FIRST" 
    Second, I'm not sure if it is required, but in the context of an insert into... I would also put brackets () around the entire select statement. Otherwise, how would Oracle know if the WHERE clause is part of the insert or select?

    Hth
    Bill
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

  3. #3
    Join Date
    Mar 2004
    Posts
    3

    That did the trick...

    Thanks for the information... that did the trick...


    Howard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •