Re: ERROR: SELECT query has no destination for result data - Mailing list pgsql-sql

From John DeSoi
Subject Re: ERROR: SELECT query has no destination for result data
Date
Msg-id A970EDA9-C83F-4F15-B455-93CB54B2B8C4@pgedit.com
Whole thread Raw
In response to ERROR: SELECT query has no destination for result data  ("Ezequias Rodrigues da Rocha" <ezequias.rocha@gmail.com>)
List pgsql-sql
Sorry, try

select into numRegistros count(*) from base.emissor_ponto_venda where
id = PontoVenda_Emissor;

The thing you are selecting into needs to match what you are
selecting. So in your examples below, record is needed when you use
"* from ...". If you just need to look at one value:

select into num_em_pdv id from base.emissor_ponto_venda where id =
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 =
> PontoVenda_Emissor;
>          if num_em_pdv.id is null then --> Se o emissor ponto venda
> passado não tem na base retorne 4
>             retorno:= 4;
>
> When I put (don't works well):
>     num_em_pdv int4;
> select into num_em_pdv * from base.emissor_ponto_venda where id =
> PontoVenda_Emissor;
>          if num_em_pdv.id is null then --> Se o emissor ponto venda
> passado não tem na base retorne 4
>             retorno:= 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



pgsql-sql by date:

Previous
From: "2000 Informatica"
Date:
Subject: Re: ERROR: SELECT query has no destination for result data
Next
From: "Aaron Bono"
Date:
Subject: Re: Trigger on Insert to Update only newly inserted fields?