[pgbr-geral] Erro em trigger

2008-07-22 Thread Glauber Almeida

Bom pessoal, estou com um problema em uma trigger e não consigo achar o que
esta errado.

Funcionalidade:
Na inclusão da venda deve selecionar o cliente na tabela de clientes e
duplicar os dados (nome do cliente, número do cpf/cnpj) na tabela de venda.

Trigger: tri_erp_venda_ins
Type: before
For each: Row
On event: Insert

$body$
declare
rscliente erp_cliente%rowtype;

begin
select cli_cod, cli_nom, cli_num_cpf_cnpj into rscliente from 
erp_cliente
where cli_cod = new.cli_cod;
if not rscliente.cli_cod is null then
 new.ven_nom_cli := rscliente.cli_nom;
 new.ven_num_cpf_cnpj := rscliente.cli_num_cpf_cnpj;
else
  new.cli_cod:=1;
  new.ven_nom_cli := 'CONSUMIDOR FINAL';
  new.ven_num_cpf_cnpj := '1234567890';
end  if;
end;

end;
$body$


Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
   CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at SQL
statement

Ao inserir na tabela de vendas um código de cliente existente na tabela de
cliente esta ocorrendo o erro acima.



-- 
View this message in context: 
http://www.nabble.com/Erro-em-trigger-tp18597325p18597325.html
Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.

___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Erro em trigger

2008-07-22 Thread Glauber Almeida

Só esqueci de uma coisa, segundo o log o erro esta ocorrendo nessa linha e
não na linha 11 como eu postei.

select cli_cod, cli_nom, cli_num_cpf_cnpj into rscliente from 
erp_cliente
where cli_cod = new.cli_cod;





Glauber Almeida wrote:
> 
> Bom pessoal, estou com um problema em uma trigger e não consigo achar o
> que esta errado.
> 
> Funcionalidade:
> Na inclusão da venda deve selecionar o cliente na tabela de clientes e
> duplicar os dados (nome do cliente, número do cpf/cnpj) na tabela de
> venda.
> 
> Trigger: tri_erp_venda_ins
> Type: before
> For each: Row
> On event: Insert
> 
> $body$
> declare
> rscliente erp_cliente%rowtype;
> 
> begin
>   select cli_cod, cli_nom, cli_num_cpf_cnpj into rscliente from 
> erp_cliente
> where cli_cod = new.cli_cod;
>   if not rscliente.cli_cod is null then
>new.ven_nom_cli := rscliente.cli_nom;
>new.ven_num_cpf_cnpj := rscliente.cli_num_cpf_cnpj;
>   else
> new.cli_cod:=1;
> new.ven_nom_cli := 'CONSUMIDOR FINAL';
> new.ven_num_cpf_cnpj := '1234567890';
>   end  if;
> end;
> 
> end;
> $body$
> 
> 
> Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
>CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at SQL
> statement
> 
> Ao inserir na tabela de vendas um código de cliente existente na tabela de
> cliente esta ocorrendo o erro acima.
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Erro-em-trigger-tp18597325p18597377.html
Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.

___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Erro em trigger

2008-07-22 Thread Rudinei Dias
Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
  CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at SQL
statement

Glauber,

pelo erro que o postgres esta retornando, parece que o tipo do campo
ven_nom_cli não corresponde a rscliente.cli_nom.

Rudinei Dias



2008/7/22 Glauber Almeida <[EMAIL PROTECTED]>:

>
> Bom pessoal, estou com um problema em uma trigger e não consigo achar o que
> esta errado.
>
> Funcionalidade:
> Na inclusão da venda deve selecionar o cliente na tabela de clientes e
> duplicar os dados (nome do cliente, número do cpf/cnpj) na tabela de venda.
>
> Trigger: tri_erp_venda_ins
> Type: before
> For each: Row
> On event: Insert
>
> $body$
> declare
> rscliente erp_cliente%rowtype;
>
> begin
>select cli_cod, cli_nom, cli_num_cpf_cnpj into rscliente from
> erp_cliente
> where cli_cod = new.cli_cod;
>if not rscliente.cli_cod is null then
> new.ven_nom_cli := rscliente.cli_nom;
> new.ven_num_cpf_cnpj := rscliente.cli_num_cpf_cnpj;
>else
>  new.cli_cod:=1;
>  new.ven_nom_cli := 'CONSUMIDOR FINAL';
>  new.ven_num_cpf_cnpj := '1234567890';
>end  if;
> end;
>
> end;
> $body$
>
>
> Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
>   CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at SQL
> statement
>
> Ao inserir na tabela de vendas um código de cliente existente na tabela de
> cliente esta ocorrendo o erro acima.
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Erro-em-trigger-tp18597325p18597325.html
> Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.
>
> ___
> pgbr-geral mailing list
> pgbr-geral@listas.postgresql.org.br
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>
___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Erro em trigger

2008-07-22 Thread Glauber Almeida

Pois é. 

Foi a primeira coisa que conferir na tabela de vendas e clientes.

Tabela de venda erp_venda
ven_nom_cli varchar(50)

Tabela de clientes erp_cliente
cli_nom varchar(50)


Isso que é foda, mas não sei se tenho que declarar esses campos ou se o tipo
rowtype já pega o tipo das colunas selecionadas da própria tabela.



Rudinei Dias-3 wrote:
> 
> Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
>   CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at SQL
> statement
> 
> Glauber,
> 
> pelo erro que o postgres esta retornando, parece que o tipo do campo
> ven_nom_cli não corresponde a rscliente.cli_nom.
> 
> Rudinei Dias
> 
> 
> 
> 2008/7/22 Glauber Almeida <[EMAIL PROTECTED]>:
> 
>>
>> Bom pessoal, estou com um problema em uma trigger e não consigo achar o
>> que
>> esta errado.
>>
>> Funcionalidade:
>> Na inclusão da venda deve selecionar o cliente na tabela de clientes e
>> duplicar os dados (nome do cliente, número do cpf/cnpj) na tabela de
>> venda.
>>
>> Trigger: tri_erp_venda_ins
>> Type: before
>> For each: Row
>> On event: Insert
>>
>> $body$
>> declare
>> rscliente erp_cliente%rowtype;
>>
>> begin
>>select cli_cod, cli_nom, cli_num_cpf_cnpj into rscliente from
>> erp_cliente
>> where cli_cod = new.cli_cod;
>>if not rscliente.cli_cod is null then
>> new.ven_nom_cli := rscliente.cli_nom;
>> new.ven_num_cpf_cnpj := rscliente.cli_num_cpf_cnpj;
>>else
>>  new.cli_cod:=1;
>>  new.ven_nom_cli := 'CONSUMIDOR FINAL';
>>  new.ven_num_cpf_cnpj := '1234567890';
>>end  if;
>> end;
>>
>> end;
>> $body$
>>
>>
>> Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
>>   CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at SQL
>> statement
>>
>> Ao inserir na tabela de vendas um código de cliente existente na tabela
>> de
>> cliente esta ocorrendo o erro acima.
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Erro-em-trigger-tp18597325p18597325.html
>> Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.
>>
>> ___
>> pgbr-geral mailing list
>> pgbr-geral@listas.postgresql.org.br
>> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>>
> 
> ___
> pgbr-geral mailing list
> pgbr-geral@listas.postgresql.org.br
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Erro-em-trigger-tp18597325p18597612.html
Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.

___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Erro em trigger

2008-07-22 Thread Rudinei Dias
Talvez se mudares a lógica da tua trigger...
da uma olhada nessa


CREATE OR REPLACE FUNCTION fnpessoa_nacionalidade_upd()
  RETURNS "trigger" AS
$BODY$
DECLARE
vNACIONALIDADE varchar(100);
BEGIN
   if new.spas_id is not null then
  select spas_nacion into vNACIONALIDADE
  from sie_paises
  where spas_id = new.spas_id;
   else
  select spas_nacion into vNACIONALIDADE
  from sie_paises
  where spas_id = old.spas_id;
   end if;

   if found then
  new.nacionalidade := vNACIONALIDADE;
   end if;

   RETURN new;
END; $BODY$
  LANGUAGE 'plpgsql' VOLATILE;

onde testo se o campo recebido new.spas_id para null e depois então faço o
select na tabela para atualizar (if found) o new.nacionalidade caso
encontrado registro na tab.


2008/7/22 Glauber Almeida <[EMAIL PROTECTED]>:

>
> Pois é.
>
> Foi a primeira coisa que conferir na tabela de vendas e clientes.
>
> Tabela de venda erp_venda
> ven_nom_cli varchar(50)
>
> Tabela de clientes erp_cliente
> cli_nom varchar(50)
>
>
> Isso que é foda, mas não sei se tenho que declarar esses campos ou se o
> tipo
> rowtype já pega o tipo das colunas selecionadas da própria tabela.
>
>
>
> Rudinei Dias-3 wrote:
> >
> > Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
> >   CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at SQL
> > statement
> >
> > Glauber,
> >
> > pelo erro que o postgres esta retornando, parece que o tipo do campo
> > ven_nom_cli não corresponde a rscliente.cli_nom.
> >
> > Rudinei Dias
> >
> >
> >
> > 2008/7/22 Glauber Almeida <[EMAIL PROTECTED]>:
> >
> >>
> >> Bom pessoal, estou com um problema em uma trigger e não consigo achar o
> >> que
> >> esta errado.
> >>
> >> Funcionalidade:
> >> Na inclusão da venda deve selecionar o cliente na tabela de clientes e
> >> duplicar os dados (nome do cliente, número do cpf/cnpj) na tabela de
> >> venda.
> >>
> >> Trigger: tri_erp_venda_ins
> >> Type: before
> >> For each: Row
> >> On event: Insert
> >>
> >> $body$
> >> declare
> >> rscliente erp_cliente%rowtype;
> >>
> >> begin
> >>select cli_cod, cli_nom, cli_num_cpf_cnpj into rscliente from
> >> erp_cliente
> >> where cli_cod = new.cli_cod;
> >>if not rscliente.cli_cod is null then
> >> new.ven_nom_cli := rscliente.cli_nom;
> >> new.ven_num_cpf_cnpj := rscliente.cli_num_cpf_cnpj;
> >>else
> >>  new.cli_cod:=1;
> >>  new.ven_nom_cli := 'CONSUMIDOR FINAL';
> >>  new.ven_num_cpf_cnpj := '1234567890';
> >>end  if;
> >> end;
> >>
> >> end;
> >> $body$
> >>
> >>
> >> Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
> >>   CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at SQL
> >> statement
> >>
> >> Ao inserir na tabela de vendas um código de cliente existente na tabela
> >> de
> >> cliente esta ocorrendo o erro acima.
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Erro-em-trigger-tp18597325p18597325.html
> >> Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.
> >>
> >> ___
> >> pgbr-geral mailing list
> >> pgbr-geral@listas.postgresql.org.br
> >> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> >>
> >
> > ___
> > pgbr-geral mailing list
> > pgbr-geral@listas.postgresql.org.br
> > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Erro-em-trigger-tp18597325p18597612.html
> Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.
>
> ___
> pgbr-geral mailing list
> pgbr-geral@listas.postgresql.org.br
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>
___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Erro em trigger

2008-07-22 Thread Glauber Almeida

Pensei em fazer daquela forma porque se não vou ter que fazer 1 select para
cada campo. Estou certo?
Da forma que você colocou, iria ficar assim:

declare
vnome varchar(50);
vdoc varchar(14);

begin
   select cli_nom into vnome from erp_cliente where cli_cod = new.cli_cod;
   select cli_num_cpf_cnpj into vdoc from erp_cliente where cli_cod =
new.cli_cod;

   if found then
 new.ven_nom_cli := vnome
 new.ven_num_cpf_cnpj := vdoc
   end if;
   return new;
end;


Eu não perderia performance ?





Rudinei Dias-3 wrote:
> 
> Talvez se mudares a lógica da tua trigger...
> da uma olhada nessa
> 
> 
> CREATE OR REPLACE FUNCTION fnpessoa_nacionalidade_upd()
>   RETURNS "trigger" AS
> $BODY$
> DECLARE
> vNACIONALIDADE varchar(100);
> BEGIN
>if new.spas_id is not null then
>   select spas_nacion into vNACIONALIDADE
>   from sie_paises
>   where spas_id = new.spas_id;
>else
>   select spas_nacion into vNACIONALIDADE
>   from sie_paises
>   where spas_id = old.spas_id;
>end if;
> 
>if found then
>   new.nacionalidade := vNACIONALIDADE;
>end if;
> 
>RETURN new;
> END; $BODY$
>   LANGUAGE 'plpgsql' VOLATILE;
> 
> onde testo se o campo recebido new.spas_id para null e depois então faço o
> select na tabela para atualizar (if found) o new.nacionalidade caso
> encontrado registro na tab.
> 
> 
> 2008/7/22 Glauber Almeida <[EMAIL PROTECTED]>:
> 
>>
>> Pois é.
>>
>> Foi a primeira coisa que conferir na tabela de vendas e clientes.
>>
>> Tabela de venda erp_venda
>> ven_nom_cli varchar(50)
>>
>> Tabela de clientes erp_cliente
>> cli_nom varchar(50)
>>
>>
>> Isso que é foda, mas não sei se tenho que declarar esses campos ou se o
>> tipo
>> rowtype já pega o tipo das colunas selecionadas da própria tabela.
>>
>>
>>
>> Rudinei Dias-3 wrote:
>> >
>> > Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
>> >   CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at
>> SQL
>> > statement
>> >
>> > Glauber,
>> >
>> > pelo erro que o postgres esta retornando, parece que o tipo do campo
>> > ven_nom_cli não corresponde a rscliente.cli_nom.
>> >
>> > Rudinei Dias
>> >
>> >
>> >
>> > 2008/7/22 Glauber Almeida <[EMAIL PROTECTED]>:
>> >
>> >>
>> >> Bom pessoal, estou com um problema em uma trigger e não consigo achar
>> o
>> >> que
>> >> esta errado.
>> >>
>> >> Funcionalidade:
>> >> Na inclusão da venda deve selecionar o cliente na tabela de clientes e
>> >> duplicar os dados (nome do cliente, número do cpf/cnpj) na tabela de
>> >> venda.
>> >>
>> >> Trigger: tri_erp_venda_ins
>> >> Type: before
>> >> For each: Row
>> >> On event: Insert
>> >>
>> >> $body$
>> >> declare
>> >> rscliente erp_cliente%rowtype;
>> >>
>> >> begin
>> >>select cli_cod, cli_nom, cli_num_cpf_cnpj into rscliente from
>> >> erp_cliente
>> >> where cli_cod = new.cli_cod;
>> >>if not rscliente.cli_cod is null then
>> >> new.ven_nom_cli := rscliente.cli_nom;
>> >> new.ven_num_cpf_cnpj := rscliente.cli_num_cpf_cnpj;
>> >>else
>> >>  new.cli_cod:=1;
>> >>  new.ven_nom_cli := 'CONSUMIDOR FINAL';
>> >>  new.ven_num_cpf_cnpj := '1234567890';
>> >>end  if;
>> >> end;
>> >>
>> >> end;
>> >> $body$
>> >>
>> >>
>> >> Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
>> >>   CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at
>> SQL
>> >> statement
>> >>
>> >> Ao inserir na tabela de vendas um código de cliente existente na
>> tabela
>> >> de
>> >> cliente esta ocorrendo o erro acima.
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Erro-em-trigger-tp18597325p18597325.html
>> >> Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.
>> >>
>> >> ___
>> >> pgbr-geral mailing list
>> >> pgbr-geral@listas.postgresql.org.br
>> >> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>> >>
>> >
>> > ___
>> > pgbr-geral mailing list
>> > pgbr-geral@listas.postgresql.org.br
>> > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Erro-em-trigger-tp18597325p18597612.html
>> Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.
>>
>> ___
>> pgbr-geral mailing list
>> pgbr-geral@listas.postgresql.org.br
>> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>>
> 
> ___
> pgbr-geral mailing list
> pgbr-geral@listas.postgresql.org.br
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Erro-em-trigger-tp18597325p18598103.html
Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.

___

Re: [pgbr-geral] Erro em trigger

2008-07-22 Thread Luiz Matsumura
2008/7/22 Glauber Almeida <[EMAIL PROTECTED]>:
>
> Bom pessoal, estou com um problema em uma trigger e não consigo achar o que
> esta errado.
>
> Funcionalidade:
> Na inclusão da venda deve selecionar o cliente na tabela de clientes e
> duplicar os dados (nome do cliente, número do cpf/cnpj) na tabela de venda.
>
> Trigger: tri_erp_venda_ins
> Type: before
> For each: Row
> On event: Insert
>
> $body$
> declare
> rscliente erp_cliente%rowtype;
>
> begin
>select cli_cod, cli_nom, cli_num_cpf_cnpj into rscliente from 
> erp_cliente
> where cli_cod = new.cli_cod;
>if not rscliente.cli_cod is null then
> new.ven_nom_cli := rscliente.cli_nom;
> new.ven_num_cpf_cnpj := rscliente.cli_num_cpf_cnpj;
>else
>  new.cli_cod:=1;
>  new.ven_nom_cli := 'CONSUMIDOR FINAL';
>  new.ven_num_cpf_cnpj := '1234567890';
>end  if;
> end;
>
> end;
> $body$
>
>

Creio que o seu problema esta na linha:

rscliente erp_cliente%rowtype;

que acredito fazer com que se espere os dados na mesma sequência
definida na tabela erp_cliente, melhor seria utilizar

rscliente RECORD;
___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Erro em trigger

2008-07-22 Thread Euler Taveira de Oliveira
Glauber Almeida escreveu:

> end;
> 
> end;

duas cláusulas 'end'?

> Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
>CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at SQL
> statement
> 
O que está acontecendo é que você declarou um ROWTYPE mas não está 
utilizando-o. Se a sua tabela erp_cliente tem os campos a,b,c e d, então 
rscliente terá esses campos também. Não parece ser o que você está 
fazendo. Utilize o RECORD quando não pretender trazer todos os campos de 
uma tabela.


-- 
   Euler Taveira de Oliveira
   http://www.timbira.com/
___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Erro em trigger

2008-07-23 Thread Glauber Almeida

Euler,

  obrigado pela informação, a alteração foi feita na trigger e esta
funcionando corretamente.
  Achei que rowtype fosse igual ao record. Agora entendi a maneira correta
de se fazer isso.

Obrigado.




Euler Taveira de Oliveira-2 wrote:
> 
> Glauber Almeida escreveu:
> 
>> end;
>> 
>> end;
> 
> duas cláusulas 'end'?
> 
>> Erro: invalid input syntax for integer: "ERLON PAULO ANDRADE"
>>CONTEXT:  PL/pgSQL function "fun_tri_erp_venda_ins" line 11 at SQL
>> statement
>> 
> O que está acontecendo é que você declarou um ROWTYPE mas não está 
> utilizando-o. Se a sua tabela erp_cliente tem os campos a,b,c e d, então 
> rscliente terá esses campos também. Não parece ser o que você está 
> fazendo. Utilize o RECORD quando não pretender trazer todos os campos de 
> uma tabela.
> 
> 
> -- 
>Euler Taveira de Oliveira
>http://www.timbira.com/
> ___
> pgbr-geral mailing list
> pgbr-geral@listas.postgresql.org.br
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Erro-em-trigger-tp18597325p18608500.html
Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.

___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Erro em trigger

2008-07-24 Thread Rudinei Dias
2008/7/22 Glauber Almeida <[EMAIL PROTECTED]>:

>
> Pensei em fazer daquela forma porque se não vou ter que fazer 1 select para
> cada campo. Estou certo?
> Da forma que você colocou, iria ficar assim:
>
> begin
>   select cli_nom into vnome from erp_cliente where cli_cod = new.cli_cod;
>   select cli_num_cpf_cnpj into vdoc from erp_cliente where cli_cod =
> new.cli_cod;
>
>
Na verdade assim é que funciona, primeiro todos os campos e depois do into
as variáveis para cada campo.

select cli_nom, cli_num_cpf_cnpj into vnome, vdoc
from erp_cliente where cli_cod =
new.cli_cod;
___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral


Re: [pgbr-geral] Erro em trigger

2008-07-24 Thread Glauber Almeida

Rudinei,
   
  vlw, Obrigado pela explicação, dessa forma também iria funcionar e
acredito vai ser melhor do que o record.

Glauber Almeida


Rudinei Dias-3 wrote:
> 
> 2008/7/22 Glauber Almeida <[EMAIL PROTECTED]>:
> 
>>
>> Pensei em fazer daquela forma porque se não vou ter que fazer 1 select
>> para
>> cada campo. Estou certo?
>> Da forma que você colocou, iria ficar assim:
>>
>> begin
>>   select cli_nom into vnome from erp_cliente where cli_cod = new.cli_cod;
>>   select cli_num_cpf_cnpj into vdoc from erp_cliente where cli_cod =
>> new.cli_cod;
>>
>>
> Na verdade assim é que funciona, primeiro todos os campos e depois do into
> as variáveis para cada campo.
> 
> select cli_nom, cli_num_cpf_cnpj into vnome, vdoc
> from erp_cliente where cli_cod =
> new.cli_cod;
> 
> ___
> pgbr-geral mailing list
> pgbr-geral@listas.postgresql.org.br
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Erro-em-trigger-tp18597325p18638666.html
Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.

___
pgbr-geral mailing list
pgbr-geral@listas.postgresql.org.br
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral