1

I have this SQL Code. It just runs fine when i run this from the SQL Developer. I have a need to execute from my groovy script

sql.executeInsert("INSERT INTO s_status (C_DATE, sl_id, st_id, PARENT_st_id, STATUS, DETAILS, ACTIVE_IND) SELECT cd.cc_date, sl_id, st_id+1 st_id, st_id parent_st_id, 'CONFIRMED' status, 'SQL' details, 'Y' active_ind FROM s_status ss JOIN v_c_dates cd ON 1=1 WHERE (sl_id, st_id) IN (SELECT sl.sl_id, MAX(st_id) st_id FROM s_status ss JOIN stats sl ON ss.sl_id = sl.sl_id JOIN site si ON si.site_id = sl.site_id JOIN orders d ON d.ord_id = si.ord_id GROUP BY sl.sl_id ) and ss.active_ind = 'N' and ss.status = 'SENT'")

I see this error in my groovy console when i run this from groovy. Help me figuing the error

java.sql.SQLException: ORA-00933: SQL command not properly ended

2 Answers 2

1
INSERT INTO s_status (C_DATE, sl_id, st_id, PARENT_st_id, STATUS, DETAILS, ACTIVE_IND) 
SELECT cd.cc_date, sl_id, st_id+1, st_id, 'CONFIRMED', 
'SQL', 'Y'
FROM s_status ss JOIN v_c_dates cd ON 1=1 
WHERE (sl_id, st_id) IN 
(SELECT sl.sl_id, MAX(st_id) --use table alias before st_id
 FROM s_status ss JOIN stats sl ON ss.sl_id = sl.sl_id
 JOIN site si ON si.site_id = sl.site_id 
 JOIN orders d ON d.ord_id = si.ord_id 
 GROUP BY sl.sl_id) 
and ss.active_ind = 'N' and ss.status = 'SENT'

You don't need aliasing in the select statement. Modified your statement accordingly. You also need to look at the comment in the code where you need to use a table alias.

Sign up to request clarification or add additional context in comments.

Comments

0

I've had several cases where ORA-00933 was caused by case sensitivity. Be sure the table and column name references match the schema.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.