I have three tables User, office and a role map. The user Id will be FK to the office table against the Office manager and office head. The role and the user Id will be mapped in the role map table as shown below.
When an office is deleted, the office table's Active column will be updated to 'N'. 
When an office is deleted, I have to check if the office manager is present as office manager for any other office. (The same person can be manager for another market too)
If he is not, then I have to delete the entry in Role map table by updating the Active flag to 'N'

Table User

```
User ID | User Name |
--------------------------
1       |   Mark    |

2       |   George  |

3       |   Rick    |

4       |   Alex    |

```

Table Office

```
Office ID   | Office Name   | Office Manager| Office Head   |   Active  |
---------------------------------------------------------------------------
1           |   Off1        |   1           |   2           |   Y       |

2           |   Off2        |   1           |   4           |   Y       |

```

Role Map

```
User ID |   User Role       |   Active  |
---------------------------------------------
    1   |   Office Manager  |   Y       |

    2   |   Office Head     |   Y       |

    4   |   Office Head     |   Y       |

```

So in this example, If I delete Office 2, then I need to update the third entry in the role map table to the following 
The OFfice manager role map will be intact, as the same user is the manager for Off1 too.

Role Map -- After update 

```
User ID |   User Role       |   Active  |
-------------------------------------------
    1   |   Office Manager  |   Y       |

    2   |   Office Head     |   Y       |

    4   |   Office Head     |   N       |

```

I am unsure how to implement this query in pl/sql. can someone please guide me here?