• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException: ORA-00911: invalid character

 
Simon Knight
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - I've got the following code in respect of an SQL query:



Which when run produces the following (for a specific instance of the query):

select PARSING_USER_ID from v$sql where SQL_TEXT like 'select LOW_OPTIMAL_SIZE, HIGH_OPTIMAL_SIZE, OPTIMAL_EXECUTIONS, ONEPASS_EXECUTIONS, MULTIPASSES_EXECUTIONS, TOTAL_EXECUTIONS from GV$SQL_WORKAREA_HISTOGRAM where INST_ID = USERENV('Instance')'

This also has the unfortunate result of causing a "java.sql.SQLException: ORA-00933: SQL command not properly ended" exception. I don't understand this as the query looks fine to me, and when cut and paste into SQLDeveloper works fine...

Can anyone tell me, why won't it work in JDBC and is there a work around?
 
Pavel Cherkashin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The point is in preparation of statement. Avoid using string concatination, when You put params into query.
For instance:

if SQLtext contains some invalid characters, jdbc driver translates
them to correct SQL escape symbols. But in your case all characters will be pasted into query as is.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic