Firebird SQL – URL parse procedure
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