Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ORA-00933: SQL command not properly ended 2

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
To say I'm a novice in Oracle 8i is an understatement.

I'm trying to run this code as one statement and I get the error ORA-00933: SQL command not properly ended.

If I run the insert first and then the selects it works. Why can't I run it all together. Also Table1 is a global temp table.

Code:
INSERT INTO TABLE1 
	   (ASSY_ID)
	   ( SELECT DISTINCT ASSEMBLY_ID FROM SNAPMAN.ASSY_PT)


SELECT SO.ITEM, 'HLA' TYPE 

FROM PROD.V_SHOPORDER SO, SNAPMAN.ASSY_PT AP 

WHERE SO.ITEM = AP.ASSEMBLY_ID AND SO.RELEASED_QTY > 0 

GROUP BY SO.ITEM, 'HLA' 

UNION ALL

SELECT SO.ITEM, 'OTHER' TYPE 

FROM PROD.V_SHOPORDER SO, SNAPMAN.ASSY_PT AP , TABLE1 TT

WHERE SO.ITEM = AP.COMPONENT_ID AND SO.RELEASED_QTY > 0 

AND SO.ITEM  = TT.ASSY_ID (+)--NOT IN(SELECT DISTINCT ASSEMBLY_ID FROM SNAPMAN.ASSY_PT) 

AND TT.ASSY_ID IS NULL

GROUP BY SO.ITEM, 'OTHER' ,TT.ASSY_ID
 
J,


I realise that I've wandered from the OP here. Just to be sure that it's purely a TOAD thing, could you please do the following:-

Run the first half of your union in isolation and make sure it works and returns rows to TOAD's data grid. Then add the second part and make sure that it too works and returns rows to TOAD's data grid.
Then, after the above two have succeeded, prepend the insert statement at the end and see what happens. If it is a sequencing issue, that ought to reveal it.

To really assist, I need the underlying table definitions, some sample data, and your date handling functions, so that I can create the view locally and have it compile successfully.

Regards

T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top