转至繁体中文版     | 网站首页 | 文章中心 | 下载中心 | 图片中心 | 笑话频道 | 教程频道 | 会员中心 | 雁过留声 | 
最新公告:     "MinTao学以致用网"欢迎您的光临,你的支持便是我们的动力,欢迎广大网友和各界人士亲临指导,你们的一个小小的建议便是我们发展的开路石!  [MinTao  2007年9月5日]        
您现在的位置: MinTao学以致用网 >> 文章中心 >> 电子课堂 >> 数据库 >> Sql Server >> 文章正文
专题栏目
更多内容
最新推荐 更多内容
相关文章
eclipse下tanghan plugi
ASP 中连接 Mssql的几种
查看 MSSQL  数据空间分
A problem when connect
eclipse下tanghan plugi
Hibernate middlegen中m
Tomcat5+Mssql server 2
更多内容
一次编程实践[ASP+MSSQL]         
一次编程实践[ASP+MSSQL]
作者:zlx_1012 文章来源:不详 点击数: 更新时间:2007-11-14 12:59:50
bsp;  (ProductID nvarchar(6))
        DECLARE @YesterdayOfCheckDate smalldatetime
        SET @YesterdayOfCheckDate = DATEADD(day, -1, @CheckDate)

        --保存该日生产的产品ID号
        INSERT @ProductIDList
        select distinct LEFT(productid, 4) + ''''00'''' as productid from yuancaiFlow_view
        where productiondate = @CheckDate
        and productid like ''''01____''''

        --正常工序为hj->sx->jt->ph->zj
        INSERT @FlowSubsistenceList
        select a.productid,
        b.productname,
        isnull(hj.GoodQty, 0) as hj_good,
        isnull(hjtoday.qty, 0) as hj_today,
        isnull(hjyesterday.qty, 0) hj_yesterday,
        0 - (isnull(hj.GoodQty, 0) - isnull(hjtoday.qty, 0) + isnull(hjyesterday.qty, 0) - isnull(sx.GoodQty, 0) - isnull(sx.BadQty, 0)) as hj_difference,
        isnull(sx.GoodQty, 0) as sx_good,
        isnull(sx.BadQty, 0) as sx_bad,
        isnull(sxtoday.qty, 0) as sx_today,
        isnull(sxyesterday.qty, 0) sx_yesterday,
        0 - (isnull(sx.GoodQty, 0) - isnull(sxtoday.qty, 0) + isnull(sxyesterday.qty, 0) - isnull(jt.GoodQty, 0) - isnull(jt.BadQty, 0)) as sx_difference,
        isnull(jt.GoodQty, 0) as jt_good,
        isnull(jt.BadQty, 0) as jt_bad,
        isnull(jttoday.qty, 0) as jt_today,
        isnull(jtyesterday.qty, 0) jt_yesterday,
        0 - (isnull(jt.GoodQty, 0) - isnull(jttoday.qty, 0) + isnull(jtyesterday.qty, 0) - isnull(ph.GoodQty, 0) - isnull(ph.BadQty, 0)) as jt_difference,
        isnull(ph.GoodQty, 0) as ph_good,
        isnull(ph.BadQty, 0) as ph_bad,
        isnull(phtoday.qty, 0) as ph_today,
        isnull(phyesterday.qty, 0) ph_yesterday,
        0 - (isnull(ph.GoodQty, 0) - isnull(phtoday.qty, 0) + isnull(phyesterday.qty, 0) - isnull(zj.GoodQty, 0) - isnull(zj.BadQty, 0)) as ph_difference,
        isnull(zj.GoodQty, 0) as zj_good,
        isnull(zj.BadQty, 0) as zj_bad
        from @ProductIDList as a,
        finishedproduct as b,
        yuancaiFlow_view as hj,
        basflowsubsistence as hjtoday,
        basflowsubsistence as hjyesterday,
        yuancaiFlow_view as sx,
        basflowsubsistence as sxtoday,
        basflowsubsistence as sxyesterday,
        yuancaiFlow_view as jt,
        basflowsubsistence as jttoday,
        basflowsubsistence as jtyesterday,
        yuancaiFlow_view as ph,
        basflowsubsistence as phtoday,
        basflowsubsistence as phyesterday,
        yuancaiFlow_view as zj
        where a.productid = b.productid
        --hj
        and hj.productiondate = @CheckDate
        and left(a.productid, 4) *= left(hj.productid, 4)
        and hj.productid like ''''____06''''  
        and left(a.productid, 4) + ''''06'''' *= hjtoday.productid
        and hjtoday.checkdate = @CheckDate
        and left(a.productid, 4) + ''''06'''' *= hjyesterday.productid
        and hjyesterday.checkdate = @YesterdayOfCheckDate
        --sx
        and sx.productiondate = @CheckDate
        and left(a.productid, 4) *= left(sx.productid, 4)
        and sx.productid like ''''____08''''  
        and left(a.productid, 4) + ''''08'''' *= sxtoday.productid
        and sxtoday.checkdate = @CheckDate
        and left(a.productid, 4) + ''''08'''' *= sxyesterday.productid
        and sxyesterday.checkdate = @YesterdayOfCheckDate
        --jt
        and jt.productiondate = @CheckDate
        and left(a.productid, 4) *= left(jt.productid, 4)
        and jt.productid like ''''____07''''  
        and left(a.productid, 4) + ''''07'''' *= jttoday.productid
        and jttoday.checkdate = @CheckDate
        and left(a.productid, 4) + ''''07'''' *= jtyesterday.productid
        and jtyesterday.checkdate = @YesterdayOfCheckDate
        --ph
        and ph.productiondate = @CheckDate
        and left(a.productid, 4) *= left(ph.productid, 4)
        and ph.productid like ''''____09''''  
        and left(a.productid, 4) + ''''09'''' *= phtoday.productid
        and phtoday.checkdate = @CheckDate
        and left(a.productid, 4) + ''''09'''' *= phyesterday.productid
        and phyesterday.checkdate = @YesterdayOfCheckDate
        --zj
        and zj.productiondate = @CheckDate
        and left(a.productid, 4) *= left(zj.productid, 4)
        and zj.productid like ''''01__11''''
        RETURN
END
GO

ASP端与SQL端意外地解耦合了:

Dim rsCheckList
Set rsCheckList = Server.CreateObject("ADODB.Recordset")
rsCheckList.ActiveConnection = oConn
rsCheckList.Open"select * from dbo.fn_GetGLSubsistenceList(''''"&datCheckDate&"'''')"

这次编程实践让我得到一个ASP开发的新思路:
用视图+函数封装数据库端,ASP端只调用函数,这样做最大的好处是平台移植更加方便了,并且对ASP程序员的数据库知识要求也降低了。

上一页  [1] [2] 

文章录入:mintao    责任编辑:mintao 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007 MinTao学以致用网(www.mintao.net) Inc All Rights Reserved.
    QQ:543098146有事请Q我! QQ:261561092有事请Q我 QQ:179647303有事请Q我 MSN:min906@126.com
    站长:MinTao 信息产业部ICP备案号:鄂ICP备07500065号

    学以致用是我们学习者的至高境界和不懈追求,[MinTao学以致用网]与大家共同学习,共同进步……
    信息产业部备案
    *鄂ICP备07500065号