Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 29 Oct 2004 @ 04:12:12 GMT


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


Subj:   Re: ASCII function: Return ASCII value of the number
 
From:   Dennis Calkins

CharToHexInt will return the ASCII Value of the charcater string passed to it. However it comes out in HEX and is a CHAR(4). Casting it to an integer won't work because HEX contains APLHA CHARACTERS which don't translate.

     sel char2hexint('A');

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

     Char2HexInt('A')
     ----------------
     0041


      BTEQ -- Enter your DBC/SQL request or BTEQ command:
     sel 1 where ( char2hexint('A') = '0041');

     sel 1 where ( char2hexint('A') = '0041');

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

        1
     ----
        1


     sel char2hexint('ABC');

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

     Char2HexInt('ABC')
     ----------------
     004100420043

If you are 5.1 or later...

An ORD UDF would be pretty simple

     #define SQL_TEXT Latin_Text
     #include "sqltypes_td.h"

     void ORD( CHARACTER_LATIN input[2],
               int        *result,
               char sqlstate[6])
     {
          /* put the parameters in a couple locals */
           *result = input[0];

          return;
     }


     CREATE FUNCTION ORD (A CHAR(1) CHARACTER SET LATIN)
     RETURNS INTEGER
     =85 ;


     
  <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