select aa.attribute_id, coalesce(aa.column_name, aa.attribute_name) as column_name, aa.default_value, coalesce(aa.table_name,at.table_name) as table_name, aa.storage, aa.datatype, aa.sort_order, aa.attribute_name, aa.pretty_name, aa.pretty_plural from acs_attributes aa, ca_attributes ca, acs_object_types at where aa.attribute_id = :attribute_id and aa.attribute_id = ca.attribute_id and (ca.package_id = :package_id or ca.sitewide_p = 't') and aa.object_type = :content_type and at.object_type = :content_type select widget, label, html_options, select_options, validate, optional_p, enabled_p from ca_attribute_widget_values where attribute_id=:attribute_id select distinct datatype, datatype from acs_attributes order by datatype select max(sort_order) as sort_order from acs_attributes select widget, widget from ca_attribute_widgets order by widget update acs_attributes set pretty_name = :pretty_name, pretty_plural = :pretty_plural, sort_order = :sort_order, default_value = :default_value where attribute_id = :attribute_id ` update ca_attribute_widget_values set label = :label, html_options = :html_options, select_options = :select_options, keyword_id = :keyword_id, extra_options = :extra_options, validate = :validate, optional_p = :optional_p, enabled_p = :enabled_p where attribute_id = :attribute_id