select organization__new ( :legal_name, :name, :notes, null, :org_type_id, :reg_number, :email, :url, :user_id, :peeraddr, :package_id ); insert into organization_type_map (organization_id, organization_type_id) values (:organization_id, :oti) UPDATE organizations SET name = :name, legal_name = :legal_name, notes = :notes, reg_number = :reg_number WHERE organization_id = :organization_id UPDATE parties SET email = :email, url = :url WHERE party_id = :organization_id SELECT o.name, o.legal_name, p.email, p.url, o.notes, o.reg_number FROM organizations o, parties p WHERE p.party_id = o.organization_id and o.organization_id = :organization_id select type, organization_type_id from organization_types order by type SELECT organization_type_id as oti FROM organization_type_map WHERE organization_id = :organization_id DELETE FROM organization_type_map WHERE organization_id = :organization_id