H
hugolesme author
Hello I have 2 tables
- articulo
with 2 fields of barcodes idartic serial NOT NULL
descartic character varying(100) NOT NULL,
codbarra1 character varying(30)
codbarra2 character varying(30) and
- codigobarra
idcodigodebarra serial NOT NULL,
idtipocodigodebarra integer NOT NULL,
idarticulo integer NOT NULL,
codigodebarra character varying(30) NOT NULL, And a Trigger Function, on Insert event over table articulo CREATE OR REPLACE FUNCTION insert_precioventa_codbarra()
RETURNS "trigger" AS
$BODY$ BEGIN
IF TG_OP = 'INSERT' THEN IF NEW.codbarra1 IS NOT NULL THEN
INSERT INTO codigodebarra (idtipocodigodebarra,idarticulo,codigodebarra)
VALUES (2,NEW.idarticulo,NEW.codbarra1);
END IF; IF NEW.codbarra2 IS NOT NULL THEN
INSERT INTO codigodebarra (idtipocodigodebarra,idarticulo,codigodebarra)
VALUES (2,NEW.idarticulo,NEW.codbarra2);
END IF; RETURN NEW;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION insert_precioventa_codbarra() OWNER TO postgres; I have made a Project in PHPRunner and built it In the articulo add page when I register a product and leave empty (NULL) the field codbarra1 and codbarra2 the PHPRunner inserts a ( '' ) 2 quoted value with nothing between ? Why??????
It makes my unique constraint to block the Insert because it inserts '' in every register Hugo - Paraguay
|
|