• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

java.sql.SQLException: ORA-01036: illegal variable name/number

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to change an existing SQL statement and adding order by clause with Asc or Desc keyword. My query looks like this...

...///

WHERE rank BETWEEN #{startrow} AND #{endrow}
<if test="sort != null and sort != ''">
order by #{sort} #{direction}
</if>
....///

When I do not sort in the UI the query works fine. However if I sort on any fields in UI i get

### Error querying database. Cause: java.sql.SQLException: ORA-01036: illegal variable name/number
### Cause: java.sql.SQLException: ORA-01036: illegal variable name/number

; uncategorized SQLException for SQL []; SQL state [72000]; error code [1036]; ORA-01036: illegal variable name/number
; nested exception is java.sql.SQLException: ORA-01036: illegal variable name/number


I can see proper values getting passed from my controller to mapper class and the xml file. Can someone help me with this please?
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us the actual SQL statement that Oracle is receiving from this code? Because the error is being raised by the Oracle database, so you need to know what SQL Oracle is actually looking at.
reply
    Bookmark Topic Watch Topic
  • New Topic