Browse Prior Art Database

Method of SQL Data Type Recognition Based on Data Analysis

IP.com Disclosure Number: IPCOM000121679D
Original Publication Date: 1991-Sep-01
Included in the Prior Art Database: 2005-Apr-03
Document File: 4 page(s) / 106K

Publishing Venue

IBM

Related People

Boykin, JR: AUTHOR

Abstract

Disclosed is a method for determining data type based on its contents. BACKGROUND

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 36% of the total text.

Method of SQL Data Type Recognition Based on Data Analysis

      Disclosed is a method for determining data type based on
its contents.
BACKGROUND

      The OS/2* 1.2 Extended Edition Database Manager contains
support for the OS/2 Procedures Language (REXX). This support entails
the use of REXX variables in SQL statements.  As REXX is an
interpreted language based on character representation of data, there
is no variable declaration or type enforcement by a compiler or its
equivalent when assigning the contents of a variable.

      The SQL language supports the use of host variables within
various SQL statements.  These host variables are utilized to pass
data between an application and the Database Manager.  As there is no
variable declaration or data type enforcement within REXX, the
Database Manager does not have the luxury of both being informed of a
variable's data type and assured of its contents.

      The invention is the determination of the data type of REXX
host variables.

      Data types recognized include the following:
          Character - A string with a leading and trailing apostrophe
or which does not qualify as one of the four remaining types.
          Graphic   - A string with a leading and trailing apostrophe
and preceded by a G (i.e., G'<text>').
          Float     - A number that is in scientific notation
possibly surrounded by blanks.
          Decimal   - A number with a decimal point possibly
surrounded by blanks.
          Integer   - All other numbers possibly surrounded by
blanks.
THE INVENTION - A METHOD FOR DETERMINING DATA TYPE
Overview
      The algorithm performs as enumerated below:
      1.   The algorithm first detects if the variable contents are
enclosed within apostrophes without any leading characters.  If so,
the character type must be CHARACTER.
      2.   Next, the algorithm detects if the variable contents are
enclosed within apostrophes and preceded by an uppercase G.  If so,
the character type must be GRAPHIC.
      3.   The algorithm then removes all leading and trailing
blanks.
      4.   Next, the algorithm walks through the remaining data
characters setting the data type of the variable based on the current
character and previous determined data type.  If at any time an
invalid character is encountered for the current data type, the data
type is changed to CHARACTER and the loop terminates.
      5.   If the algorithm has determined the data type to be
CHARACTER, the leading and trailing blanks are restored.
      6.   Lastly, a pointer to the determined data and its length is
returned to the routine's caller.
The Algorithm
{
   /* set a local data pointer variable to the input data pointer */
   /* set a local data length variable to the input data length */
   /* initialize data type to CHARACTER */
   /* if the length of the data is not 0 */
   {...