Subject | TIB_DSQL-prevent exception on empty result |
---|---|
Author | G. Nau |
Post date | 2005-05-17T14:33:57Z |
I'm using TIB_DSQL to do a number of single record based
operations and it's working fine, but ...
----------------------------
sSQL:='select first(1) REF from '+MainQuery.Tablename+' '+
'Where (('+SortIndex+'<:P1) or ('+SortIndex+'=:P1 and
REF<:P2)) '+
'Order by '+SortIndex+' DESC,REF DESC';
SearchQuery.sql.clear;
SearchQuery.sql.add(ssql);
SearchQuery.Prepare;
SearchQuery.Params[0].AsString:=Suchbegriff;
SearchQuery.Params[1].Asinteger:=RefAlt;
try
SearchQuery.ExecSQL;
RefNeu:=SearchQuery.FieldByName('REF').AsInteger;
MainQuery.ParamByName('REFNO').AsInteger:=RefNeu;
Except //kein neuer Satz gefunden; also den letzten Ansteuern
SQL_First_Ref_on_actual_Sort(MainQuery,SearchQuery);
End;
-----------------------------------
My question(s):
1. The ExecSQL is firing an Debugger Exception, if the result of the
sql is empty. How can this Exception be prevented?
2. If there is a solution for 1., how do I determine, if the result
"isempty"? I haven't found a function like tib_query.isempty.
Thanks in advance
Gunther
operations and it's working fine, but ...
----------------------------
sSQL:='select first(1) REF from '+MainQuery.Tablename+' '+
'Where (('+SortIndex+'<:P1) or ('+SortIndex+'=:P1 and
REF<:P2)) '+
'Order by '+SortIndex+' DESC,REF DESC';
SearchQuery.sql.clear;
SearchQuery.sql.add(ssql);
SearchQuery.Prepare;
SearchQuery.Params[0].AsString:=Suchbegriff;
SearchQuery.Params[1].Asinteger:=RefAlt;
try
SearchQuery.ExecSQL;
RefNeu:=SearchQuery.FieldByName('REF').AsInteger;
MainQuery.ParamByName('REFNO').AsInteger:=RefNeu;
Except //kein neuer Satz gefunden; also den letzten Ansteuern
SQL_First_Ref_on_actual_Sort(MainQuery,SearchQuery);
End;
-----------------------------------
My question(s):
1. The ExecSQL is firing an Debugger Exception, if the result of the
sql is empty. How can this Exception be prevented?
2. If there is a solution for 1., how do I determine, if the result
"isempty"? I haven't found a function like tib_query.isempty.
Thanks in advance
Gunther