数据数据库中的数据删除查询 [英] data deletion query from data database

查看:75
本文介绍了数据数据库中的数据删除查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我解决问题

如何制作功能
当我在列表视图中按记录上的删除键时,
在数据库的所有其他表中检查其唯一标识
如果找到,则提供其他表中使用的消息记录
然后停止删除

访问数据库文件

pls help me for a problem

how to make a function
when i press a delete key on record in listview then
check its uniqe id in all other tabels of database
if found then give message record used in other table
and stop from delete

access database file

推荐答案

您没有提到正在使用的数据库,而是说它是SQL Server.无论如何,如果您要维护数据库中数据的完整性,请不要检查代码中的关系.请改用数据库的功能.因此,如果这是例如SQL Server,请参见 SQL外键约束 [
You didn''t mention the database you''re using, but let''s say it''s SQL Server. Regardless of that, if you want to maintain the integrity of the data in the database, don''t check the relations in your code. Use the features of the database instead. So if this is for example SQL Server, see SQL FOREIGN KEY Constraint[^]


为什么需要功能?您可以使用存储过程来实现.

Why you need function ? You can achieve this using stored procedure.

CREATE PROC SearchRecordInAllTableById
(
 @Id BIGINT
)
AS
BEGIN
  IF EXISTS (SELECT Id FROM TABLE1 WHERE ID=@Id)
   BEGIN
    RETURN 1
   END

  IF EXISTS (SELECT Id FROM TABLE1 WHERE ID=@Id)
   BEGIN
    RETURN 1
   END

RETURN 0
END


这篇关于数据数据库中的数据删除查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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