A cursor’s existence depends on its scope, which refers to the context in which the cursor is used: within a user session, within a stored procedure, or within a trigger.
Within a user session, the cursor exists only until a user ends the session. After the user logs off, SAP ASE deallocates the cursors created in that session. The cursor does not exist for additional sessions that other users start.
create procedure proc2 @flag int as if @flag > 0 declare names_crsr cursor for select au_fname from authors else declare names_crsr cursor for select au_lname from authors return