I cannot seem to set the proper type in a prepared statement. This code:
String sql = "delete from foo where ctid = ?";
PreparedStatement deleteStmt = conn.prepareStatement( sql );
deleteStmt.setString(1, "(0,43)"); // select ctid from foo shows (0,43) exists....
int a = deleteStmt.executeUpdate();
throws this exception:
org.postgresql.util.PSQLException: ERROR: operator does not exist: tid = character varying
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts. Position: 28
Note that from psql, the delete works using a string:
mydb=# DELETE FROM foo where ctid = '(0,43)';
DELETE 1
What is the proper type/encoding for a tid in a JDBC PreparedStatement? I have tried setRowId() (throws ava.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc4.Jdbc4PreparedStatement.setRowId(int, RowId) is not yet implemented.) and setBytes() (throws ...operator does not exist: tid = byte)
deleteStmt.setObject(1, "(0,43)");? What exception does it throw?setString(1, "(0,43)::ctid")or don't use a PreparedStatement and use a dynamic SQL.