plql and or clausule - Mailing list pgsql-general

From carlos@lpis.com
Subject plql and or clausule
Date
Msg-id 2003295514.67185.1464729506228@webmail.lpis.com
Whole thread Raw
Responses Re: plql and or clausule
Re: plql and or clausule
Re: plql and or clausule
List pgsql-general

hello

this is my first question.

I am new in postgres and using plsql.

i am making this (bellow)

i want to insert one copy of one record into the log table but if there is some change into the original recor to update into this record two fields but i have one rror

can you help me please?


CREATE OR REPLACE FUNCTION lst_tot_mytable_LOG() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF (TG_OP = 'UPDATE') THEN
INSERT INTO lst_tot_mytable_log SELECT 'U', now(), OLD.*;
IF OLD.Peticionario != NEW.Peticionario or OLD.interlocclte != NEW.interlocclte or OLD.Equipo != NEW.Equipo or OLD.RespTecnico != NEW.RespTecnico or OLD.RespOrganiz != NEW.RespOrganiz THEN
UPDATE lst_tot_mytable set fultimamodificacion = now(), esmodificadoerspectoaanterior = true WHERE nropeti = OLD.nropeti;
ELSIF OLD.Peticionario == NEW.Peticionario or OLD.interlocclte == NEW.interlocclte or OLD.Equipo == NEW.Equipo or OLD.RespTecnico == NEW.RespTecnico or OLD.RespOrganiz == NEW.RespOrganiz THEN
UPDATE lst_tot_mytable set NEW.fultimamodificacion = now(), NEW.esmodificadoerspectoaanterior = fase WHERE nropeti = OLD.nropeti;
END IF;
RETURN NULL; -- result is ignored since this is an AFTER trigger
END;
$$;

the eror si this:

ERROR: el operador no existe: character varying == character varying
LINE 1: SELECT OLD.Peticionario == NEW.Peticionario or OLD.interlocc...
^
HINT: Ningún operador coincide con el nombre y el tipo de los argumentos. Puede ser necesario agregar conversiones explícitas de tipos.
QUERY: SELECT OLD.Peticionario == NEW.Peticionario or OLD.interlocclte == NEW.interlocclte or OLD.Equipo == NEW.Equipo or OLD.RespTecnico == NEW.RespTecnico or OLD.RespOrganiz == NEW.RespOrganiz or OLD.FAlta == NEW.FAlta or OLD.FRequerida == NEW.FRequerida or OLD.Titulo == NEW.Titulo or OLD.Cliente == NEW.Cliente or OLD.Organico == NEW.Organico or OLD.Pri == NEW.Pri or OLD.Estado == NEW.Estado or OLD.FEstado == NEW.FEstado or OLD.CCCA == NEW.CCCA or OLD.Aplicacion_Actvdad == NEW.Aplicacion_Actvdad or OLD.Servicio == NEW.Servicio or OLD.FPrevistaInicioPeticion == NEW.FPrevistaInicioPeticion or OLD.FPrevistaFinPeticion == NEW.FPrevistaFinPeticion or OLD.autpet_Horas == NEW.autpet_Horas or OLD.autpet_Importe == NEW.autpet_Importe or OLD.auteje_Horas == NEW.auteje_Horas or OLD.auteje_Importe == NEW.auteje_Importe or OLD.aprpet_Horas == NEW.aprpet_Horas or OLD.aprpet_Importe == NEW.aprpet_Importe or OLD.apreje_Horas == NEW.apreje_Horas or OLD.apreje_Importe == NEW.apreje_Importe or OLD.ultprvpet_Horas == NEW.ultprvpet_Horas or OLD.ultprvpet_Importe == NEW.ultprvpet_Importe or OLD.ultprveje_Horas == NEW.ultprveje_Horas or OLD.ultprveje_Importe == NEW.ultprveje_Importe or OLD.realpet_Horas == NEW.realpet_Horas or OLD.realpet_Importe == NEW.realpet_Importe or OLD.realeje_Horas == NEW.realeje_Horas or OLD.realeje_Importe == NEW.realeje_Importe or OLD.CodFacturacion == NEW.CodFacturacion or OLD.Facturable == NEW.Facturable or OLD.ProyCliente == NEW.ProyCliente
CONTEXT: función PL/pgSQL lst_tot_mytable_log() en la línea 12 en IF
sentencia SQL: «UPDATE lst_tot_mytable set fultimamodificacion = now(), esmodificadoerspectoaanterior = true WHERE nropeti = OLD.nropeti»
función PL/pgSQL lst_tot_mytable_log() en la línea 13 en sentencia SQL
********** Error **********

ERROR: el operador no existe: character varying == character varying
SQL state: 42883
Hint: Ningún operador coincide con el nombre y el tipo de los argumentos. Puede ser necesario agregar conversiones explícitas de tipos.
Context: función PL/pgSQL lst_tot_mytable_log() en la línea 12 en IF
sentencia SQL: «UPDATE lst_tot_mytable set fultimamodificacion = now(), esmodificadoerspectoaanterior = true WHERE nropeti = OLD.nropeti»
función PL/pgSQL lst_tot_mytable_log() en la línea 13 en sentencia SQL

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Row security policies documentation question
Next
From: Kevin Grittner
Date:
Subject: Re: plql and or clausule