I had a simple query where I was pulling data on a user, but binding with :user, as in

select *
  from user_table u  join other_table o on u.user_id = o.user_id
 where u.user_id = :user

It took a good fifteen minutes of getting the above error (and scratching my head… and maybe a bit of cursing) before it dawned on me that the reason for this was the use of a reserved word in Oracle.  Changing the binding to :u_name worked instantly.  Other reserved words can be found here; binding on those words will cause some grief.

4 thoughts on “ORA-01745: Invalid host/bind variable name error

  1. Thanks! I just ran into this and was also scratching my head for a while. In my case I was trying to use :rowid.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.