📄 261.html
字号:
<STYLE type=text/css>
<!--
body,td { font-size:9pt;}
hr { color: #000000; height: 1px}
-->
</STYLE>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD><TITLE>精选文章 >> Oracle 专栏 >> 快照和触发子结合使用的例子</title>
</head>
<body >
<p><IMG SRC="../image/jsp001_middle_logo.gif" WIDTH="180" HEIGHT="60" BORDER=0 ALT=""></p>
<table width=100% bgcolor="#cccccc" align=center cellpadding="2" cellspacing="0" border=1 bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr bgcolor="#EFF8FF"><td>
<a href=http://www.jsp001.com/list_thread.php?int_attribute=2>精选文章</a>
>> <a href=http://www.jsp001.com/list_thread.php?forumid=20&int_attribute=2>Oracle 专栏</a>
>> 快照和触发子结合使用的例子 [<a href=http://www.jsp001.com/forum/showthread.php?goto=newpost&threadid=261>查看别人的评论</a>]<br>
<hr><p>由 webmaster 发布于: 2001-02-05 11:39</p><p><img src="images/icons/icon5.gif" alt="Question" border=0> </p><p>软件环境: <br>1、Windows NT4.0+ORACLE 8.0.4<br>2、ORACLE安装路径为:C:\ORANT<br><br>需求说明: <br>大型商场、超市中,都会有计算机管理系统,很多都用到了Oracle数据库, 此行业中有一个商品库存管理的问题,因为商品种类特别多(超过10万种), 一般库存表中记载的是只是当日库存,那么如何记录历史库存呢? <br>实现方法: <br>SQL*Plus中<br><br>create table 当前库存表(<br> spbm char(6), --商品编码<br> kcsl number --库存数量<br> );<br><br>create table 历史库存表(<br> rq char(8), --日期<br> spbm char(6), --商品编码<br> kcsl number --库存数量<br> );<br><br> drop snapshot 计算快照;<br>create snapshot 计算快照 refresh next round(sysdate+0.5)+116/144<br>as <br> select * from dual;<br>--每天晚19:20执行,这个快照什么也不做,只是为了触发下面的触发子,因为在这个快照刷新的时候,有新记录产生<br><br><br>create or replace trigger 记录历史库存触发子 before insert on snap$_计算快照 for each row<br>begin<br> insert into 历史库存表(rq,spbm,kcsl)<br> select to_char(sysdate,'yyyymmdd'),spbm,kcsl from 当前库存表;<br>exception when others then<br> raise_application_error(-10000,'不能记录历史库存');<br>end;<br>/<br><br>以上只是一种方法,主要目的是介绍快照和触发器结合使用的方法。<br><br></p></td>
</tr>
</table>
<p>
<CENTER><a href="http://www.jsp001.com/forum/newreply.php?action=newreply&threadid=261">点这里对该文章发表评论</a></CENTER>
<p>该文章总得分是 <font color=red>0</font> 分,你认为它对你有帮助吗?
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=261&intVote=4","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>非常多</a>](<font color=red>0</font>)
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=261&intVote=2","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>有一些</a>](<font color=red>0</font>)
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=261&intVote=1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>无帮助</a>](<font color=red>0</font>)
[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=261&intVote=-1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>是灌水</a>](<font color=red>0</font>) </p>
<script language="javascript" src="http://www.jsp001.com/include/read_thread_script.php?threadid=261"></script>
<p><CENTER>
Copyright © 2001 - 2009 JSP001.com . All Rights Reserved <P>
<IMG SRC="../image/jsp001_small_logo.gif" WIDTH="85" HEIGHT="30" BORDER=0 ALT="">
</CENTER></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -