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 :

return text[]


Sujet :

PostgreSQL

  1. #1
    Nouveau membre du Club Avatar de Warz
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 48
    Points : 38
    Points
    38
    Par défaut return text[]
    Salut All !

    J'ai une fonction plsql, appellée dans une autre fonction plsql.

    La première renvoie un text[].

    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
     
    --Fonction Explode qui transforme une chaine de caracteres en tableau
    CREATE OR REPLACE FUNCTION explode(stringArray text, separator text)  RETURNS text[] AS'
     
    DECLARE
    postgresArray			text[];
    restStringArray			text;
    beginning			int;
    ending				int;
    currentSeparatorPosition	int;
    currentValue			text;
    i				int;
     
    BEGIN
    postgresArray:=''{}'';
    IF position(''{'' in stringArray)>0 AND position(''}'' in stringArray)>0 THEN
    	beginning:=position(''{'' in stringArray)+1;
    	ending:=position(''}'' in stringArray)-beginning;
    	restStringArray:=substring(stringArray from beginning for ending);
    	currentSeparatorPosition:=position(separator in restStringArray)-1;
    	i:=1;
    	WHILE currentSeparatorPosition>0 LOOP
    		currentValue:=substring(restStringArray from 1 for currentSeparatorPosition-1);
    		postgresArray[i]:=currentValue;
    		restStringArray:=substring(restStringArray from currentSeparatorPosition+1);
    		i:=i+1;
    		currentSeparatorPosition:=position(separator in restStringArray);
    	END LOOP;
    ELSE
    	postgresArray[1]:=''Error : '' || stringArray || '' is not formated as an array ({..,..,..}).'';
    END IF;
    RETURN postgresArray;
    END;
     
    'LANGUAGE 'plpgsql' ;
    Quand j'appelle cette première fonction dans la deuxième :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    ...
    DECLARE
    typeCritere text;
    tabTypeCritere text[];
    ...
    BEGIN
    typeCritere:=''{80,'''',21}'';
    SELECT INTO tabTypeCritere explode(typeCritere,'','');
    ...
    j'ai un erreur et j'ai l'impression qu'il n'arrive pas à mettre un text[] dans un autre text[].

    J'ai oublié de faire un truc ???

  2. #2
    Nouveau membre du Club Avatar de Warz
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 48
    Points : 38
    Points
    38
    Par défaut
    Désolé, mon explode était nul...

    currentSeparatorPosition:=position(separator in restStringArray);

    et pas -1

    Résolu

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

Discussions similaires

  1. return only Text
    Par lolalilo dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 28/05/2013, 19h15
  2. Unbind touche return widget Text
    Par atalon1 dans le forum Tkinter
    Réponses: 2
    Dernier message: 01/07/2008, 18h10
  3. return setof text[]
    Par mereyj dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 05/04/2005, 09h29
  4. afficher du texte
    Par Mau dans le forum OpenGL
    Réponses: 10
    Dernier message: 24/06/2003, 15h31
  5. Réponses: 2
    Dernier message: 10/06/2002, 11h03

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