简单的函数
Function UpdateOrInsert(Fbentityid,Itemid,CNTRID:integer):boolean;
var aSQLQuery: TSQLQuery;
begin
Result:=True;
aSQLQuery:=TSqlquery.create(nil);
with aSQLQuery do try
Close;SQL.Clear;
SQLConnection:=SQLConn;
sql.Add('select count(*) from PRICEMNGITEMS ');
sql.Add('where Sysid=:Sysid and Entityid=:Entityid and itemid=:itemid and CNTRID=:CNTRID');
ParamByName('Sysid').asInteger:=FSysid;
ParamByName('Entityid').asInteger:=FBEntityID;
ParamByName('Itemid').asInteger:=Itemid;
ParamByName('CNTRID').asInteger:=CNTRID;
Open;
if (not IsEmpty) and (FieldByName('Count').AsInteger>0) then
begin
Result:=False;
exit;
end;
finally
free;
end;
end