Dulcian Slide logo
Slide ‹#› of 37
Connection Pooling (2)
uTemporary tables cleanup
u
uprocedure p_truncate is
u   v_exist_yn varchar2(1);
uBegin
u  select 'Y' into v_exist_yn
u  from v$session s, v$tempseg_usage u
u  where s.audsid = SYS_CONTEXT('USERENV','SESSIONID')
u  and   s.saddr = u.session_addr
u  and   u.segtype = 'DATA'
u  and rownum = 1;
u  for c in (select table_name from user_table
u            where temporary = 'Y‘
u            and duration = 'SYS$SESSION') loop
u    execute immediate 'truncate table '||c.table_name;
u  end loop;
uend;
j0230785