2 qq 24936749 qq_24936749 于 2017.09.03 09:51 提问

等待资源被锁死,存储过程和触发器爆发逻辑错误。
 --创建读取登录用户信息的存储过程
CREATE OR REPLACE PROCEDURE
sel_user(loginname IN VARCHAR2, psw IN VARCHAR2, 
         username OUT VARCHAR2, telephone OUT VARCHAR2, email OUT VARCHAR2, 
         gentime OUT VARCHAR2, logintime OUT VARCHAR2, lasttime OUT VARCHAR2, 
         times OUT NUMBER)
IS
BEGIN
 SELECT Username, Mobile, Email, to_char(Gen_Time,'yyyy-mm-dd hh24:mi:ss'), to_char(login_time,'yyyy-mm-dd hh24:mi:ss'), to_char(last_login_time,'yyyy-mm-dd hh24:mi:ss'), count 
 INTO username, telephone, email, gentime, logintime, lasttime, times
 FROM TUser
 WHERE login_name=loginname AND password=psw;
 UPDATE TUser SET count = times+1 WHERE login_name=loginname AND password=psw; 
END sel_user;

--创建记录与登录时间相关的触发器
CREATE OR REPLACE TRIGGER tr_login
BEFORE UPDATE OF count
ON TUser
FOR EACH ROW
DECLARE 
 PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
  UPDATE TUser SET last_login_time = :OLD.login_time WHERE login_name = :OLD.login_name;
  UPDATE TUser SET login_time = SYSDATE WHERE login_name = :OLD.login_name;
 COMMIT;
END tr_login;

这是一段涉及JDBC的sql语句,我想通过执行存储过程并更改登陆次数从而通过触发器达到最近登录时间和登录时间的修改,但总爆发资源等待被锁死,求问各位怎么改进?

2个回答

devmiao
devmiao   Ds   Rxr 2017.09.03 22:31
已采纳
sunbocong
sunbocong   2017.09.06 19:58

存储过程的update未commit?

Csdn user default icon
上传中...
上传图片
插入图片