Hello,
I'm using PostgreSQL. As part of a migration, I want to add a column to an existing table, create a sequence, populate the column from elsewhere, and then set the sequence to start at the maximum of the initial values just used to populate that column. (The sequence will then be used to provide future values for that column.) To set the sequence, I need to execute:
SELECT setval('job_our_ref_seq', (SELECT max(our_ref) FROM job));
ERXJDBCUtilities.executeUpdate() doesn't seem happy about executing a SELECT (and getting a result). This is the best I could come up with:
ERXJDBCUtilities.executeQuery(database.adaptorChannel(), "SELECT setval('" + Job.OUR_REF_SEQ_NAME + "', (SELECT max(our_ref) FROM job))", new ERXJDBCUtilities.IResultSetDelegate() { @Override public void processResultSet( EOAdaptorChannel adaptorChannel, ResultSet rs) throws Exception { return; } });
While that works, it seems unwieldy—I just want to discard the result. Is there a better way?
|