Created
April 7, 2022 12:49
Star
You must be signed in to star a gist
PL/SQL function defined in SQL WITH clause
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH | |
| FUNCTION get_domain(url VARCHAR2) RETURN VARCHAR2 IS | |
| pos BINARY_INTEGER; | |
| len BINARY_INTEGER; | |
| BEGIN | |
| pos := INSTR( url, 'www.' ); | |
| len := INSTR( SUBSTR( url, pos + 4 ), '.' ) - 1; | |
| RETURN SUBSTR( url, pos + 4, len ); | |
| END; | |
| SELECT DISTINCT url, get_domain(url) AS domain | |
| FROM websites; | |
| URL DOMAIN | |
| ---------------- -------- | |
| www.oracle.com oracle | |
| www.graalvm.org graalvm | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment