Freigeben über


ICommandPersist::SaveCommand

Persists the current command definition.

Syntax

HRESULT SaveCommand(
   DBID    *pCommandID,
   DWORD    dwFlags);

Parameters

  • pCommandID
    [in] The DBID to assign to the persisted command. If this is a null pointer and the command already has a DBID, the provider saves the current version with the same DBID. If this is a null pointer and the command does not already have a DBID, the provider assigns an ID to the command. The ID must be unique.

  • dwFlags
    [in] Options for persisting command definition. The following flags are possible:

    Flag

    Description

    DBCOMMANDPERSISTFLAG_NOSAVE

    You can use DBCOMMANDPERSISTFLAG_NOSAVE to associate or obtain a new DBID for the command without actually persisting the definition.

    DBCOMMANDPERSISTFLAG_PERSISTVIEW

    The command is to be persisted as a view. Views are row-returning objects that do not contain parameters or return values and can generally be used anywhere a base table is used. Views can be enumerated through the DBSCHEMA_VIEWS schema rowset.

    DBCOMMANDPERSISTFLAG_PERSISTPROCEDURE

    The command is to be persisted as a procedure. Procedures may or may not return rows and may or may not contain parameters or return values. Procedures can be enumerated through the DBSCHEMA_PROCEDURES schema rowset.

    DBCOMMANDPERSISTFLAG_DEFAULT

    The behavior of DBCOMMANDPERSISTFLAGS_DEFAULT is provider specific.

    DBCOMMANDPERSISTFLAG_PERSISTVIEW and DBCOMMANDPERSISTFLAG_PERSISTPROCEDURE are mutually exclusive. If neither is specified, the provider persists the command as a default type.

Return Code

  • S_OK
    The command was successfully saved.

  • DB_E_BADCOMMANDID
    The DBID specified in *pCommandID was invalid.

  • DB_E_BADCOMMANDFLAGS
    dwFlags was invalid.

    In dwFlags, both DBCOMMANDPERSISTFLAG_PERSISTVIEW and DBCOMMANDPERSISTFLAG_PERSISTPROCEDURE were specified.

    DBCOMMANDPERSISTFLAG_PERSISTVIEW was specified, and the command could not be persisted as a view.

    DBCOMMANDPERSISTFLAG_PERSISTPROCEDURE was specified, and the command could not be persisted as a procedure.

  • DB_E_DUPLICATEID
    The specified DBID already exists. If the provider supports the use of persisted commands as a source in a new command definition, DBIDs must be unique across persisted commands, procedures, tables, and views.

  • DB_E_ERRORSINCOMMAND
    An invalid command has been set using ICommandText::SetCommandText().

  • DB_E_NOCOMMAND
    SaveCommand() called without setting the command text.

  • E_FAIL
    A provider-specific error occurred.

  • E_INVALIDARG
    Should never be returned by ICommandPersist::SaveCommand(). See Comments below.

Comments

ICommandPersist::SaveCommand saves the current command definition. It does not persist any open rowsets, current property values, or specified parameter information.

E_INVALIDARG is no longer returned. It is illegal to pass in a null pCommandID.