Home » SQL & PL/SQL » SQL & PL/SQL » ORA-00907: missing right parenthesis
ORA-00907: missing right parenthesis [message #299644] Tue, 12 February 2008 17:53 Go to next message
zepalways
Messages: 15
Registered: February 2008
Junior Member
Hi there.

I typed this code:
INSERT INTO sales_order
(
        SELECT
                order_id,
                order_date
        FROM
                item
        ORDER BY order_id
)
;


I tried with

        SELECT
                order_id,
                order_date
        FROM
                item
        ORDER BY order_id


And that one works fine. However, when I put that first code (with INSERT statement), I get this error:

ORDER BY item.order_id,
*
ERROR at line 13:
ORA-00907: missing right parenthesis

How can I solve this??
Re: ORA-00907: missing right parenthesis [message #299651 is a reply to message #299644] Tue, 12 February 2008 18:44 Go to previous messageGo to next message
moshea
Messages: 51
Registered: February 2008
Location: Dublin, Ireland
Member
Well ask yourself this question, "In the context of the Insert statement, what exactly are you trying to say with the ORDER BY clause?"

Are you really trying to tell oracle that you want the records inserted into the table in a particular order? Or more precisely, do you really care what order they're inserted into the table. When you realise the answer is no, then look at your statement again.

Cheers,
Michael

PS : You should really always list your columns in the insert clause ie :

Quote:
INSERT INTO foo
(a,b)
(SELECT c, d
...)
Re: ORA-00907: missing right parenthesis [message #299727 is a reply to message #299644] Wed, 13 February 2008 00:49 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Note that this works if you don't put the parenthesis "insert into T1 select * from T2 order by id".
Oracle SQL inconsistencies.

Regards
Michel
Previous Topic: Schedule to execute SP's...ist possible?
Next Topic: Dynamic sql
Goto Forum:
  


Current Time: Sun Dec 04 08:37:56 CST 2016

Total time taken to generate the page: 0.12391 seconds