Created
February 3, 2011 18:53
-
-
Save alf239/809944 to your computer and use it in GitHub Desktop.
Aggregare function for HSQL to emulate Oracle's WM_CONCAT
This file contains hidden or 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
| @SuppressWarnings("unused") | |
| public static String wmConcat(String in, Boolean flag, | |
| String[] register, Integer[] counter) { | |
| if (flag) { | |
| if (register[0] == null) { | |
| return null; | |
| } | |
| return register[0]; | |
| } | |
| if (in == null) { | |
| return null; | |
| } | |
| if (register[0] == null) { | |
| register[0] = in; | |
| counter[0] = 1; | |
| } else { | |
| register[0] += "," + in; | |
| counter[0]++; | |
| } | |
| return null; | |
| } |
This file contains hidden or 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
| CREATE AGGREGATE FUNCTION wm_concat( | |
| IN val VARCHAR(255), IN flag BOOLEAN, | |
| INOUT register VARCHAR(255), INOUT counter INT) | |
| RETURNS VARCHAR(512) | |
| NO SQL | |
| LANGUAGE JAVA | |
| EXTERNAL NAME 'CLASSPATH:uk.ac.ebi.gxa.dao.AtlasDAOTestCase.wmConcat' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please note the stacktraces are not too useful if an exception is thrown by a custom function. Log everything or, better, use a debugger