// ----------// var adoQ_temp: TFDQuery; begin adoQ_temp := TFDQuery.Create(nil); // 生成临时的ADOQuery变量 adoQ_temp.Connection := FDConnection1; // 将adoQ_temp与ADOConnection1相连 try with adoQ_temp do begin Close; SQL.Clear; SQL.Add(format('select %s from %s where ' + Trim(BH_FieldName) + ' = "%s" ', [BH_FieldName, tableName, New_z])); Open; if adoQ_temp.RecordCount <> 0 then begin Result := True; Exit; end; Close; end; Result := False; finally adoQ_temp.free; end;
SQL server2008数据库, A 表的登记号是主键, 在A表执行删除操作时,同时向B表插入一条相同的记录, 如果B表存在登记号相同的记录时,则先删除B表的该记录再执行输入插入, 这个触发器怎么写?
create trigger a_tri_ins on A as begin declare @c登记号 varchar(100) select @c登记号 = 登记号 from inserted if exists ( select 1 from B where 登记号 = @c登记号 ) delete B where 登记号 = @c登记号
insert B ( 列名全写出来 ) select 列名全写出来 from inserted end
----------------------------------------------
-