IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PostgreSQL Discussion :

ERROR: record "new" is not assigned yet


Sujet :

PostgreSQL

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre très actif
    Profil pro
    Inscrit en
    Février 2007
    Messages
    126
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2007
    Messages : 126
    Par défaut ERROR: record "new" is not assigned yet
    Bonjour,

    Je reçois le message d'erreur suivant lorsque j'insère une ligne dans la table "implantation".

    ERROR: record "new" is not assigned yet
    DETAIL: The tuple structure of a not-yet-assigned record is indeterminate.
    CONTEXT: PL/pgSQL fuction "setcreele" line 2 at assignement
    Cette table a 2 triggers qui appellent chacun une fonction. D'autres tables ont les mêmes triggers vers les mêmes fonctions et là tout se passe bien.
    J'ai essayé après avoir changé le nom de la table, en ayant supprimé la plupart des colonnes, essayé sur des serveurs différents, en remplaçant "new" par "old" dans les fonctions, mais ... rien à faire.

    Quelqu'un pourrait-il me dire pourquoi ce problème survient sur cette tables-là et comment je pourrais le résoudre. J'ai mis ci-dessous le DDL des tables etc.

    Merci d'avance.



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    CREATE FUNCTION public.SetMajLe()
    RETURNS "trigger"
     LANGUAGE 'plpgsql'
     VOLATILE
    AS
    $$
    begin
    new.MajLe = now();
    return new;
    end;
    $$
    ;
     
    CREATE FUNCTION public.SetCreeLe()
    RETURNS "trigger"
     LANGUAGE 'plpgsql'
     VOLATILE
    AS
    $$
    begin
    new.CreeLe = now();
    new.MajLe = now();
    return new;
    end;
    $$
    ;
     
     
    -- Sequence: autonumidseq
     
    CREATE SEQUENCE autonumidseq
      INCREMENT 1
      MINVALUE 1
      MAXVALUE 9223372036854775807
      START 1003461
      CACHE 1;
    ALTER TABLE autonumidseq OWNER TO postgres;
    GRANT ALL ON TABLE autonumidseq TO postgres;
    GRANT SELECT, UPDATE ON TABLE autonumidseq TO sigalebu;
     
     
    -- Table: implantation
     
    CREATE TABLE implantation
    (
      idimplantation integer NOT NULL DEFAULT nextval('autonumidseq'::regclass),
      idlocalite integer NOT NULL DEFAULT 11,
      rue character varying(50),
      numeropolice character varying(10),
      coordx character varying(10), -- coordonnée X (pour la cartographie)
      coordy character varying(10), -- coordonnée Y (pour la cartographie)
      secteurstatistique character varying(10), -- code du secteur statistique (pour la cartognaphie)
      telephone character varying(15),
      fax character varying(15),
      commentaire text,
      actif smallint NOT NULL DEFAULT (-1),
      bufint integer,
      bufstr character varying(20),
      creele timestamp without time zone,
      creepar character varying(20),
      majle timestamp without time zone,
      majpar character varying(20),
      actifliste smallint DEFAULT (-1),
      ordreliste character varying(20),
      CONSTRAINT pkimplantation PRIMARY KEY (idimplantation),
      CONSTRAINT cuimplantation UNIQUE (idimplantation)
    )
    WITH (
      OIDS=FALSE
    );
    ALTER TABLE implantation OWNER TO postgres;
    GRANT ALL ON TABLE implantation TO postgres;
    GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE implantation TO sigalebu;
     
     
    -- Index: implantationordreliste
     
    CREATE INDEX implantationordreliste
      ON implantation
      USING btree
      (ordreliste, rue);
     
     
    -- Trigger: remplircreele on implantation
     
    CREATE TRIGGER remplircreele
      BEFORE INSERT
      ON implantation
      FOR EACH STATEMENT
      EXECUTE PROCEDURE setcreele();
     
     
    -- Trigger: remplirmajle on implantation
     
    CREATE TRIGGER remplirmajle
      BEFORE INSERT OR UPDATE
      ON implantation
      FOR EACH STATEMENT
      EXECUTE PROCEDURE setmajle();
     
     
    -- Table: creditbudgetaire
     
    CREATE TABLE creditbudgetaire
    (
      idcreditbudgetaire integer NOT NULL DEFAULT nextval('autonumidseq'::regclass),
      idallocationdebase integer NOT NULL,
      idanneebudgetaire integer NOT NULL,
      libellecredit character varying(250) NOT NULL,
      montantinitial numeric(12,2),
      totalvariations numeric(12,2) DEFAULT 0, -- Cumul des variations de crédit (ajustements, redistributions)
      montantactualise numeric(12,2) DEFAULT 0, -- = MontantInitial - TotalVariations
      checkdatemouvements date,
      checkmouvements smallint,
      bufint integer,
      bufstr character varying(20),
      creele timestamp without time zone,
      creepar character varying(20),
      majle timestamp without time zone,
      majpar character varying(20),
      commentaire text,
      ordreliste character varying(20),
      actifliste smallint DEFAULT (-1),
      actif smallint NOT NULL DEFAULT (-1),
      bufidcb character varying(20),
      bufanneebudgetaire character varying(20),
      bufidab character varying(20),
      CONSTRAINT pkcreditbudgetaire PRIMARY KEY (idcreditbudgetaire),
      CONSTRAINT cucreditbudgetaire UNIQUE (idcreditbudgetaire)
    )
    WITH (
      OIDS=FALSE
    );
    ALTER TABLE creditbudgetaire OWNER TO postgres;
    GRANT ALL ON TABLE creditbudgetaire TO postgres;
    GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE creditbudgetaire TO sigalebu;
     
    -- Index: creditallocationdebase
     
    CREATE INDEX creditallocationdebase
      ON creditbudgetaire
      USING btree
      (idallocationdebase);
     
     
    -- Index: creditanneebudgetaire
     
    CREATE INDEX creditanneebudgetaire
      ON creditbudgetaire
      USING btree
      (idanneebudgetaire);
     
     
    -- Index: creditordreliste
     
    CREATE INDEX creditordreliste
      ON creditbudgetaire
      USING btree
      (ordreliste, idcreditbudgetaire);
     
     
    -- Trigger: remplircreele on creditbudgetaire
     
    CREATE TRIGGER remplircreele
      BEFORE INSERT
      ON creditbudgetaire
      FOR EACH ROW
      EXECUTE PROCEDURE setcreele();
     
     
    -- Trigger: remplirmajle on creditbudgetaire
     
    CREATE TRIGGER remplirmajle
      BEFORE INSERT OR UPDATE
      ON creditbudgetaire
      FOR EACH ROW
      EXECUTE PROCEDURE setmajle();

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    1 874
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Octobre 2008
    Messages : 1 874
    Par défaut
    Le problème vient certainement du "FOR EACH STATEMENT" dans la déclaration du trigger qui devrait être "FOR EACH ROW"
    Car l'accès à la variable NEW n'a de sens que pour un trigger qui s'exécute pour chaque ligne.

  3. #3
    Membre très actif
    Profil pro
    Inscrit en
    Février 2007
    Messages
    126
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Février 2007
    Messages : 126
    Par défaut
    Merci.
    C'était bien cela, le problème.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. ERROR: record "new" is not assigned yet
    Par bsangoku dans le forum Débuter
    Réponses: 3
    Dernier message: 01/04/2011, 05h58
  2. Réponses: 6
    Dernier message: 21/10/2005, 18h59
  3. probleme avec : record "new" is not assigned yet D
    Par chtieu dans le forum PostgreSQL
    Réponses: 2
    Dernier message: 31/03/2005, 20h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo