postgresql7.1 select ec_products.product_id, ec_products.price, ec_category_product_map.category_id, min(sale_price) as sale_price from acs_objects, ec_products left join ec_category_product_map on ec_category_product_map.product_id=ec_products.product_id left join ec_sale_prices_current on ec_sale_prices_current.product_id=ec_products.product_id where acs_objects.context_id=:event_id and acs_objects.object_id=ec_products.product_id group by ec_products.product_id, ec_products.price, ec_category_product_map.category_id select ec_products.product_id from acs_objects, ec_products left join ec_category_product_map on ec_category_product_map.product_id=ec_products.product_id where acs_objects.context_id=:event_id and acs_objects.object_id=ec_products.product_id last_modified=current_timestamp, last_modifying_user=:user_id, modified_ip_address=:peeraddr insert into ec_category_product_map values (:product_id, :category_id, null, current_timestamp, :user_id, :peeraddr) select ec_product__new( null, :user_id, :event_id, '$activity_info(name) $date_time', :event_price, 'event_$event_id', '$activity_info(name); $date_time; $pretty_location', '$activity_info(description)', '$activity_info(name), $venue_info(venue_name), $pretty_location', 't', 'i', null, to_date(current_timestamp, 'YYYY-MM-DD'), :peeraddr ) select ec_product__delete(:product_id)