J'ai un petit problème, la fonction fonctionne pas et je ne comprends pas pourquoi...
Erreur SQL :
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 CREATE FUNCTION "chk_dispo" (int, int, date, date, int) RETURNS boolean AS 'DECLARE idarech ALIAS FOR $1; idurech ALIAS FOR $2; date1 ALIAS FOR $3; date2 ALIAS FOR $4; qtdemandee ALIAS for $5; total INTEGER; dispo INTEGER; BEGIN total = 0; dispo = 0; SELECT SUM(quantite) AS total FROM mouvement WHERE idarticle = idarech AND es = true AND idcom IN (SELECT idcom FROM commande WHERE ''date1'' BETWEEN datesortie AND dateretour OR ''date2'' BETWEEN datesortie AND dateretour); SELECT quatitetot FROM article WHERE idarticle = idarech; dispo = quatitetot - total; IF(dispo > qtdemandee) THEN return true; ELSE return false; END IF; END;' LANGUAGE "plpgsql"
ERROR: syntax error at or near "$1"
Partager