Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 28 Oct 2003 @ 19:17:22 GMT


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


Subj:   Re: Problem related to number
 
From:   Calvert, Jim

John:

I have done a fair amount of work lately on UDFs. They really do exist in V2R5.1 ( not vapourware ).

The following is an actual albeit simple UDF in C.

#define SQL_TEXT Latin_Text
#include "sqltypes_td.h"
#include 
#include 
#define NoSqlError "00000"

void ByteToInteger (BYTE *inputByte,
                                INTEGER *result,
                                char sqlstate[6])
{
        strcpy(sqlstate, NoSqlError);

        memcpy( (BYTE *) result, (BYTE *) inputByte + 2, 2);
        memcpy( (BYTE *) result + 2, (BYTE *) inputByte, 2);

        return;
}

The following is the associated CREATE FUNCTION statement for the function above.

CREATE FUNCTION YourID.BYTETOINTEGER (InByte BYTE(4) )
 RETURNS INTEGER
 SPECIFIC ByteToInteger
 LANGUAGE C
 NO SQL
 PARAMETER STYLE TD_GENERAL
 NOT DETERMINISTIC
 RETURNS NULL ON NULL INPUT
 EXTERNAL NAME
'SS!ByteToInteger!/home/YourDirectory/ByteToInteger.c!F!ByteToInteger'
;

Trust me, they work and you will be excited!

Jim Calvert - Teradata Canada



     
  <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