Can we fire database query while flagging the node?
According to The Flag 3.x API (PHP)


mymodule_flag_flag($flag, $content_id, $account, $flagging) {
  // Do something in response to the flagging.
}

mymodule_flag_unflag($flag, $content_id, $account, $flagging) {
  // Do something in response to the unflagging.
}



In your case

mymodule_flag_flag($flag, $content_id, $account, $flagging) {

  if ($flag-&gt;name == 'pick_this_bid'){

     $nid = $content_id;
     db_update('my_table')
       -&gt;expression('status', '0')
       -&gt;condition('nid', $nid)
       -&gt;execute();
  }

}