create or replace package CSMP_LOGINUSERINFO
Authid current_user
is
procedure PRO_ADD_LOGINUSERINFO
(
memberaccount in VARCHAR2, --成员账号
eccode in VARCHAR2, --集团客户编码
token in VARCHAR2, --令牌
logintime in VARCHAR2, --登录时间
logouttime in VARCHAR2 default null, --退出时间
onlinetime in NUMBER default null, --在线时长
clienttype in VARCHAR2, --登录方式0表示wap客户端1表示web客户端2表示cs客户端
tableDate in VARCHAR2, --建表的时间
result out VARCHAR2 --处理结果
);
END CSMP_LOGINUSERINFO;
/
commit;
create or replace package body CSMP_LOGINUSERINFO
as
procedure PRO_ADD_LOGINUSERINFO
(
memberaccount in VARCHAR2, --成员账号
eccode in VARCHAR2, --集团客户编码
token in VARCHAR2, --令牌
logintime in VARCHAR2, --登录时间
logouttime in VARCHAR2 default null, --退出时间
onlinetime in NUMBER default null, --在线时长
clienttype in VARCHAR2, --登录方式0表示wap客户端1表示web客户端2表示cs客户端
tableDate in VARCHAR2, --建表的时间
result out VARCHAR2 --处理结果
)
as
totality integer; --记录新表的数量
newTabName varchar2(40); --新表名称
createTabStr varchar(1000); --创建新表的语句
insertStr varchar(1000); --插入记录的语句
begin
--默认成功操作码
result := 'true';
newTabName := 'CSMP_LOGININFO_'||tableDate;
--查询今天用户登录信息表的总数量
select count(0) into totality from user_tables where table_name = newTabName;
if totality <= 0
then
createTabStr := 'create table '||newTabName||'
(
ID VARCHAR2(20) not null,
TOKEN VARCHAR2(64) not null,
MEMBERACCOUNT VARCHAR2(64) not null,
ECCODE VARCHAR2(32) not null,
LOGINTIME DATE not null,
LOGOUTTIME DATE,
ONLINETIME NUMBER,
CLIENTTYPE VARCHAR2(32) not null,
constraint PK_'||newTabName||' primary key (ID)
)';
execute immediate createTabStr;
end if;
insertStr := 'insert into '||newTabName||'
(id,memberaccount,eccode,token,logintime,logouttime,onlinetime,clienttype)
values
(csmp_logininfo_seq.nextval,'''
|| memberaccount||''','''
||eccode||''','''
||token||''','
||'to_date('''||logintime||''',''yyyy-mm-dd hh24:mi:ss'')'||','
||'to_date('''||logouttime||''',''yyyy-mm-dd hh24:mi:ss'')'||','''
||onlinetime||''','''
||clienttype||''')';
execute immediate insertStr;
exception
when others THEN
result := 'false';
commit;
END PRO_ADD_LOGINUSERINFO;
END CSMP_LOGINUSERINFO;
/
commit;
存储过程中创建表
最新推荐文章于 2023-08-29 22:22:17 发布