Udostępnij za pośrednictwem


IDBSchemaRowset::GetSchemas

Returns a list of schema rowsets accessible by IDBSchemaRowset::GetRowset.

Syntax

HRESULT GetSchemas (
   ULONG    *pcSchemas,
   GUID    **prgSchemas,
   ULONG   **prgRestrictionSupport);

Parameters

  • pcSchemas
    [out] A pointer to memory in which to return the number of GUIDs in *prgSchemas. The returned count of schema GUIDs is always at least 3, because all providers must support the TABLES, COLUMNS, and PROVIDER_TYPES schema rowsets. If an error occurs, *pcSchemas is set to 0.

  • prgSchemas
    [out] A pointer to memory in which to return an array of GUIDs identifying supported schema rowsets. For more information, see IDBSchemaRowset. The session allocates memory for the GUIDs and returns the address to this memory. The consumer releases this memory with IMalloc::Free when it no longer needs the list of GUIDs. If an error occurs, *prgSchemas is set to a null pointer.

  • prgRestrictionSupport
    [out] A pointer to memory in which to return an array of ULONGs, one element for each supported schema rowset, describing the restriction columns supported for that schema rowset. For a given schema rowset, the array element corresponding to the schema rowset will have the appropriate bit set if the provider implements a restriction on that column. Bits that do not correspond to currently defined restriction columns should not be set.

    The value of prgRestrictionSupport reflects on which of the columns listed as restriction columns the provider supports restrictions. The table of GUID restriction columns earlier in the overview of IDBSchemaRowset indicates the array of possible restriction columns to which this bitmask applies.

    For example, the GUID table at the beginning of this reference entry lists three restriction columns for the schema DBSCHEMA_ASSERTIONS. The array element corresponding to this schema will represent the CONSTRAINT_CATALOG column in bit 0, the CONSTRAINT_SCHEMA column in bit 1, and the CONSTRAINT_NAME column in bit 2. The following code shows how the consumer might determine whether a restriction on the CONSTRAINT_CATALOG column is supported on the ASSERTIONS schema rowset.

    ULONG     cSchemas;
    GUID *    rgSchemas;
    ULONG *   rgRestSupport;
    
    pIDBSchemaRowset->GetSchemas(&cSchemas, &rgSchemas, &rgRestSupport);
    
    // Assume rgSchemas[0] is the GUID DBSCHEMA_ASSERTIONS. The following
    // code checks whether the restriction on the CONSTRAINT_CATALOG
    // column is supported.
    if (rgRestSupport[0] & 0x1) {
       // Restriction is supported.
    } else {
       // Restriction is not supported.
    }
    

    The session allocates memory for the restrictions and returns the address to this memory. The consumer releases this memory with IMalloc::Free when it no longer needs the list of restrictions. If an error occurs, *prgRestrictionSupport is set to a null pointer.

    If prgRestrictionSupport is a null pointer, the session does not allocate any memory or return any restrictions.

Return Code

  • S_OK
    The method succeeded.

  • E_FAIL
    A provider-specific error occurred.

  • E_INVALIDARG
    pcSchemas or prgSchemas was a null pointer.

  • E_OUTOFMEMORY
    The provider was unable to allocate sufficient memory in which to return the array of schema GUIDs or restriction support information.

See Also

Reference

IDBSchemaRowset::GetRowset