Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 07 Oct 2004 @ 14:41:35 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: UDF - Overloading inbuilt functions
 
From:   Michael Larkins

Narayan:

The SUM function is a unary function. Therefore, it expects a single value upon which to operate. If you mean that overloading a function is passing too many values to it, I am guessing the answer is no. I say this because if you put anything in the function between the column and the right parentheses, you get a 3706 syntax error.

From your description, I cannot understand all the aspects of your challenge. However, there does not seem to be an overwhelming need to write a UDF to accomplish what you are seeking. It looks like you can do what you are asking using the SUM in junction with a CASE statement. Something like this (a guess based on your positive and even):

     SUM(CASE WHEN col1 > 0 THEN col1
              WHEN col1 < 0 THEN ABS(col1)
              WHEN col1 mod 2 = 0 THEN col1*2 /* even number */
              WHEN col1 mod 2 = 1 THEN (col1+1)*2 /* odd number */
        /* zero, by default returns a NULL to the SUM */  END)

Again, I have no illusion that this is the actual solution for what you are asking about because I do not have enough info to know what you want to do when it is positive vs what you want to do when it is even or anything else. It is simply intended to point you in a direction that may help you. If it does not provide the basis for you solution - then you can write a UDF.


Cheers,

Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023