Lecture d'un tableau résultant d'une fonction
Bonjour,
J'ai un petit soucis pour accéder aux valeurs d'un tableau qui provient d'une fonction perso.
Cette fonction retourne le tableau de données suivant :
Code:
[0:2]={"{68,3}","{92,1}","{93,7}"}
Je cherche à lire ces infos dans une autre fonction (fonction de test) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
CREATE OR REPLACE FUNCTION test.stock(p_id_article INTEGER) RETURNS VOID AS $$
DECLARE
v_data_stock TEXT[];
i SMALLINT;
v_id_stock INTEGER;
v_quantite INTEGER;
BEGIN
SELECT test.verif_stock(p_id_article) INTO v_data_stock;
i = 0;
WHILE v_data_stock[i] IS NOT NULL LOOP
v_id_stock = v_data_stock[i][0];
v_quantite = v_data_stock[i][1];
RAISE NOTICE 'id_stock=% - quantite_stock=%', v_id_stock, v_quantite;
i = i + 1;
END LOOP;
END;
$$ LANGUAGE plpgsql;
SELECT test.stock(4555846); |
Pour le moment les variables v_id_stock et v_quantite restent vide, je ne vois pas trop comment accéder aux éléments {68,3}, {92,1} et {93,7}
Une idée ?
Merci