On Wed, 27 Jan 2016 10:48:49 -0200, "hamacker sirhamacker@gmail.com
  [firebird-support]" <firebird-support@yahoogroups.com> wrote:
  > I would know whats methods is more effective, per exemple:
  > To know if itens exists or not, select:
  > select
  >   case
  >     when exists(select 1 from cv_itens  where id_cv=51716)
  >     then 'Y'
  >     else 'N'
  >   end as existe_itens
  > from rdb$database
  > 
  > OR using block execute:
  > execute block
  > returns(exist varchar(1))
  > as
  > begin
  >   exist='N';
  >   if (exists(select 1 from cv_itens  where id_cv=51716)) then exist='Y';
  >   suspend;
  > end
  > 
  > I think that first method using rdb$database as source, checking
  > permissions and others things and second method is not and more
  powerfull
  > using psql.
  > 
  > I would like to know what you guys think about.
  
  I'd use select 1 from cv_itens  where id_cv=51716
  
  and check if you have a row or not. If it can produce multiple rows, then
  use select first 1 1 from cv_itens  where id_cv=51716, or select 1 from
  cv_itens  where id_cv=51716 rows 1.
  
  That is much simpler, and likely has less overhead. 
  
  Mark
  
  
Posted by: Mark Rotteveel <mark@lawinegevaar.nl>
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) | 
Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu. Try FAQ and other links from the left-side menu there.
Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
No comments:
Post a Comment