HP 3000 Manuals

Defining and Using Host Variables with Date/Time Functions [ ALLBASE/SQL C Application Programming Guide ] MPE/iX 5.0 Documentation


ALLBASE/SQL C Application Programming Guide

Defining and Using Host Variables with Date/Time Functions 

Date/time functions can be used in the way an expression is used; that
is, in a select list to indicate the columns you want in the query
result, in a search condition to define the set of rows to be operated
on, and to define the value of a column when using the UPDATE command.
(See the ALLBASE/SQL Reference Manual for in-depth information regarding
expressions.)

Whether you use host variables or literal strings to specify the
parameters of the date/time functions depends on the elements of your
application and on how you are using the functions.  This section focuses
on the use of host variables.

You can use host variables to specify input or output format
specifications.  Use them as well to hold data input to and any resulting
data output from the date/time functions.  (Host variables cannot be used
to indicate column names.)

Host variables for format specifications must be defined in your
application to be compatible with ALLBASE/SQL CHAR or VARCHAR data types.
The exception is the ADD_MONTHS function which requires an INTEGER
compatible host variable.

As for host variables containing input and output data, define them to be
CHAR or VARCHAR compatible with one exception.  The TO_INTEGER function
requires an INTEGER compatible host variable for its output.

Reference the chapter on defining host variables for additional
information about defining a host variable to be compatible with a
specific ALLBASE/SQL data type.  Note that the declarations relate to the
default format specification for each date/time data type.  Your
declaration must reflect the length of the format you are using.

Table 11-2  shows host variable data type compatibility for date/time
functions.

          Table 11-2.  Host Variable Data Type Compatibility for Date/Time Functions 

-----------------------------------------------------------------------------------------------------
|                   |                   |                   |                   |                   |
|     Date/Time     |   Input Format    |   Output Format   |    Input Data     |    Output Data    |
|     Function      |   Specification   |   Specification   |                   |                   |
|                   |                   |                   |                   |                   |
-----------------------------------------------------------------------------------------------------
|                   |                   |                   |                   |                   |
| TO_DATE           | (VAR)CHAR         |                   | (VAR)CHAR         | (VAR)CHAR 1       |
|                   |                   |                   |                   |                   |
| TO_TIME           |                   |                   |                   |                   |
|                   |                   |                   |                   |                   |
| TO_DATETIME       |                   |                   |                   |                   |
|                   |                   |                   |                   |                   |
| TO_INTERVAL       |                   |                   |                   |                   |
|                   |                   |                   |                   |                   |
-----------------------------------------------------------------------------------------------------
|                   |                   |                   |                   |                   |
| TO_CHAR           |                   | (VAR)CHAR         |                   | (VAR)CHAR         |
|                   |                   |                   |                   |                   |
-----------------------------------------------------------------------------------------------------
|                   |                   |                   |                   |                   |
| TO_INTEGER        |                   | (VAR)CHAR         |                   | INTEGER           |
|                   |                   |                   |                   |                   |
-----------------------------------------------------------------------------------------------------
|                   |                   |                   |                   |                   |
| ADD_MONTHS        | INTEGER           |                   |                   | (VAR)CHAR 1       |
|                   |                   |                   |                   |                   |
-----------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------
|                                                                                        |
| 1 Applies only when used in a select list.                                             |
|                                                                                        |
------------------------------------------------------------------------------------------



MPE/iX 5.0 Documentation