SETUSER not allowed in procedures, triggers, events or batches

Item Value
SQLCODE -877
Constant SQLE_SETUSER_NOT_IN_PROCEDURES
SQLSTATE 42W09
Sybase error code 13888
ODBC 2 State ERROR
ODBC 3 State ERROR

Probable cause 

The SETUSER statement is not allowed in stored procedures, triggers, event handlers or batches. It cannot be executed via EXECUTE IMMEDIATE.