sql - How to get results of a TQuery en Delphi? -


database

when run following query in database:

 select t.id tabla t id=3 

resutl:

no rows returned

now try show message in delphi "the record not exist".

in form have component tquery call qvalidacion connected 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)          begin              showmessage('the record not exist'); //it should display message, not show         end;     qvalidacion.sql.clear; end; 

if want check if record in query don't use qvalidacion.eof qvalidacion.isempty

if (qvalidacion.isempty)  begin   showmessage('the record not exist');  end; 

the eof function here returning true when reach end of dataset. example:

qvalidacion.first; while not qvalidacion.eof begin  // current record.  qvalidacion.next end; 

edit1: using isempty indeed more clean. arioch 'the


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -