This topic is locked

PHPRunner inserts a ( '' ) 2 quoted value with nothing be

8/7/2007 3:24:52 PM
PHPRunner General questions
H
hugolesme author

Hello
I have 2 tables

  1. 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
  2. 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

H
hugolesme author 8/9/2007

Still hoping for some advice
--------------------

Hugo

Paraguay

Sergey Kornilov admin 8/9/2007

You can either remove those fields from the Add page to make sure their are NULL or use BeforeAdd event to assign NULL value explicitly.

H
hugolesme author 8/9/2007

I dont want to remove because the field is optional (the user can fill or not).
If the user fill, the procedure will create a barcode data in the other table.
If the user dont fill, the procedure will ignore it. (In this case with PHPRunner not)
I think I´ll use BeforeAdd event to assign NULL value explicitly. If is really NULL
But, theres a hope PHPRunner New Version to not put ( '' ) in case of null ????.
Because it disables some PostgreSQL pgplsql advantages.
Hugo.