1. when a DB2 stored proc is called from java/some other client, the necessity to use a temp table in stored proc arises only when u are returning a result set to the calling module.
So If ur passing back a result set stored in a temp table then;
Two types of temp table can be created in db2(for this purpose)
1. Global temp table : these are temp tables which are present in the database but will not occupy any space. data is put in to them when the stored proc executes and then data is wiped off...thus it does not occupy more memory
2. another type is creating a temp table using JCL which would exist only when the process runs and at the end of process the table itself is wiped out
Note: In 1, the table exists and only data is wiped out whereas in 2 table and data are wiped out.
If u want to know to use temp tables in a stored proc.......send me a PM.