one of the documented procedures in this installation of the ACS
chat_last_post   chat_room_id
What it does:
Returns chat_msg_id of most recent post in a room; used by JavaScript client to figure out whether an update to the main window is needed
Defined in: /web/philip/tcl/chat-defs.tcl

Source code:

    set db [ns_db gethandle subquery]
    set last_chat_msg_id [database_to_tcl_string $db "select max(chat_msg_id) 
from chat_msgs
where chat_room_id = $chat_room_id
and approved_p='t'"]
    ns_db releasehandle $db 
    return $last_chat_msg_id