JUDF Aggregate UDFs execute error.help~~


JUDF Aggregate UDFs execute error.help~~


i'm back agin.i wann to build a "GROUP CONCAT" function ,like mysql's group_concat(oracle has:wm_sys.wm_concat),and i build a C udf yestoday,but not success,so i create a JUDF,l worked with teradata plugin for eclipse .and it works in simple samples.but ,when i write and complie and deploy and execute the GroupConcat function ,i meet failure again, it report error:

[Teradata Database] [TeraJDBC] [Error 7825] [SQLState 38000] in UDF/XSP/UDM FW.gpConcat: SQLSTATE 38101: 

when i execute a query:

select os.SUPER_BR_CODE,fw.gpConcat(os.BR_CODE) 


group by 1


this is my JUDF code :


package judf;

import java.sql.SQLException;

import com.teradata.fnc.Context;

import com.teradata.fnc.Phase;

import java.io.Serializable;

import java.lang.String;

public class GpConcat {

public static String gpConcat(Phase phase, Context[] context, String name)

throws SQLException {

String returnValue = null;

// TODO Auto-generated method stub

try {

GpCStor s1 = null;


* AGR_DETAIL, AGR_COMBINE, and AGR_FINAL phases use the value from

* the aggregate storage area.


if (phase.getPhase() > Phase.AGR_INIT

&& phase.getPhase() < Phase.AGR_NODATA) {

s1 = (GpCStor) context[0].getObject(1);


switch (phase.getPhase()) {

/* The AGR_INIT phase is executed once. */

case Phase.AGR_INIT:

s1 = new GpCStor();

/* Fall through to detail phase also. */

case Phase.AGR_DETAIL:

// TODO Perform SUM



case Phase.AGR_COMBINE:

GpCStor s2 = (GpCStor) context[0].getObject(2);


// TODO SUM between AMPs.


case Phase.AGR_FINAL:

returnValue = s1.getName();

// TODO Final, return SUM.


case Phase.AGR_NODATA:

/* Not expecting no data. */

return null;


throw new SQLException("Invalid Phase", "38U05");


/* Save the intermediate SUM in the aggregate storage. */

context[0].setObject(1, s1);

} catch (Exception ex) {

throw new SQLException(ex.getMessage(), "38101");


return returnValue;



class GpCStor implements Serializable {

private StringBuffer name;

public GpCStor() {

// TODO Initialize to context object to maximum size

name = new StringBuffer();


public java.lang.String getName() {

return this.name.toString();


public void setName(java.lang.String name) {





i develop and deploy it with the Teradata plugin for Eclipse.

Tags (1)