When a client connects, Adaptive Server assigns a temporary database to its session. Adaptive Server uses this session-assigned temporary database as a default space where it creates temporary objects (including hashed-temporary tables and worktables) for work the client performs. The session-assigned temporary database remains assigned to the session until the session connects to the client.
Adaptive Server selects temporary databases for a session according to these rules:
If a binding already exists for a login, that binding is used.
If an application name is specified and it has a binding, use that binding.
If Adaptive Server does not find a binding, it assigns a temporary database from the default group using a round-robin scheme.
To specify that Adaptive Server creates an object in a specific temporary database. For example:
create procedure inv_amounts as select stor_id, "Total Due" = sum(amount) from #tempstores group by stor_id