Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Posts
    3

    Unanswered: ORA-01745: invalid host/bind variable name

    Hi,
    I am getting the following error when using PreparedStatements and I have no clue why.

    ORA-01745: invalid host/bind variable name

    Below is the query

    StringBuffer query = new StringBuffer(
    "SELECT count(*) "
    + " from my_table "
    + " where project = ?"
    + " AND UPPER(my_no) LIKE ? ");

    PreparedStatement ps = con.createPreparedStatement( query.toString() );
    ps.setInt( 1, projectID );
    ps.setString( 2, "%"+filterString.toUpperCase()+"%" );


    ResultSet rs = ps.executeQuery();

  2. #2
    Join Date
    Dec 2003
    Posts
    3

    Re: ORA-01745: invalid host/bind variable name

    Also, none of the variables I pass in are null or invalid.

  3. #3
    Join Date
    Dec 2003
    Posts
    3

    Re: ORA-01745: invalid host/bind variable name

    Some more things I should mention...

    The 1st parameter is a NUMBER(10)
    The 2nd parameter is a VARCHAR2(25)

    I'm using Java 1.4.02
    I'm using Oracle 9.2

  4. #4
    Join Date
    Jul 2003
    Posts
    2,296
    does the query work if you plug in the variables and run it straight from sql-plus?
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  5. #5
    Join Date
    Dec 2003
    Location
    Kekaha, Kauai, Hawaii
    Posts
    22
    Do you really have "?" in the query? "?" is not a correct bind variable. Am I being too simplistic here?

  6. #6
    Join Date
    Jul 2003
    Posts
    2,296
    Originally posted by aknoble
    Do you really have "?" in the query? "?" is not a correct bind variable. Am I being too simplistic here?
    '?' should work in java

    I think you are missing the single-quotes in your LIKE clause.

    it should end up with something along these lines:
    PHP Code:
    AND UPPER(my_noLIKE '%STRING%' 
    I don't see where you are throwing in the single quotes
    - The_Duck
    you can lead someone to something but they will never learn anything ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •