关于多张表的删除 ( 积分: 10 )

  • 主题发起人 主题发起人 admin2008
  • 开始时间 开始时间
A

admin2008

Unregistered / Unconfirmed
GUEST, unregistred user!
我用视图查找的数据显示在dbgrid控件里 当我选中表中的一行就删除 我知道视图是不能作为删除的 我的视图是这样的 ,请问删除dbgrid中某条数据应怎么样做呢
create view v_inhouse_find
as
select c.IN_DATE as 入库日期,
a.yaoid as 药品ID,
a.pm as 品名,
a.tym as 通用名,
a.gg as 规格,
a.cj as 厂家,
a.dw as 单位,
b.ph as 批号,
b.mount as 数量,
b.cgdj as 采购单价,
b.cgje as 金额,
b.teshu as 标志 ,
d.vendor_name as 供货单位,
d.vendor_id ,
b.huowei as 货位,
b.hege as 有无合格证,
b.waibao as 外观质量,
b.jielun as 验收结论,
b.yxq as 有效期,
c.IN_ID as 入库单号,
c.invoice_DATE 发票日期,
c.DESCRIPTION ,
b.xsdj1 as 销售价,
b.hyj1 as 会员价,
xsdj3 as 促销提成,
e.stff_name as 验收人,
e.stff_id,
f.user_name as 操作员,
f.user_id,
b.scrq as 生产日期,
a.zbm as 自编码,
a.zjf as 助记码,
b.memo1 as 备注,
a.type1 as 商品种类,
a.type2 as 药品分类,
a.type3 as 自定义分类
from yaoid a,inhouse b,inhead c,vendor d,staff e,appuser f
where a.yaoid=b.yaoid and b.in_id=c.in_id and c.stff_id=e.stff_id and c.user_id=f.user_id and d.vendor_id=c.vendor_id

 
逐表删除吧
 
还是建立好表间关系,通过主外键的约束来删除相关记录的信息,这样做会比较好些
 
你是要删除试图里面对应的是表中数据还是要在DBgrid里面把那条不显示呀
如果是删除 估计只能逐表删除
如果是不显示 那可以用fiter来做呀 不知道 处理可得当 本人也才门槛
if ADOQuery1.Filter = '' then
begin
ADOQuery1.Filtered := False;
ADOQuery1.Filter := '药品ID <> ' + '''' + ADOQuery1.FieldByName('药品ID').Value + '''';
ADOQuery1.Filtered := True;
end else
begin
ADOQuery1.Filter := ADOQuery1.Filter + ' and 药品ID <> ' + '''' +ADOQuery1.FieldByName('药品ID').Value +'''';
ADOQuery1.Filtered := true;
end;
 
视图只是为了方便显示才用的.维护数据也在视图里做?
 
你删除的是主档资料.还是所有对应的资料都要删除.如果此笔资料里别的资料也对应的内容怎么办.?也给删除了吗?那不就乱了?
 
后退
顶部