现在想实现如下功能,在插入记录前检查记录的值,符合条件则让该记录正常插入,不符合,则不让插入该记录。
我使用trigger+procedure可以实现该功能吗?在TRIGGER和PROCEDURE中不采用抛出EXCEPTION的方式。
而是捕捉异常,自行处理掉

解决方案 »

  1.   

    public ActionForward downloadcx(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    //DynaActionForm upfileForm = (DynaActionForm) form;// TODO Auto-generated method stub
       String transid=(String) request.getParameter("transid");
       
       log.info("任务ID = "+transid);


    log.info("path==="+Constants.FILE_PATH);
       BufferedInputStream bis=null;
       BufferedOutputStream bos=null;
       OutputStream os=null;
       InputStream is=null;
     
       String fn=transid+"_s"+".zip";
       String filePath=Constants.FILE_PATH;
     
       log.info("filePath==="+filePath);
            try
            {
          
           File downloadFile=new File(filePath,fn);
           
           if(!downloadFile.exists()||!downloadFile.isFile())
           {
            ActionMessages errors = new ActionMessages();
    errors.add("upload", new ActionMessage("upload.errors.findcxerror"));
    super.saveErrors(request, errors);
            return mapping.findForward("finderror");
           }
           is=new FileInputStream(downloadFile);
           bis=new BufferedInputStream(is);
           os=response.getOutputStream();
           bos=new BufferedOutputStream(os);
           response.setHeader("Content-disposition","filename="+fn);
           int bytesRead=0;
           byte[] buffer=new byte[1024];
           while((bytesRead=bis.read(buffer,0,1024))!=-1)
           {
            bos.write(buffer, 0, bytesRead);
           }
           bos.flush();                       
           is.close();
           bis.close();
           os.close();
           bos.close();
            }
            catch(Exception e){
            e.printStackTrace();
                     }
                  
             return null;
              }
      

  2.   

    after insert
    for all rows
    delete from ... where ...;
    这样可以吗
      

  3.   

    貌似在TRIGGER中无法实现,不符合,则不让插入该记录,或可以立即删除该记录。
    因为TRIGGER属于插入记录这个事务,有其它在数据库中通过PL/SQL之类的功能实现该功能的吗?
    1楼乱贴的什么东东。
      

  4.   

    现在想实现如下功能,在插入一条记录前检查记录的值,符合条件则让该记录正常插入,不符合,则不让插入该记录。我使用trigger+procedure可以实现该功能吗?在TRIGGER和PROCEDURE中不采用抛出EXCEPTION的方式。而是捕捉异常,自行处理掉。貌似在TRIGGER中无法实现,“在插入一条记录前检查记录的值,不符合条件,则不让插入该记录,或立即删除该记录[/color]”这个功能。
    因为TRIGGER属于插入记录这个事务,用after insert for each row貌似无法实现,我测试过了,结果是记录依然插入进去了,因为不能靠抛出异常来使记录插入失败,可有高人知道有其它在数据库中实现该功能的吗?
      

  5.   

    自治事务automnous transaction、
    不好用,