Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 25 Feb 2014 @ 22:20:29 GMT


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


Subj:   UDF using DECIMAL8 OR DECIMAL16 VALUES to pass decimal(18, 2) values
 
From:   Satti, Faheem

Hi Folks,

need the help to create a UDF in C using DECIMAL8 OR DECIMAL16 VALUES to pass input values defined as decimal(18,2) values

This code works and gives result:

     input/output size <= (9,2)

     REPLACE FUNCTION plusudfdec(
         a   DECIMAL(9,2),
         b   DECIMAL(9,2)
     )RETURNS DECIMAL(9,2)
     LANGUAGE C
     NO SQL
     EXTERNAL NAME 'CS!plusudfdec!C:\Users\Documents\UDFs\dec\plusudfdec.c'
     PARAMETER STYLE TD_GENERAL;

     #define SQL_TEXT Latin_Text
     #include 
     #include 
     #include 
     #include 
     #include 

     void plusudfdec(DECIMAL4 *a, DECIMAL4 *b, DECIMAL4 *result, char
     sqlstate[5])
     {  *result = *a + *b;}
     ;

     select plusudfdec(5.1,10.3);

      *** Query completed. One row found. One column returned.
      *** Total elapsed time was 1 second.

     plusudfdec(5.1,10.3)
     --------------------
                    15.40

Increase the input/output size from (9,2) to (10,2) and in c program from

     DECIMAL4 to DECIMAL8
     This does not compile
     REPLACE FUNCTION plusudfdec(
         a   DECIMAL(10,2),
         b   DECIMAL(10,2)
     )RETURNS DECIMAL(10,2)
     LANGUAGE C
     NO SQL
     EXTERNAL NAME 'CS!plusudfdec!C:\Users\UDFs\dec\plusudfdec.c'
     PARAMETER STYLE TD_GENERAL;

     #define SQL_TEXT Latin_Text
     #include 
     #include 
     #include 
     #include 
     #include 


     void plusudfdec(DECIMAL8 *a, DECIMAL8 *b, DECIMAL8 *result, char
     sqlstate[5])
     {  *result = *a + *b;}
     ;

     Errors/Warnings reported during compilation


     
  <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