'Usage Dim command As TdCommand TdCommandBuilder.DeriveParameters(command)
public: static void DeriveParameters( TdCommand^ command )
Parameters
- command
- The TdCommand object to derive parameters.
'Usage Dim command As TdCommand TdCommandBuilder.DeriveParameters(command)
public: static void DeriveParameters( TdCommand^ command )
Exception | Description |
---|---|
System.InvalidOperationException | CommandType property of the command object is not set to Data.CommandType.StoredProcedure or Data.CommandType.Text. |
TdException | The Advanced SQL Engine generated an error. |
The Data Provider will send a HELP PROCEDURE statement to retrieve the stored procedure parameter information from the Advanced SQL Engine when TdCommand.CommandType is set to StoredProcedure and TdCommand.CommandText is a Stored Procedure name. The information is used to populate the command. The parameters collection is populated with TdParameter objects, one for each stored procedure parameter. TdParameter Direction, IsNullable, ParameterName, Precision, Scale, Size and TdType properties will be set.
When the TdParameter.TdType property is set as a TdType.AnyType, the Precision, Scale and Size are not available. The TdType.AnyType indicates that the actual TdType and value will be supplied during execution of the stored procedure, enabling selection of a dynamic TdType to the stored procedure.
When OUT parameter types are defined as TdType.AnyType, the parameter information ordinarily supplied by the HELP PROCEDURE statement must be supplied in the parameter collection by the program. TdParameter.SecondaryTdType must be defined to indicate the actual TdType supplied during execution of the stored procedure. The Precision, Scale, Size and Value must also be supplied additionally if applicable.
The Data Provider will Prepare the command when TdCommand.CommandType is set to Text. The TdCommand.Parameters properties is populated from the Metadata. CommandType.Text must not be used with CALL statements.
REPLACE PROCEDURE xspAnyType02(IN param2 INTEGER, OUT result2 TD_ANYTYPE)
public static void DeriveTdAnyTypeParameters(TdCommand myCommand) { myCommand.CommandType = CommandType.StoredProcedure; TdCommandBuilder.DeriveParameters(myCommand); Debug.Assert(2 == myCommand.Parameters.Count); Debug.Assert(ParameterDirection.Input == myCommand.Parameters[0].Direction); Debug.Assert(TdType.Integer == myCommand.Parameters[0].TdType); Debug.Assert(ParameterDirection.Output == myCommand.Parameters[1].Direction); Debug.Assert(TdType.AnyType == myCommand.Parameters[1].TdType); myCommand.Parameters[0].Value = 20; myCommand.Parameters[1].SecondaryTdType = TdType.VarChar; myCommand.Parameters[1].Size = 20; myCommand.ExecuteReader(); Console.WriteLine("Result is {0}", myCommand.Parameters[1].Value); }
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019