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 >>





 
  Top Home Privacy Feedback  
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky
Copyright 2016 - All Rights Reserved
Last Modified: 28 Jun 2020