为什么LISTAGG运营商不使用更新批量更新?

时间:2018-04-19 10:41:43

标签: jsp oracle11g

 <%
        try
        {
            String employee_id3=request.getParameter("txtemployeeid");
     if(request.getParameter("btnPunchout")!=null)
         {
      Timestamp date_out=java.sql.Timestamp.valueOf(java.time.LocalDateTime.now());
           Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection con3=DriverManager.getConnection("jdbc:oracle:thin:@172.18.114.213:1821:godb","xe","Spacess");


                 String time_out_history="UPDATE EMPLOYEE_LOGIN_TIME T1 SET T1.TIME_OUT_HISTORY=(SELECT LISTAGG(time_out,',') WITHIN GROUP (ORDER BY time_out) FROM EMPLOYEE_LOGIN_TIME WHERE EMPLOYEE_ID='" + employee_id3+"' and trunc(time_out)=trunc(SYSDATE))";
               PreparedStatement ps5=con3.prepareStatement(time_out_history);
               ps5.executeUpdate();

    %>
      <%

         String Update_Timeout="update EMPLOYEE_LOGIN_TIME set time_out=? where Employee_id='"+employee_id3+"' and trunc(punch_date)=trunc(SYSDATE)";
              PreparedStatement ps3=con3.prepareStatement(Update_Timeout);
               ps3.setTimestamp(1,date_out);
                  ps3.executeUpdate();
                  %>

    <%  String Date1="UPDATE EMPLOYEE_LOGIN_TIME T1 SET T1.WORKING_HOUR=(SELECT to_timestamp (to_char(TIME_OUT))- to_timestamp (to_char(TIME_IN)) AS WORKING_HOUR FROM EMPLOYEE_LOGIN_TIME WHERE EMPLOYEE_ID='" + employee_id3+"' and trunc(punch_date)=trunc(SYSDATE))";
              PreparedStatement ps8=con3.prepareStatement(Date1);
                   ps8.executeUpdate();  
                   %>

    <%

         out.println("<script type=\"text/javascript\">");
   out.println("alert('You are Successfully logout for the day');");
   out.println("location='EmployeeLogin.html';");
   out.println("</script>");

       }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }

    %>

现在我的问题是每当我点击退出按钮2和3没有。查询工作正常但在第一次查询中它只存储最后一次注销详细信息我想显示time_out_history列多次注销数据,就像他在特定日期所做的那样

  

19-APR-18 04.12.38.676000 PM,

     

19-APR-18 04.13.38.676000 PM,

     

19-APR-18 04.14.38.676000 PM,

     

19-APR-18 04.15.38.676000 PM

依旧......

1 个答案:

答案 0 :(得分:0)

您似乎希望使用特定的日期格式,因此您需要使用具有所需特定格式的to_char function

LISTAGG(to_char(time_out,'DD-MON-YYYY HH:MI:SS.FF AM'),',')