GET_COL_METADATA_FROM_INDEX
Valid For
Extract and Replicat
Description
Use the GET_COL_METADATA_FROM_INDEX
function to retrieve column metadata by specifying the index of the desired column.
Database object names are returned exactly as they are defined in the hosting database, including the letter case.
Syntax
#include "usrdecs.h" short result_code; col_metadata_def column_meta_rec; ERCALLBACK (GET_COL_METADATA_FROM_INDEX, &column_meta_rec, &result_code);
Buffer
typedef struct { short column_index; char *column_name; long max_name_length; short native_data_type; short gg_data_type; short gg_sub_data_type; short is_nullable; short is_part_of_key; short key_column_index; short length; short precision; short scale; short source_or_target; } col_metadata_def;
Input
-
column_index
-
The column index of the column value to be returned.
-
max_name_length
-
The maximum length of the returned column name. Typically, the maximum length is the length of the name buffer. Since the returned name is null-terminated, the maximum length should equal the maximum length of the column name.
-
source_or_target
-
One of the following to indicate whether the source or target record is being compressed.
EXIT_FN_SOURCE_VAL EXIT_FN_TARGET_VAL
Output
-
column_name
-
The column name of the column value to be returned.
-
actual_name_length
-
The actual length of the returned name.
-
value_truncated
-
A flag (
0
or1
) to indicate whether or not the value was truncated. Truncation occurs if the length of the column name plus the null terminator exceeds the maximum buffer length. -
native_data_type
-
The native (to the database) data type of the column. Either
native_data_type
ordd_data_type
is returned, depending on the process, as follows:-
If Extract is making the callback request for a source column,
native_data_type
is returned. If Extract is requesting a mapped target column,gg_data_type
is returned (assuming there is a target definitions file on the system). -
If an Extract data pump is making the callback request for a source column and there is a local database,
native_data_type
is returned. If there is no database,gg_data_type
is returned (assuming there is a source definitions file on the system). If the pump is requesting the target column,gg_data_type
is returned (assuming a target definitions file exists on the system). -
If Replicat is making the callback request for the source column, then
gg_data_type
is returned (assuming a source definitions file exists on the system). If Replicat is requesting the source column andASSUMETARGETDEFS
is being used in the parameter file, thennative_data_type
is returned. If Replicat is requesting the target column,native_data_type
is returned.
-
-
gg_data_type
-
The Oracle GoldenGate data type of the column.
-
gg_sub_data_type
-
The Oracle GoldenGate sub-type of the column.
-
is_nullable
-
Flag indicating whether the column permits a null value (
TRUE
orFALSE
). -
is_part_of_key
-
Flag (
TRUE
orFALSE
) indicating whether the column is part of the key that is being used by Oracle GoldenGate. -
key_column_index
-
Indicates the order of the columns in the index. For example, the following table has two key columns that exist in a different order from the order in which they are declared in the primary key.
CREATE TABLE ABC ( cust_code VARCHAR2(4), name VARCHAR2(30), city VARCHAR2(20), state CHAR(2), PRIMARY KEY (city, cust_code) USING INDEX );
Executing the callback function for each column in the logical column order returns the following:
-
cust_code
returns1
-
name
returns-1
-
city
returns0
-
state
returns-1
If the column is part of the key, the value returned is the order of the column within the key.
If the column is not part of the key, a value of
-1
is returned. -
-
length
-
Returns the length of the column.
-
precision
-
If a numeric data type, returns the precision of the column.
-
scale
-
If a numeric data type, returns the scale.
Return Values
EXIT_FN_RET_INVALID_PARAM EXIT_FN_RET_INVALID_CONTEXT EXIT_FN_RET_EXCEEDED_MAX_LENGTH EXIT_FN_RET_INVALID_COLUMN EXIT_FN_RET_OK
Parent topic: User Exit Functions