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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| CREATE OR REPLACE PROCEDURE PS_PUBLICATIONS
(
PUB_NO IN PUBLICATIONS.PUB_ID%TYPE,
CAT_ID IN PUBLICATIONS.PUB_ZON_ID%TYPE,
ACTIF IN PUBLICATIONS.PUB_ACT%TYPE,
L_Mot IN VARCHAR2,
curs_pub OUT ref_curseur
)
IS
st NUMBER;
L_Pos NUMBER;
ads BOOLEAN;
chaine VARCHAR2 := '';
temp_cur ref_curseur;
BEGIN
IF L_Mot <> '' THEN
L_Mot := L_Mot || ' ';
st := 1;
L_Pos := INSTR(L_Mot,' ');
ads := FALSE;
WHILE L_Pos > 0 LOOP
IF ads = FALSE THEN
chaine := chaine || "PUB_LIB LIKE '%" || SUBSTR(L_Mot, st, L_Pos - st) || "%' OR PUB_TXT LIKE '%" || SUBSTR(L_Mot, st, L_Pos- st) || "%'";
ads := TRUE;
ELSE
chaine := chaine || " OR PUB_LIB LIKE '%" || SUBSTR(L_Mot, st, L_Pos - st) || "%' OR PUB_TXT LIKE '%" || SUBSTR(L_Mot, st, L_Pos- st) || "%'" ;
END IF;
st := L_Pos + 1;
L_Pos := INSTR(L_Mot,st, ' ');
END LOOP;
END IF;
OPEN temp_cur FOR
SELECT PUBLICATIONS.*,
ZONES.*,
ZONES_1.ZONES_ID AS CAT_SUR_ID,
ZONES_1.ZONES_NOM AS CAT_SUR_LIB
FROM PUBLICATIONS
INNER JOIN ZONES ON PUB_ZON_ID = ZONES.ZONES_ID
INNER JOIN ZONES ZONES_1 ON ZONES.ZONES_ZON_ID = ZONES_1.ZONES_ID
INNER JOIN ZONES ZONES_2 ON ZONES_1.ZONES_ZON_ID = ZONES_2.ZONES_ID
WHERE (PUB_ACT = ACTIF OR ACTIF IS NULL)
AND (PUB_ID = PUB_NO OR PUB_NO IS NULL)
AND (PUB_ZON_ID = CAT_ID OR CAT_ID IS NULL
OR ZONES_1.ZONES_ID = CAT_ID
OR ZONES_2.ZONES_ID = CAT_ID
OR ZONES.ZONES_ID = CAT_ID)
AND (chaine)
ORDER BY PUB_DTE_DEB DESC, PUB_ID DESC;
curs_pub:= temp_cur;
END PS_PUBLICATIONS; |
Partager