Scalable Database Server, HiRDB Version 8 UAP Development Guide

[Contents][Index][Back][Next]

Appendix G.3 Function for conversion to a DECIMAL signed normalized number

The function for conversion to a DECIMAL signed normalized number sets the sign for DECIMAL data to either X'C' or X'D' (for a value of 0, the sign is X'C'). Because this function lets you obtain the normalized sign without having to store DECIMAL data in a database, you can use it for the following purposes:

Prerequisites for using the function for conversion to a DECIMAL signed normalized number
The prerequisites are the same as those for the hash function for table partitioning. For details, see G.1(1) Prerequisites for using the hash function for table partitioning.

Prerequisites for creating and executing a UAP using the function for conversion to a DECIMAL signed normalized number
The prerequisites are the same as those for the hash function for table partitioning. For details, see G.1(2) Creating and executing UAPs that use the hash function for table partitioning.
Organization of this subsection
(1) Details about the function for conversion to a DECIMAL signed normalized number

(1) Details about the function for conversion to a DECIMAL signed normalized number

(a) Specification configuration

For details about the specification configuration, see G.1(3)(b) Specification configuration.

(b) Function for conversion to a DECIMAL signed normalized number (p_rdb_dec_sign_norm)

Function
The function normalizes the sign of DECIMAL data indicated by srcp as follows:
Before normalization After normalization
X'A' X'C'
X'B' X'D'*
X'C' X'C'
X'D' X'D'*
X'E' X'C'
X'F' X'C'
X'0' to X'9' Error

* If the absolute value of data is 0, the sign part is set to X'C'.


Header file
#include<pdauxcnv.h>
This header file is required to use the function for conversion to a DECIMAL signed normalized number.

Format
int p_rdb_dec_sign_norm(unsigned char   *srcp,
                        short           srcl,
                        unsigned char   *destp);

Arguments
srcp (input)
Specifies the start address of the DECIMAL data to be normalized.
srcl (input)
Specifies the length code of the DECIMAL data indicated by the srcp argument. Specifiable data length codes are as follows:
Data type Data length code
INTERVAL YEAR TO DAY 8 [Figure] 256
INTERVAL HOUR TO SECOND 6 [Figure] 256
DECIMAL[(p[,q])] p [Figure] 256 + q
(If p is omitted, 15 is assumed; if q is omitted, 0 is assumed.)
destp (output)
Sets the normalized DECIMAL data. Allocate this area indicated by destp on the side that calls the function for conversion to a DECIMAL signed normalized number.

Return values
data type: int
p_rdb_RC_RTRN(0)
Normal termination.
p_rdb_RC_ERRDFRM(-12)
Invalid sign part for data.

Notes
  1. The function does not check anything for error other than the sign part of DECIMAL data. Operation is not guaranteed if DECIMAL data is invalid or the data length code specified by the srcl argument contradicts the DECIMAL data.
  2. Operation is guaranteed if the data input area is the same as the data output area, or if the output area is located before the input area and the latter half of the output area overlaps the first half of the input area.