Précédent   Forum des professionnels en informatique > Bases de données > PostgreSQL > Débuter
Débuter Forum d'entraide : Débuter en base de données avec PostgreSQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 31/03/2011, 22h31   #1
Futur Membre du Club
 
Inscription : décembre 2009
Messages : 105
Détails du profil
Informations forums :
Inscription : décembre 2009
Messages : 105
Points : 17
Points : 17
Par défaut ERROR: record "new" is not assigned yet

Bonjour,

Je cherche à inserer dans la table acteur un nupplet
Mais je reçois un message d'erreur:

Code :
1
2
3
ERROR:  record "new" IS NOT assigned yet
DETAIL:  The tuple structure of a not-yet-assigned record IS indeterminate.
CONTEXT:  PL/pgSQL FUNCTION "functiontriggerinsertionacteur" line 2 at IF
Voici mon code:

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
CREATE OR REPLACE FUNCTION b.functionTriggerinsertionacteur()
returns TRIGGER AS 
'
BEGIN
IF(NEW.ArtistID, NEW.nom, NEW.nationalite) IN
(Select ArtistID,nom,nationalite From b.artiste) 
Then Insert Into b.acteur Values (NEW.ArtistID, NEW.Nom, NEW.nationalite);
END IF;
RETURN NEW;
END;
'
LANGUAGE 'plpgsql';
 
 
CREATE TRIGGER INSERTIONACTEUR
BEFORE INSERT ON b.Acteur
FOR each statement
execute procedure b.functionTriggerinsertionacteur()
Pouvez vous m'aider svp? Merci
bsangoku est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/03/2011, 22h37   #2
Modérateur
 
Inscription : octobre 2008
Messages : 1 505
Détails du profil
Informations personnelles :
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : octobre 2008
Messages : 1 505
Points : 2 034
Points : 2 034
A mon sens ce n'est pas un trigger FOR EACH STATEMENT qu'il faut employer ici, mais FOR EACH ROW.
estofilo est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 05h47   #3
Futur Membre du Club
 
Inscription : décembre 2009
Messages : 105
Détails du profil
Informations forums :
Inscription : décembre 2009
Messages : 105
Points : 17
Points : 17
Merci de m'aider: il s'agit de mon premier trigger (et j'en ai vu qu'un seul en cours()

OK maintenant le code est devenu:

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
CREATE OR REPLACE FUNCTION functionTriggerinsertionacteur()
returns TRIGGER AS 
'
BEGIN
if New.artistID not in (Select artistID From artiste)
THEN RAISE EXCEPTION ''lacteur nest pas present dabs artiste '';
ELSE if (NEW.nom, NEW.nationalite) not in (Select nom, nationalite From artiste) 
THEN RAISE EXCEPTION '' artist_id deja utilise''; 
ELSE
INSERT INTO acteur VALUES (NEW.ArtistID, NEW.Nom, NEW.nationalite);
END IF;
END IF;
END;'
LANGUAGE 'plpgsql';
 
CREATE TRIGGER INSERTIONACTEUR
BEFORE INSERT ON Acteur
FOR each row
execute procedure functionTriggerinsertionacteur();
Maintenant j'ai ce problème

Code :
1
2
3
4
5
6
7
8
9
10
11
12
 
ERROR:  stack depth LIMIT exceeded
HINT:  Increase the configuration parameter "max_stack_depth", after ensuring the platform's stack depth limit is adequate.
CONTEXT:  SQL statement "SELECT   $1  not in (Select artistID From artiste)"
PL/pgSQL function "functiontriggerinsertionacteur" line 2 at IF
SQL statement "INSERT INTO acteur VALUES ( $1 ,  $2 ,  $3 )"
PL/pgSQL function "functiontriggerinsertionacteur" line 7 at SQL statement
SQL statement "INSERT INTO acteur VALUES ( $1 ,  $2 ,  $3 )"
PL/pgSQL function "functiontriggerinsertionacteur" line 7 at SQL statement
SQL statement "INSERT INTO acteur VALUES ( $1 ,  $2 ,  $3 )"
PL/pgSQL function "functiontriggerinsertionacteur" line 7 at SQL statement
SQL statement "INSERT INTO acteur VALUES ( $1 ,  $2 ,  $3 )"
bsangoku est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 05h58   #4
Futur Membre du Club
 
Inscription : décembre 2009
Messages : 105
Détails du profil
Informations forums :
Inscription : décembre 2009
Messages : 105
Points : 17
Points : 17
non c'est bon merci!!!!!!!!!!!!!!
bsangoku est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 04h03.


 
 
 
 
Partenaires

Hébergement Web