DataBase
When I run the following query in a database:
SELECT T.ID FROM TABLA T WHERE ID=3
Result:
No rows returned
Now I try show message in Delphi say "The record not exist".
In the form I have a component TQuery call qValidacion successfully connected with database Oracle 11g.
Try 1
procedure TfPrueba.ButtonAceptarClick(Sender: TObject); begin qValidacion.Close; qValidacion.SQL.Add('SELECT T.ID'); qValidacion.SQL.Add('FROM TABLA T'); qValidacion.SQL.Add('WHERE ID=3'); qValidacion.Open; qValidacion.First; if (not qValidacion.Eof) then begin ShowMessage('The record not exist'); //It Should display the message, but does not show end; qValidacion.SQL.Clear; end;
TABLA
which hasID = 3
? – Bob Jarvis - Reinstate Monicaif (not qValidacion.Eof)...
- you want, however to check if you are atEof
, not if you are not atEof
. The idiomatic way to check this, however, is to examine ifqValidacion.RecordCount = 0
. – J...qValidacion.SQL.Add('SELECT T.ID');
- BAD idea - there may already be something! Either callSQL.Clear
before the first line, or just call one-linerSQL.Text := ' SELECT ... WHERE T.ID=3';
– Arioch 'Theif qValidation.IsEmpty then ...
– Arioch 'The