1.Java代码执行oracle,update和insert语句卡住不动
解决方法:造成这样的情况原因在于你之前执行了update或insert操作但你并没有commit,导致你操作的这条记录被oracle锁住,后面就无法update或insert。
1:可能你是在PLSQL中操作的,commit一下
2:查询锁定:SELECT s.sid, s.serial# FROM v$locked_object lo, dba_objects ao, v$session s WHERE ao.object_id = lo.object_id AND lo.session_id = s.sid;
删除锁定:ALTER system KILL session 'SID,serial'
2.ORACLE插入时间对象
insert into SY_COMM_CONFIG (CONF_ID, S_MTIME )
values('12345',to_char(sysdate,'YYYY-MM-DD HH24:MI:SS')
选择ORACLE里面的系统时间 SELECT SYSDATE FROM DUAL;
3.CASE WHEN过滤多行数据
SELECT TLB_ID, TO_CHAR(AUDIT_DATE, 'YYYY-MM-DD HH24:MI:SS') AS AUDIT_DATE, AUDIT_RESULT, (case when AUDIT_PROCESS = '111' then '1' /*待处理*/ when AUDIT_PROCESS in ('118', '211', '212', '213', '221', '222', '223', '231', '239', '218', '228') then '2' /*审核中*/ when AUDIT_PROCESS in ('311', '312') then '3' /*合同确认中*/ when AUDIT_PROCESS in ('411', '412', '413', '414', '419', '421', '422') then '4' /*放款处理中*/ when AUDIT_PROCESS = '423' then '5' /* 已放款*/ when AUDIT_PROCESS = '999' then '6' /*已结束*/ else AUDIT_PROCESS end) as HEAD_PROCESS from TLB_APPLY_AUDIT_RECORD where 1 = 1 and TLB_ID = :TLB_ID and TLB_TYPE = '1' and AUDIT_RESULT != '-1' ORDER BY AUDIT_DATE DESC ;
4.插入数据,并且插入的数据为两段字符串拼接起来的
拼接符号是||,前面是算随机数,后面是截取号码后四位
INSERT INTO T_SCRM_DB_APP_USER (LOGIN_NAME, PASSWORD, MOBILE_PHONE, USER_NAME, USER_ID ,ID) VALUES (138171228888, 123456, 138171228888, '刘德华', 420117198910226789,(trunc(dbms_random.value(1000,9999))||substr('138171228888', -4))) ;