0

I'd like to create a PL SQL table that stores User defined error messages but when trying to assign a message to my table I get an error.

It seems like there an issue when trying to access the table using the index '-20001'.

Am I doing it wrong?

Here is the code

create or replace PACKAGE GESTIONNAGEURS 
AS 
   -- ----- TYPES ----- --
   TYPE T_TableNageurs IS TABLE OF Nageurs%ROWTYPE INDEX BY PLS_INTEGER;
   TYPE T_Exception IS TABLE OF VARCHAR2(256) INDEX BY BINARY_INTEGER;

   -- ----- EXCEPTIONS ----- --
   V_ExTable   T_Exception;

   ExParaListerNULL        EXCEPTION;
   V_ExTable(20001)       := 'Erreur : Fonction Lister : Au moins un des parametres est NULL!';

   ExParaListerINV         EXCEPTION;
   V_ExTable(-20002)       := 'Erreur : Fonction Lister : Au moins un des parametres est INVALIDE!';

   ExNageuses              EXCEPTION;
   V_ExTable(-20003)       := 'Erreur : Fonction Lister : ';

   ExParaSupprNULL         EXCEPTION;
   V_ExTable(-20004)       := 'Erreur : Procedure Supprimer : Au moins un des parametres est NULL!';

   ExParaSupprINV          EXCEPTION;
   V_ExTable(-20005)       := 'Erreur : PROCEDURE Supprimer : Au moins un des parametres est INVALIDE!';

   ExDelete                EXCEPTION;
   V_ExTable(-20006)       := 'Erreur : Procedure Supprimer : ';

   ExParaMod               EXCEPTION;
   V_ExTable(-20007)       := 'Erreur : Procedure Modifier : Au moins un des parametres est NULL!';


   -- ----- METHODES ----- --
   FUNCTION LISTER ( P_NRCOMPETITION IN NUMBER, P_ANNEE IN NUMBER, P_NRJOUR IN NUMBER ) RETURN T_TableNageurs;

   -- ----- PROCEDURES ----- --
   PROCEDURE SUPPRIMER ( P_NRLIGUE IN Nageurs.NrLigue%TYPE, P_ANNEE IN Nageurs.AnneeNaiss%TYPE );



   /* TODO enter package declarations (types, exceptions, methods etc) here */ 

 END GESTIONNAGEURS;

Here is the error message I get :

Erreur(11,12): PLS-00103: Encountered the symbol "(" when expecting one of the following:     constant exception <identificateur>    <identificateur entre guillemets> table long double ref char    time timestamp interval date binary national character nchar The symbol "<identificateur>" was substituted for "(" to continue. 
Erreur(14,12): PLS-00103: Encountered the symbol "(" when expecting one of the following:     constant exception <identificateur>    <identificateur entre guillemets> table long double ref char    time timestamp interval date binary national character nchar The symbol "<identificateur>" was substituted for "(" to continue. 
Erreur(17,12): PLS-00103: Encountered the symbol "(" when expecting one of the following:     constant exception <identificateur>    <identificateur entre guillemets> table long double ref char    time timestamp interval date binary national character nchar The symbol "<identificateur>" was substituted for "(" to continue. 
Erreur(20,12): PLS-00103: Encountered the symbol "(" when expecting one of the following:     constant exception <identificateur>    <identificateur entre guillemets> table long double ref char    time timestamp interval date binary national character nchar The symbol "<identificateur>" was substituted for "(" to continue. 
Erreur(23,12): PLS-00103: Encountered the symbol "(" when expecting one of the following:     constant exception <identificateur>    <identificateur entre guillemets> table long double ref char    time timestamp interval date binary national character nchar The symbol "<identificateur>" was substituted for "(" to continue. 
Erreur(26,12): PLS-00103: Encountered the symbol "(" when expecting one of the following:     constant exception <identificateur>    <identificateur entre guillemets> table long double ref char    time timestamp interval date binary national character nchar The symbol "<identificateur>" was substituted for "(" to continue. 
Erreur(29,12): PLS-00103: Encountered the symbol "(" when expecting one of the following:     constant exception <identificateur>    <identificateur entre guillemets> table long double ref char    time timestamp interval date binary national character nchar The symbol "<identificateur>" was substituted for "(" to continue. 
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Axel Samyn
  • 160
  • 1
  • 12

1 Answers1

0

You're getting that error because you're trying to set the contents of the array from within the declaration section. You can't do that - you'd have to do it in the package body (yes, packages can have a BEGIN section of their very own!).

However, I think you're probably after something like the custom error package mentioned in this post.

Community
  • 1
  • 1
Boneist
  • 22,910
  • 1
  • 25
  • 40