create service "session"
type 'raw'
authorization off
user DBA
as call sp_session();
create or replace procedure sp_session()
begin
declare body long varchar;
declare sesid long varchar;
declare newsesid long varchar;
declare createtm timestamp;
declare lastaccesstm timestamp;
select connection_property('sessionid') into sesid;
if HTTP_VARIABLE('delete') is not null then
call sa_set_http_option('SessionID', null );
set body = '
Deleted ' || sesid|| 'Start Again';
select body;
end if;
if sesid = '' then
set newsesid = set_session();
create variable request_count int;
set request_count = 0;
set body = '
Created sessionid ' || newsesid|| ' Enter into Session';
else
select connection_property('sessionid') into sesid;
set request_count = request_count +1;
select connection_property('sessioncreatetime') into createtm;
select connection_property('sessionlasttime') into lastaccesstm;
set body = '
Session ' || sesid || ''|| 'created ' || createtm || ''
|| 'last access ' || lastaccesstm || ''
|| '
REQUEST COUNT is '|| request_count || '
'
|| ' Enter into Session'
|| ' Delete Session';
end if;
select body;
end;