Skip to content

Instantly share code, notes, and snippets.

@alf239
Created February 3, 2011 18:53
Show Gist options
  • Select an option

  • Save alf239/809944 to your computer and use it in GitHub Desktop.

Select an option

Save alf239/809944 to your computer and use it in GitHub Desktop.
Aggregare function for HSQL to emulate Oracle's WM_CONCAT
@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;
}
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'
@alf239
Copy link
Author

alf239 commented Feb 4, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment