---
title: "总结思考"
author: "vanadiumlin"
date: "2010-08-16T14:45:42Z"
tags: []
categories: ["数据库"]
slug: "untitled"
draft: false
lastmod: "2010-09-15T16:54:12Z"
id: 738412
url: "https://vanadiumlin.iteye.com/blog/738412"
---

最近在改一个存储过程其实应该不难，但是就是遇到麻烦，

select b.store\_qty,b.wh\_code,b.part\_code  
into #po\_wh\_part  
from #tmp\_none\_store a,po\_wh\_part b  
  where  a.wh\_code = b.wh\_code and  
         a.part\_code = b.part\_code

首先是  使用了   cross join 考虑一下，这个和inner join的效率哪个比较高呢?  还有就是left join，

另外选择出来的结果， 我看到是重复的，  例如   从b选择出来同个型号的产品part\_code一样，出来两次， 但实际在b中，只有一条

 

/*                     
  首先更新小型机的库存和未发送              
\*/    
 update  #tmp\_none\_store set none\_nums = nosend\_nums - b.store\_qty,  
local\_nums = case when  nosend\_nums - b.store\_qty &lt;0 then nosend\_nums else b.store\_qty end ,  
store\_nums = case when nosend\_nums - b.store\_qty &lt;0 then  b.store\_qty -nosend\_nums else 0 end  
   from  #tmp\_none\_store a,  
   #po\_wh\_part b  
  where  a.wh\_code = b.wh\_code and  
         a.part\_code = b.part\_code and  
  a.mkind\_type='1'

 

这里出现的问题是，update语句中  none\_nums 在第二行语句中的值是否已经改变，结果是还是为初始值。看来在语句没完全执行前，他的值还是原来的。

 

 

\--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

关于dao抽象工厂模式，在项目中我们使用了hibernate这个框架，而在项目中我们经常要使用到各自不同的dao，那么我们将这种创建任务集中其他来处理，使用抽象工厂模式，DaoFactory 和 HibernateDaoFactory  那么，能不能使用接口来实现呢？  这个时候选择接口和抽象类的区别在哪里呢？  如果使用spring 的话，是用注入吧，这些问题都需要去考虑。。。。