calendar::apm::before_uninstantiate (private)

 calendar::apm::before_uninstantiate -package_id package_id

Defined in packages/calendar/tcl/apm-callback-procs.tcl

Cleanup calendars from this package instance upon uninstantiation.

Switches:
-package_id
(required)

Partial Call Graph (max 5 caller/called nodes):
%3 calendar::delete calendar::delete (public) calendar::item::delete calendar::item::delete (public) calendar::item_type_delete calendar::item_type_delete (public) db_foreach db_foreach (public) db_list db_list (public) calendar::apm::before_uninstantiate calendar::apm::before_uninstantiate calendar::apm::before_uninstantiate->calendar::delete calendar::apm::before_uninstantiate->calendar::item::delete calendar::apm::before_uninstantiate->calendar::item_type_delete calendar::apm::before_uninstantiate->db_foreach calendar::apm::before_uninstantiate->db_list

Testcases:
No testcase defined.
Source code:
    # get calendar ids
    set calendar_list [db_list get_calendar_ids {
        SELECT calendar_id FROM calendars
         WHERE package_id = :package_id
    }]
    # delete calendars
    foreach calendar_id $calendar_list {
        # delete all calendar items
        db_foreach get_calendar_items {
            SELECT cal_item_id FROM cal_items
             WHERE on_which_calendar = :calendar_id
        } {
            calendar::item::delete -cal_item_id $cal_item_id
        }
        # delete item types
        db_foreach get_item_types {
            SELECT item_type_id FROM cal_item_types
             WHERE calendar_id= :calendar_id
        } {
            calendar::item_type_delete -calendar_id $calendar_id -item_type_id $item_type_id
        }
        # delete calendar
        calendar::delete -calendar_id $calendar_id
    }
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/calendar/tcl/apm-callback-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: