Database Fixed-Point Number High Level API

The database fixed-point number high level API module has the file name dbfxp.c. This module provides the programmer with a high level callable API that will store or retrieve database fields, subfields or subsubfields containing fixed-point numbers.

The fixed-point numbers are stored in database fields, subfields or subsubfields without the decimal point. The application designer must decide and keep track of where the decimal is placed. This is referred to in this document as the scale.

This API is available for all platforms. Each function requires a tid as the first function parameter.

Here is a list of functions in this module:

- dbfxp_get
- dbfxp_put
- dbfxp_get_subfield
- dbfxp_put_subfield
- dbfxp_get_subsubfield
- dbfxp_put_subsubfield

# Module Dependencies

This module requires the following modules:

- either the complete single user database suite or the complete multiuser database suite
- fixed-point number API

In the Linux/Unix/QNX platforms, this module is compiled along with the other database modules as part of the script cdbeng.

# Module Header Files

This module depends on the following header files:

- stdhead.h
- dbfxp.h
- dbmess.h
- dbiocode.h
- dblocal.h (single user)
- dbcs.h (client/server)

# Module Functions

## dbfxp_get

    Prototype   :  int dbfxp_get(int tid, int field_no, int sc, struct fxp **r1)
    Parameters  :
          Name  : tid
    Description : tid

          Name  : field_no
    Description : field number

          Name  : sc
    Description : precision or scale of number

          Name  : r1
    Description : returned fixed-point number

    Returns     : dbeng code

This function will obtain the field contents from the tid table, in the field number field. The field contents will be used to create a fixed-point number with the decimal located in the precision or scale of number position (from the right). Function returns a dynamically allocated fxp structure upon success. The fxp structure must be de-allocated by the caller. The field contents must be a number (0-9,-) without any decimal point.

## dbfxp_put

    Prototype   :  int dbfxp_put(int tid, int field_no, int sc, struct fxp *r1)
    Parameters  :
          Name  : tid
    Description : tid

          Name  : field_no
    Description : field number

          Name  : sc
    Description : precision or scale of number

          Name  : r1
    Description : fixed-point number

    Returns     : dbeng code

This function will write a fixed-point number to a database field. The number will be written without a decimal point (if any). The number will have its scale adjusted (position of the decimal point) to the precision or scale of number. The caller must know the number scale. A database write will not take place after writing the field contents.

## dbfxp_get_subfield

    Prototype   :  int dbfxp_get_subfield(int tid, int f, int sf, int sc,
                                          struct fxp **r1)
    Parameters  :
          Name  : tid
    Description : tid

          Name  : f
    Description : field number

          Name  : sf
    Description : subfield number

          Name  : sc
    Description : precision or scale of number

          Name  : r1
    Description : returned fixed-point number

    Returns     : dbeng code

This function will obtain subfield contents from the tid table in the field number and subfield number. The subfield contents will be used to create a fixed-point number (fxp) with the decimal located in the precision or scale of number position (from the right). Function returns a dynamically allocated fxp structure upon success. The fxp structure must be de-allocated by the caller. The subfield contents must be a number (0-9,-) without any decimal point.

## dbfxp_put_subfield

    Prototype   :  int dbfxp_put_subfield(int tid, int f, int sf, int sc,
                                          struct fxp *r1)
    Parameters  :
          Name  : tid
    Description : tid

          Name  : f
    Description : field number

          Name  : sf
    Description : subfield number

          Name  : sc
    Description : precision or scale of number

          Name  : r1
    Description : fixed-point number

    Returns     : dbeng code

This function will write a fixed-point number to a database subfield. The number will be written without a decimal point (if any). The number will have its scale adjusted (position of the decimal point) to the precision or scale of number. The caller must know the number scale. A database write will not take place after writing the subfield contents.

## dbfxp_get_subsubfield

    Prototype   :  int dbfxp_get_subsubfield(int tid, int f, int sf, int ssf,
                                             int sc, struct fxp **r1)
    Parameters  :
          Name  : tid
    Description : tid

          Name  : f
    Description : field number

          Name  : sf
    Description : subfield number

          Name  : ssf
    Description : subsubfield number

          Name  : sc
    Description : precision or scale of number

          Name  : r1
    Description : returned fixed-point number

    Returns     : dbeng code

This function will obtain subsubfield contents from the tid table in the field number, subfield number and subsubfield number. The subsubfield contents will be used to create a fixed-point number (fxp) with the decimal located in the precision or scale of number position (from the right). Function returns a dynamically allocated fxp structure upon success. The fxp structure must be de-allocated by the caller. The subsubfield contents must be a number (0-9,-) without any decimal point.

## dbfxp_put_subsubfield

    Prototype   :  int dbfxp_put_subsubfield(int tid, int f, int sf, int ssf,
                                             int sc, struct fxp *r1)
    Parameters  :
          Name  : tid
    Description : tid

          Name  : f
    Description : field number

          Name  : sf
    Description : subfield number

          Name  : ssf
    Description : subsubfield number

          Name  : sc
    Description : precision or scale of number

          Name  : r1
    Description : fixed-point number

    Returns     : dbeng code

This function will write a fixed-point number to a database subsubfield. The number will be written without a decimal point (if any). The number will have its scale adjusted (position of the decimal point) to the precision or scale of number. The caller must know the number scale. A database write will not take place after writing the subsubfield contents.

Goto Top | Future Lab Home | Contact Webmaster | Feedback

Copyright © 2002-2006 Future Lab, Last Updated Jun 30, 2006