Primero aqui esta la tabla:
CREATE TABLE tipo_incidencia
(
idtipoinci serial NOT NULL,
nom_tipo character varying(30) NOT NULL,
descr_tipo character(100) NOT NULL,
CONSTRAINT tipo_incidencia_pkey PRIMARY KEY (idtipoinci)
)
Aqui el procedimiento almacenado o la función:
CREATE OR REPLACE FUNCTION insert_tip_inciden(_nom_tipo character, _descr_tipo text)
RETURNS boolean AS
$BODY$
begin
INSERT INTO tipo_incidencia(nom_tipo,descr_tipo) VALUES(_nom_tipo,_descr_tipo);
RETURN True;
exception
when integrity_constraint_violation then
ROLLBACK TO my_savepoint;
RETURN False;
end;$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
Te gustoon
