Re: ERROR: SELECT query has no destination for result data

From: John DeSoi <desoi(at)pgedit(dot)com>
To: Ezequias Rodrigues da Rocha <ezequias(dot)rocha(at)gmail(dot)com>
Cc: PostgreSQL SQL List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: ERROR: SELECT query has no destination for result data
Date: 2006-08-31 14:26:10
Message-ID: A970EDA9-C83F-4F15-B455-93CB54B2B8C4@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Aaron Bono 2006-08-31 14:55:30 Re: Trigger on Insert to Update only newly inserted fields?
Previous Message Joe 2006-08-31 14:21:17 Re: ERROR: SELECT query has no destination for result data