JUDF Aggregate UDFs execute error.help~~

Database

JUDF Aggregate UDFs execute error.help~~

hello

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 13.00.00.02] [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) 

from fview.ORG_SECURITY_TRADER os

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

s1.setName(","+name); 

break;

case Phase.AGR_COMBINE:

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

s1.setName(","+s2.getName());

// TODO SUM between AMPs.

break;

case Phase.AGR_FINAL:

returnValue = s1.getName();

// TODO Final, return SUM.

break;

case Phase.AGR_NODATA:

/* Not expecting no data. */

return null;

default:

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) {

this.name.append(name);

}

}


--------------------------

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

Tags (1)