All Forums Extensibility
ChWaqas 4 posts Joined 02/12
16 Mar 2012
java udf overloading "function already exist"

 

Hi I want to overload the java UDFs but I am getting the "Function already exists"error even function parameters are different for both functions.

 

Here is how my java UDF code looks like

public class Mask_Num_ChangeRand {

	/**
	 * @param number
	 * @param limit
	 * @return
	 */

public static String mask_Num_ChangeRand(String number, int limit) {
		
		
		return "string";
	}
	public static long mask_Num_ChangeRand(long number, int limit) {
		
return 2;
	}
	
	


}

 

And Here is how I am creating function

CREATE FUNCTION "TEST_DB"."MASK_NUM_CHANGERAND" (
		"number" VARCHAR(256),
		"percent" INTEGER)
	RETURNS VARCHAR(256)
	SPECIFIC "mask_Num_ChangeRand"
	LANGUAGE JAVA
	NO SQL
	PARAMETER STYLE JAVA
	DETERMINISTIC
	RETURNS NULL ON NULL INPUT
	EXTERNAL NAME 'Mask_Num_ChangeRandJarId: mask_Num_ChangeAndRand.Mask_Num_ChangeRand.mask_Num_Ch angeRand(java.lang.String,int) returns java.lang.String';

CREATE FUNCTION "TEST_DB"."MASK_NUM_CHANGERAND" (
		"number" BIGINT,
		"percent" INTEGER)
	RETURNS BIGINT
	SPECIFIC "mask_Num_ChangeRand"
	LANGUAGE JAVA
	NO SQL
	PARAMETER STYLE JAVA
	DETERMINISTIC
	RETURNS NULL ON NULL INPUT
	EXTERNAL NAME 'Mask_Num_ChangeRandJarId: mask_Num_ChangeAndRand.Mask_Num_ChangeRand.mask_Num_Ch angeRand(long,int) returns long';
	

Can someone point out that what am I doing wrong?Thanks in advance.

rwalliser 2 posts Joined 11/06
10 Apr 2012

The value for SPECIFIC must be unique.

At your case

  1. SPECIFIC mask_Num_ChangeRand_Text
  2. SPECIFIC mask_Num_ChangeRand_Numeric

After that, Eclipse show your both function (MASK_NUM_CHANGERAND).

Notice: Teradata SQL Assistant will display the specific name

 

To drop a specific function look at http://forums.teradata.com/forum/extensibility/drop-overloaded-udf

Renato

 

You must sign in to leave a comment.