Thanks Janusz, this worked ok but now it has tripped up on a couple more issues.
The first is the update_totals section of the alter2.3.php. This section fails with....
FATAL : sales order return nothing - etc etc.
...when trying to update the second company database I think due to this sql....
SELECT sorder.*, cust.name, cust.curr_code, loc.location_name, cust.discount, stype.sales_type, stype.id AS sales_type_id, stype.tax_included, ship.shipper_name, tax_group.name AS tax_group_name , tax_group.id AS tax_group_id FROM 0_sales_orders sorder, 0_debtors_master cust,0_sales_types stype, 0_tax_groups tax_group, 0_cust_branch branch,0_locations loc, 0_shippers ship WHERE sorder.order_type=stype.id AND branch.branch_code = sorder.branch_code AND branch.tax_group_id = tax_group.id AND sorder.debtor_no = cust.debtor_no AND loc.loc_code = sorder.from_stk_loc AND ship.shipper_id = sorder.ship_via AND sorder.trans_type = '30' AND sorder.order_no = '1'
It looks like there is a table prefix issue here because even for the second company the sql it trying to select from company 0_
The var TB_PREF seems to come from the logged in user (which when upgrading is 0_) and there seems to be other references to it which generates these errors in the error.log....
[12-Oct-2010 07:28:36] 0:admin:cart_class.inc:403:[before upgrade] Invalid argument supplied for foreach()
[12-Oct-2010 07:28:36] 0:admin:cart_class.inc:463:[before upgrade] Invalid argument supplied for foreach()
Also another issue seems to be with the trans_link column as below.
DATABASE ERROR : Parent document numbers cannot be retrieved
error code : 1054
error message : Unknown column 'trans_link' in 'field list'
sql that failed was : SELECT trans_link FROM 0_debtor_trans WHERE trans_no='5' AND type='10' AND trans_link!=0
...this I got round by deleting the call to drop the trans_link column in the alter2.3php and assume I can drop the column after the upgrade.
Welcome your thoughts.
Cheers, Steve