Firebird SQL – URL parse procedure
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 |
create or alter procedure SP_PARSE_URL ( p_url VARCHAR(32000) ) RETURNS ( protocol VARCHAR(10), host VARCHAR(255), path VARCHAR(32000) ) AS BEGIN IF (POSITION('://' IN p_url) > 0) THEN protocol = SUBSTRING(p_url FROM 1 FOR POSITION('://' IN p_url) - 1); ELSE protocol = ''; IF (POSITION('://' IN p_url) > 0) THEN p_url = SUBSTRING(p_url FROM POSITION('://' IN p_url) + 3); ELSE p_url = p_url; IF (POSITION('/' IN p_url) > 0) THEN BEGIN host = SUBSTRING(p_url FROM 1 FOR POSITION('/' IN p_url) - 1); p_url = SUBSTRING(p_url FROM POSITION('/' IN p_url)); END ELSE BEGIN host = p_url; p_url = ''; END path = p_url; SUSPEND; END |