Scratchpads on 32-bit and 64-bit operating systems
To make your UDF or method code portable between 32-bit and 64-bit operating systems, you must be cautious when you create and use scratchpads that contain 64-bit values.
It is recommended that you do not declare an explicit length variable
for a scratchpad structure that contains one or more 64-bit values,
such as 64-bit pointers or sqlint64
BIGINT variables.
Following is a sample structure declaration for a scratchpad:
struct sql_scratchpad
{
sqlint32 length;
char data[100];
};
When defining its own structure for the scratchpad,
a routine has two choices: - Redefine the entire scratchpad
sql_scratchpad
, in which case it needs to include an explicit length field. For example:struct sql_spad { sqlint32 length; sqlint32 int_var; sqlint64 bigint_var; }; void SQL_API_FN routine( ..., struct sql_spad* scratchpad, ... ) { /* Use scratchpad */ }
- Redefine just the data portion of the scratchpad
sql_scratchpad
, in which case no length field is needed.struct spaddata { sqlint32 int_var; sqlint64 bigint_var; }; void SQL_API_FN routine( ..., struct sql_scratchpad* spad, ... ) { struct spaddata* scratchpad = (struct spaddata*)spad→data; /* Use scratchpad */ }