X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 3A73C9FB3D6 for ; Thu, 31 Aug 2006 11:27:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 36718-06-3 for ; Thu, 31 Aug 2006 14:27:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from a2s5.a2hosting.com (host-209-124-50-10.a2webhosting.com [209.124.50.10]) by postgresql.org (Postfix) with ESMTP id 8A72F9FB3E4 for ; Thu, 31 Aug 2006 11:26:18 -0300 (ADT) Received: from adsl-155-122-205.tys.bellsouth.net ([72.155.122.205] helo=[192.168.1.10]) by a2s5.a2hosting.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.52) id 1GInUm-0000KM-Bo; Thu, 31 Aug 2006 10:26:16 -0400 In-Reply-To: <55c095e90608310707x52bd308cmc0319fab931d4b7@mail.gmail.com> References: <55c095e90608310600y18d382f2l5cc43410466bbd79@mail.gmail.com> <55c095e90608310707x52bd308cmc0319fab931d4b7@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed Message-Id: Cc: PostgreSQL SQL List Content-Transfer-Encoding: quoted-printable From: John DeSoi Subject: Re: ERROR: SELECT query has no destination for result data Date: Thu, 31 Aug 2006 10:26:10 -0400 To: Ezequias Rodrigues da Rocha X-Mailer: Apple Mail (2.752.2) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s5.a2hosting.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - pgedit.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200608/248 X-Sequence-Number: 26206 Sorry, try select into numRegistros count(*) from base.emissor_ponto_venda where =20= id =3D PontoVenda_Emissor; The thing you are selecting into needs to match what you are =20 selecting. So in your examples below, record is needed when you use =20 "* from ...". If you just need to look at one value: select into num_em_pdv id from base.emissor_ponto_venda where id =3D =20 PontoVenda_Emissor; John On Aug 31, 2006, at 10:07 AM, Ezequias Rodrigues da Rocha wrote: > Thank you John, > > It only works using records. I don't know why. > > When I put ('works well'): > select into num_em_pdv * from base.emissor_ponto_venda where id =3D =20= > PontoVenda_Emissor; > if num_em_pdv.id is null then --> Se o emissor ponto venda =20= > passado n=E3o tem na base retorne 4 > retorno:=3D 4; > > When I put (don't works well): > num_em_pdv int4; > select into num_em_pdv * from base.emissor_ponto_venda where id =3D =20= > PontoVenda_Emissor; > if num_em_pdv.id is null then --> Se o emissor ponto venda =20= > passado n=E3o tem na base retorne 4 > retorno:=3D 4; > > Reports the error: > ERROR: missing FROM-clause entry for table "num_em_pdv" > CONTEXT: SQL statement "SELECT num_em_pdv.id is null" > PL/pgSQL function "inserirpontos" line 30 at if > > Thank you John. I think I should stay with the record type. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL