如何添加和删除但应保留记录 [英] how to add and delete but the records should be maintained

查看:59
本文介绍了如何添加和删除但应保留记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在图书馆项目中工作.
我有两种形式,即frmBooks和frmIssueRegister
和表格书籍和问题
我在表格中的字段是:Totalcopies,IssuedCopies,LeftCopies
当我发行一本书(frmIssueRegister)并保存时,应该
在frmBooks中进行以下更改:
总份数= 10
已发行副本= 3
库中的左副本= 7

类似地,在归还我的书时,应减去:
总份数= 10
已发行副本= 2
库中的左副本= 8

请帮我!!!!!!


I m working in a library project.
I have two forms i.e frmBooks and frmIssueRegister
and tables books and Issue
My fields in table books are : Totalcopies, IssuedCopies,LeftCopies
when I m issuing a book (frmIssueRegister)and on saving it should
do the following changes in frmBooks:
Total copies= 10
Issued copies=3
Left Copies in library = 7

similarly on returning i book ,it should subtract:
Total copies= 10
Issued copies=2
Left Copies in library = 8

Please help me out !!!

推荐答案

我建​​议仅存储总份数和已发行份数.可以随时计算留在库中的副本,因此在获取数据时可以使用类似以下内容的方法:
I would advice to store only the amount of total copies and issued copies. Copies left in library can be calculated at any time so when you fetch the data you can use something like:
SELECT TotalCopies,
       IssuedCopies,
       TotalCopies - IssuedCopies AS CopiesLeft
FROM ...


最好不要使用已存储的计算字段(至少以可以修改的方式).


It''s a good rule of thumb that calculated fields should never be store (at least in a way that they can be modified).


使用更新查询,例如
当Issue
use update query like
when Issue
update frmIssueRegister set Issuedcopies=Issuedcopies+1,leftCopies=leftCopies-1 where bookid='123'


希望对您有帮助


hope it will helps you


您好,
要保持此状态,您需要在触发器之前使用
要编写触发器,请参考 [
Hi,
to maintain this u need to use before trigger
to write a trigger refer this[^]

Best luck


这篇关于如何添加和删除但应保留记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆