Search Postgresql Archives

Trigger problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I'll be trying to write a my first trigger which fire when an user
makes an insert into a table; this insert records in others tables.
But when I try to insert a record in trigger's table generate an error: 
 - Syntax error near "into" in char 9. - 

This is the trigger.

CREATE OR REPLACE FUNCTION socios_insert()
  RETURNS "trigger" AS
$BODY$
    BEGIN
-- Creo el domicilio mltiple
	INSERT INTO DomiciliosMultiples (CodigoProfesion,
MatriculaProfesional, NumeroSecuencia,
	  CodigoProfesionCliSanHosp, MatriculaProfesionalCliSanHosp, Calle,
Numero, Piso, Dto, Otros,
	  Telefono, CodigoLocalidad, HorariosAtencion, NombreInstitucion,
HabilitacionAMR,
	  HabilitacionColegio, ExtensionHabilitacion, Titular,
CodigoSeccional, CodigoZona) VALUES
	  (NEW.CodigoProfesion, NEW.MatriculaProfesional, 1, 0, 0,
NEW.CalleConsultorio,
	  NEW.NumeroConsultorio, NEW.PisoConsultorio, NEW.DtoConsultorio,
NEW.OtrosConsultorio,
	  NEW.TelefonoConsultorio, NEW.CodigoLocalidadConsultorio, '', '',
FALSE, FALSE, FALSE, FALSE, 0, 99);

-- Creo las redes por defecto
	INSERT INTO RedDomicilioMultiple (CodigoDomicilioMultiple, CodigoRed,
FechaInicioVigencia)
	  VALUES (CURRVAL('domiciliosmultiples_codigodomiciliomultiple_seq'),
2, NEW.FechaIngresoCTM);

	INSERT INTO RedDomicilioMultiple (CodigoDomicilioMultiple, CodigoRed,
FechaInicioVigencia)
	  VALUES (CURRVAL('domiciliosmultiples_codigodomiciliomultiple_seq'),
13, NEW.FechaIngresoCTM);
 
	INSERT INTO RedDomicilioMultiple (CodigoDomicilioMultiple, CodigoRed,
FechaInicioVigencia)
	  VALUES (CURRVAL('domiciliosmultiples_codigodomiciliomultiple_seq'),
99, NEW.FechaIngresoCTM);
    END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

CREATE TRIGGER tsocios_insert_after
  AFTER INSERT
  ON socios
  FOR EACH ROW
  EXECUTE PROCEDURE socios_insert(); 
 
Thanks, Alejandro

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux