0

I have SYSTEM_SQL_CHECK table in which i have saved sql in CHECK_SQL column. This column is Varchar data type. Now i want to update particular sql.I have written below update sql query but it gives an error SQL Error: ORA-00933: SQL command not properly ended. I also tried to query with double quote but then it gives an error as SQL Error: ORA-00972: identifier is too long.

    Update RATOR_MONITORING_CONFIGURATION.SYSTEM_SQL_CHECK SET CHECK_SQL = 'select count(*) as CNT from O2_SDR_Header
where id = (select max(id) from O2_SDR_Header where id > 2012000000000000 and sp_id = 'SP602') 
And sp_id = 'SP602' and FILE_CREATED_DATE > (SYSTIMESTAMP - INTERVAL '2' HOUR)'
WHERE SYSTEM_SQL_CHECK_ID = 604;
1
  • 2
    String literals need to be enclosed in single quotes in SQL. Please read the manual (the chapter "Basic Elements of Oracle SQL") Commented Jun 16, 2015 at 13:43

2 Answers 2

3

This code should be like this : sp_id = 'SP602' to sp_id = ''SP602''

and this '2' to ''2''

your final code should be like this

 Update RATOR_MONITORING_CONFIGURATION.SYSTEM_SQL_CHECK SET CHECK_SQL = 'select count(*) as CNT from O2_SDR_Header
where id = (select max(id) from O2_SDR_Header where id > 2012000000000000 and sp_id = ''SP602'') 
And sp_id = ''SP602'' and FILE_CREATED_DATE > (SYSTIMESTAMP - INTERVAL ''2'' HOUR)'
WHERE SYSTEM_SQL_CHECK_ID = 604;
Sign up to request clarification or add additional context in comments.

Comments

0

you need to escape you single quote, as below

Update RATOR_MONITORING_CONFIGURATION.SYSTEM_SQL_CHECK SET CHECK_SQL = "select count(*) as CNT from O2_SDR_Header
where id = (select max(id) from O2_SDR_Header where id > 2012000000000000 and sp_id = ''SP602'') 
And sp_id = ''SP602'' and FILE_CREATED_DATE > (SYSTIMESTAMP - INTERVAL '2' HOUR)"
WHERE SYSTEM_SQL_CHECK_ID = 604;

6 Comments

As i mentioned in my query when i tried to use double quote i am getting an error as SQL Error: ORA-00972: identifier is too long
@Rahul - it isn't a double-quote (") around the text literals, it's two single quotes ('''). Very different. Also consider the alternative quoting mechanism for text literals. You need to escape the quotes around the '2' interval value too.
Ohh sorry Alex but i tried the above query also and it gives me the same identifier error.
@Rahul the 2 should be fixed also add ''2''
This is still wrong. The whole literal needs to be put in single quotes, not double quotes.
|

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.