The single ISASColumnsInfo
interface method is called GetColumnInfo. GetColumnInfo supplements
the standard OLE DB IColumnsInfo interface methods. It returns SAS
column metadata that is not supported by the GetColumnInfo method
in the standard IColumnsInfo interface.
HRESULT GetColumnInfo(
DBORDINAL * pcColumns,
SASCOLUMNINFO ** prgInfo,
OLECHAR ** ppStringsBuffer );
GetColumnInfo
returns a fixed set of column metadata in an array of SASCOLUMNINFO
structures, one structure per column. The structures appear in the
same order in which the columns appear in the rowset (column ordinal
order). This order is determined by the order in which the columns
are returned from IColumnsInfo::GetColumnInfo. Bookmark columns are
never included in the output of this method. Here is the definition
of the SASCOLUMNINFO structure:
typedef struct tagSASCOLUMNINFO {
LPOLESTR pwszColDesc;
LPOLESTR pwszFmtName;
LPOLESTR pwszIFmtName;
ULONG iOrdinal;
SHORT iFmtLength;
SHORT iFmtDecimal;
SHORT iIFmtLength;
SHORT iIFmtDecimal;
SHORT iSortInfo;
BOOL fIndexed;
} SASCOLUMNINFO;
The elements (members)
of the SASCOLUMNINFO structure are described in the following table.
Elements (Members) of the SASCOLUMNINFO Structure
|
|
|
Pointer to the column
description (the SAS variable label). If no label is associated with
this column, this member is NULL.
|
|
Pointer to the persisted
format name. If no format is associated with this column, this member
is NULL.
|
|
Pointer to the persisted
informat name. If no informat is associated with this column, this
member is NULL.
|
|
The ordinal of the column.
This value corresponds to the SAS variable number.
|
|
The width of the formatted
data. This member is valid only when pwszFmtName is not NULL.
|
|
The decimal width of
the format data. This member is valid only when pwszFmtDecimal is
not NULL.
|
|
The width of the informatted
data. This member is valid only when pwszIFmtName is not NULL.
|
|
The decimal width of
the informatted data. This member is valid only when pwszIFmtName
is not NULL.
|
|
A signed short value
that indicates the column's position in any applied sorting hierarchy.
Positive values indicate ascending sort order, and negative values
indicate descending sort order. The absolute value of the signed short
value describes the position of the variable in the sorting hierarchy.
Zero (0) indicates that the column does not participate in sorting.
|
|
True when this column
is an indexed column.
|
1For the SAS/SHARE, Local,
and Base SAS providers, this member is valid. For the SAS IOM provider,
this member is not valid. That is, it always contains 0 whether the
column participates in the sorting.
|
Here are the parameters
for the GetColumnInfo method:
[out] A pointer to
the memory where the number of columns in the rowset will be returned.
This number will not include the bookmark column even if there is
one. If this method terminates as the result of an error, *pcColumns
is set to 0.
[out] A pointer to
the memory where an array of SASCOLUMNINFO structures will be returned.
One structure is returned for each column that is in the rowset. The
provider allocates memory for the structures and returns the address
of the memory location. When the memory is no longer needed by the
column information, you use IMalloc::Free to release the memory.
If *pcColumns is 0 when it is calculated or this method terminates
as the result of an error, the provider does not allocate any memory
and ensures that *prgInfo is a NULL pointer.
[out] A pointer to
the memory where column string names will be returned. All of the
column string values (names) are stored within a single allocation
block. If no returned columns have string names or if this method
terminates as the result of an error, *ppStringsBuffer will be set
to NULL. If one or more columns has a string name, then the specified
memory location contains the string values (names) for the columns.
When the names are no longer needed, you use IMalloc::Free to release
the memory. If *pcColumns is 0 when calculated or this method terminates
as the result of an error, the provider does not allocate any memory
and ensures that *ppStringsBuffer is a NULL pointer. Each string value
stored in this buffer is terminated by a null-termination character.
Here are the return
codes for the GetColumnInfo method:
indicates that the
method succeeded.
indicates that a provider-specific
error occurred.
indicates that pcColumns,
prgInfo, or ppStringsBuffer was a null pointer.
indicates that the
provider was unable to allocate sufficient memory for the column information
structures.
Tip
The GetColumnInfo method provides
a quick alternative to the GetColumnsRowset method. While the GetColumnsRowset
method returns all available column metadata, it does so in a rowset.
To get the metadata, the consumer must create the column metadata
rowset, create one or more accessors, get each row in the rowset,
and get the data from the rowset.