Home Page for the TeradataForum
 
 

 

UDF Library: 'is_integer'

Component: 'is_integer_v.c'


 
<< readme.txt install_from_server.txt >>

#define SQL_TEXT Latin_Text
#include "sqltypes_td.h"
#include <string.h>
#include <stdlib.h>
#define IsNull -1
#define IsNotNull 0

void is_integer_v( VARCHAR_LATIN *inputString,
                   int *result,
                   int *inputStringIsNull,
                   int *ResultIsNull,
                   char sqlstate[6],
                   SQL_TEXT extname[129],
                   SQL_TEXT specific_name[129],
                   SQL_TEXT error_message[257] )
{
    char *ch;

    *error_message = '\0';
    *ResultIsNull = 0;

    /* make false result the default */
    *result = 0;

    /* Return Null value on Null Input */
    if ((*inputStringIsNull) == IsNull)
    {
        return;
    }

/* what is an Integer

         [+|-] xxxx
*/


    ch = (char *)inputString;

    /* Skip leading spaces */
    /*   remove this while line to disallow Leading whitespace */
    while ( isspace(*ch))   ch ++;

    if ( (*ch == '-') || (*ch == '+' ))
    {
        ch ++;
    }

        /* is the first character at least a digit? */
    if ( !isdigit(*ch) ) return ;

    /* skip over all the digits */
    /* already validated first digit above */
    do
    {
        ch++;
    }
    while (isdigit(*ch)) ;

    /* skip over the trailing white space */
    /* Remove this while line out   to disallow Trailing whitespace */
    while ( isspace(*ch))   ch ++;

    /* we should be at the end of the string.
       if not it is not an integer
    */
    *result = ( *ch == '\0' );

    return;
}


<< readme.txt install_from_server.txt >>





 
 

Recent Threads

Attachments

Library

Library

White Papers

UDFs

·is_integer

·nthValue

·stat_dt

·xparts

 

Teradata PDFs

IBM PDFs

 

Quick Reference

Rules of Conduct

FAQs

Join the Forum

 

Archives

Sample Index

2009  2003
2008  2002
2007  2001
2006  2000
2005  1999 
2004    


 
 
 

 
 
 
 
 
 
 
 
 
  
 
  Top Home Join Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky 
Last Modified: 05 January 2009