Resources

ISASDataSetInfo Custom Interface

The ISASDataSetInfo interface provides a way to return data set metadata that does not directly map to OLE DB constructs. There are two methods:

Method Description
GetDataSetInfo Returns file metadata that is specific to SAS.
GetRecordCounts Returns information about the number of records that are associated with a file.


The GetDataSetInfo Method

The GetDataSetInfo method returns SAS file metadata that is not supported by predefined OLE DB constructs.

HRESULT GetDataSetInfo(
        SASDATASETINFO **       ppDataSetInfo,
        OLECHAR **              ppStringsBuffer );

Parameters

ppDataSetInfo
[out]
A pointer to the memory where a SASDATASETINFO structure will be returned. If *ppDataSetInfo is NULL when GetDataSetInfo is executed, then the provider allocates memory for this structure and returns the address to the memory location specified by this pointer. When the memory is no longer needed, you use IMalloc::Free to free the memory. As an alternative to depending on the provider to allocate memory for the SASDATASETINFO structure, the consumer can allocate memory for this structure and pass in the address as *ppDataSetInfo.
ppStringsBuffer
[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.

Return Codes

S_OK
indicates that the method succeeded.
E_FAIL
indicates that a provider-specific error occurred.
E_INVALIDARG
indicates that ppDataSetInfo or ppStringsBuffer was a null pointer.
E_OUTOFMEMORY
indicates that the provider was unable to allocate sufficient memory for the data set information structures.

Usage Notes

This method makes no logical change to the state of the object.

Under some circumstances, the actual values for the lLogicalRecordCount and lPhysicalRecordCount members of the SASDATASETINFO structure will not be immediately available. This is the case when the underlying data set is something other than a physical SAS data file (for example, a SAS data view, a WHERE clause, or a SAS/ACCESS file). In those cases, the members return a -1. To determine the actual values, call ISASDataSetInfo::GetRecordCounts.

The SASDATASETINFO Structure

The GetDataSetInfo method returns file metadata in a SASDATASETINFO structure.

typedef struct tagSASDATASETINFO {
        LONG lLogicalRecordCount;
        LONG lPhysicalRecordCount;
        LONG lRecordLength;
        DATE dDateCreated;
        DATE dDateModified;
        LPOLESTR pwszLabel;
        LPOLESTR pwszCompressionRoutine;
        BOOL fIsIndexed;
} SASDATASETINFO;

The elements (members) of the SASDATASETINFO structure are described in the following table:

Element Description
lLogicalRecordCount The number of logical records in the data set. This is the number of records that are returned if the caller sequentially reads through the entire data set. If this value is not immediately available, a value of -1 is returned in this field. This is the case when the data set is not a physical file (for example, a SAS data view or a WHERE clause). In such cases, you can use the GetRecordCounts method to computationally determine this value.
lPhysicalRecordCount The number of physical records in the data set. This number can be greater than the number of logical records and can indicate the magnitude of the physical file size. If this value is not immediately available, a value of -1 is returned in this field; this is the case when the data set is not a physical SAS file (for example, a SAS data view or a SAS/ACCESS table). In such cases, you can use the GetRecordCounts method to computationally determine this value.
lRecordLengthThe physical record length in bytes.
dDateCreatedThe date that the data set was created.
dDateModifiedThe date that the data set was last modified.
pwszLabelThe data set label. NULL if none is set.
pwszCompressionRoutineThe name of the compression algorithm used. NO if none is set.
fIsIndexedTRUE if an index exists on the data set.


The GetRecordCounts Method

The GetRecordCounts method forces a count of the number of logical and physical records in a data set. Call this method only when GetDataSetInfo returns -1 in the SASDATASETINFO lLogicalRecordCount and lPhysicalRecordCount fields.

HRESULT GetRecordCounts(
        LONG *          plLogicalRecordCount,
        LONG *          plPhysicalRecordCount );

Parameters

plLogicalRecordCount
[out]
A pointer to the memory where the logical number of records in the data set will be returned. This number indicates how many rows are returned if every row is read once. If this value exceeds a LONG, a value of -1 is returned in this field.
plPhysicalRecordCount
[out]
A pointer to the memory where the physical number of records in the data set will be returned. This number might be greater than the number of logical records. It indicates how many records are allocated in the data set. This value multiplied by the length of an individual record (lRecordLength returned by GetDataSetInfo) approximates the magnitude of the physical size of the data set. If this value exceeds a LONG, a value of -1 is returned in this field.

Return Codes

S_OK
indicates that the method succeeded.
E_FAIL
indicates that a provider-specific error occurred.
E_INVALIDARG
indicates that plLogicalRecordCount or plPhysicalRecordCount was a null pointer.

Usage Notes

This method determines record counts by forcing a sequential read of the data set. If the underlying data set is large, the read can take a significant amount of time.

CAUTION:
Some data sets contain millions of records. Executing this method on a very large data set may incur a significant performance cost.


See Also:

About Custom Interfaces
ISASDatasetInfo90 Custom Interface
ISASColumnsInfo Custom Interface