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?


-- 
Paul Hoadley
http://logicsquad.net/


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to