When doing a batch call from a Prepared Statement in Java to a function in PostGres is it possible to set the returned number.
String query = "SELECT "functionCall"(?)
PreparedStatement state = con.prepareStatement(query)
state.setString(1, "test")
state.addBatch();
int[] results = state.exectueBatch();
System.out.println(result);
Then calling:
CREATE FUNCTION "functionCall" ("test" character varying) RETURNS INTEGER AS $$
DECLARE
...
BEGIN
... Do update
IF(Update IS NOT NULL) then
return 1;
ELSE
return -3;
END IF;
END;
$$ LANGUAGE plpgsql;
According the JavaDocs a failed insert should return -3 and a success should return 0 or greater.