<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_vpc_entry(nexus_ips, vpc_id, learned, active):
 """Change active state in vpc_allocate data base."""


    LOG.debug("update_vpc_entry called")

    session = bc.get_writer_session()

    with session.begin():
        for n_ip in nexus_ips:
            flipit = not active
            x = session.execute(
                sa.update(nexus_models_v2.NexusVPCAlloc).values({
                    'learned': learned,
                    'active': active}).where(sa.and_(
                        nexus_models_v2.NexusVPCAlloc.switch_ip == n_ip,
                        nexus_models_v2.NexusVPCAlloc.vpc_id == vpc_id,
                        nexus_models_v2.NexusVPCAlloc.active == flipit
                    )))
            if x.rowcount != 1:
                raise c_exc.NexusVPCAllocNotFound(
                    switch_ip=n_ip, vpc_id=vpc_id, active=active)