Thread: Exception?

Exception?

From
Thomas Møller Andersen
Date:
Does anyone have an explanation to the following exception:

Unable to identify an operator '>=' for types 'numeric' and 'float8 You will
have to retype this query using an explicit cast

The column is: numeric(10,2)

The query is from this method:

private Collection selectInRange(BigDecimal low, BigDecimal high) throws
SQLException
{
      String selectStatement =
            "select id from mytable " +
            "where amount between ? and ?";

      PreparedStatement prepStmt = con.prepareStatement(selectStatement);

      prepStmt.setBigDecimal(1, low);
      prepStmt.setBigDecimal(2, high);
      ResultSet rs = prepStmt.executeQuery();
      ArrayList a = new ArrayList();

      while (rs.next()) {
         String id = rs.getString(1);
         a.add(id);
      }

      prepStmt.close();
      return a;
}


Re: Exception?

From
"Dave Cramer"
Date:
Thomas,

The between clause really generates a query which has a >= in it. I just
tried the same thing in psql and it worked fine.

Try the query in psql and see if it works.

Dave

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Thomas Møller
Andersen
Sent: Monday, December 03, 2001 1:35 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] Exception?


Does anyone have an explanation to the following exception:

Unable to identify an operator '>=' for types 'numeric' and 'float8 You
will have to retype this query using an explicit cast

The column is: numeric(10,2)

The query is from this method:

private Collection selectInRange(BigDecimal low, BigDecimal high) throws
SQLException {
      String selectStatement =
            "select id from mytable " +
            "where amount between ? and ?";

      PreparedStatement prepStmt =
con.prepareStatement(selectStatement);

      prepStmt.setBigDecimal(1, low);
      prepStmt.setBigDecimal(2, high);
      ResultSet rs = prepStmt.executeQuery();
      ArrayList a = new ArrayList();

      while (rs.next()) {
         String id = rs.getString(1);
         a.add(id);
      }

      prepStmt.close();
      return a;
}


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)



Re: Exception?

From
"Dave Cramer"
Date:
Thomas,

I just tried this with the latest version of the jdbc driver, and
postgres 7.1.3 without any problems.

What versions are you running

Dave

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Thomas Møller
Andersen
Sent: Monday, December 03, 2001 1:35 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] Exception?


Does anyone have an explanation to the following exception:

Unable to identify an operator '>=' for types 'numeric' and 'float8 You
will have to retype this query using an explicit cast

The column is: numeric(10,2)

The query is from this method:

private Collection selectInRange(BigDecimal low, BigDecimal high) throws
SQLException {
      String selectStatement =
            "select id from mytable " +
            "where amount between ? and ?";

      PreparedStatement prepStmt =
con.prepareStatement(selectStatement);

      prepStmt.setBigDecimal(1, low);
      prepStmt.setBigDecimal(2, high);
      ResultSet rs = prepStmt.executeQuery();
      ArrayList a = new ArrayList();

      while (rs.next()) {
         String id = rs.getString(1);
         a.add(id);
      }

      prepStmt.close();
      return a;
}


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)