I am using migrations to normalize my postgresql backend. I needed to factor 
out some columns into a new table. the only way I thought of was to use the 
COPY command to a file then read the file back into my new table.

/*
* copies the data out to the file then
* copies it back to the new table
*/
                
ERXJDBCUtilities.executeUpdate(database.adaptorChannel(), 
"COPY (select id, c_invoice_number, c_invoice_date, c_invoice_booked_date, 't', 
" +
"'f' from t_version where c_is_invoiced)  " +
"TO '/Users/asacksadmin/Desktop/selectedInvoices.txt'");


ERXJDBCUtilities.executeUpdate(database.adaptorChannel(), 
"COPY t_invoice (c_version_id, c_invoice_number, c_invoice_date, 
c_invoice_booked_date, " +
"c_is_final_invoice, c_is_partial_invoice) " +
"FROM  '/Users/asacksadmin/Desktop/selectedInvoices.txt'");
        

        /*
         * drops the columns from the version table that are
         * no longer used
         * 
         * c_invoice_booked_date
         * c_invoice_number
         * c_invoice_date
         * 
         */
                
ERXJDBCUtilities.executeUpdate(database.adaptorChannel(), 
"ALTER TABLE t_version drop COLUMN c_invoice_booked_date");
                
ERXJDBCUtilities.executeUpdate(database.adaptorChannel(), 
"ALTER TABLE t_version drop COLUMN c_invoice_number");
                
ERXJDBCUtilities.executeUpdate(database.adaptorChannel(), 
"ALTER TABLE t_version drop COLUMN c_invoice_date"); 

so i got it to work and I am thinking, "Is there a better way?" Of course this 
leaves behind the file selectedInvoices.txt on the desktop but that is the only 
artifact left over. 

Maybe it's not so bad after all. but I thought I would ask. "Is there a better 
way?"

Ted


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

This email sent to [email protected]

Reply via email to