使用 SQLGetData 检索输出参数Retrieving Output Parameters Using SQLGetData

在 ODBC 3.8 之前,应用程序只能检索带有绑定输出缓冲区的查询的输出参数。Before ODBC 3.8, an application could only retrieve the output parameters of a query with a bound output buffer. 但是,如果参数值的大小非常大,则很难分配一个非常大的缓冲区 (例如,) 大的图像。However, it is difficult to allocate a very large buffer when the size of the parameter value is very large (for example, a large image). ODBC 3.8 引入了一种新方法来检索部分中的输出参数。ODBC 3.8 introduces a new way to retrieve output parameters in parts. 现在,应用程序可以多次调用带有小缓冲区的 SQLGetData ,以检索大型参数值。An application can now call SQLGetData with a small buffer multiple times to retrieve a large parameter value. 这类似于检索大列数据。This is similar to retrieving large column data.

若要绑定要在部分中检索的输出参数或输入/输出参数,请调用 SQLBindParameter ,并将 InputOutputType 参数设置为 SQL_PARAM_OUTPUT_STREAM 或 SQL_PARAM_INPUT_OUTPUT_STREAM。To bind an output parameter or input/output parameter to be retrieved in parts, call SQLBindParameter with the InputOutputType argument set to SQL_PARAM_OUTPUT_STREAM or SQL_PARAM_INPUT_OUTPUT_STREAM. 使用 SQL_PARAM_INPUT_OUTPUT_STREAM,应用程序可以使用 SQLPutData 将数据输入到参数中,然后使用 SQLGetData 检索 OUTPUT 参数。With SQL_PARAM_INPUT_OUTPUT_STREAM, an application can use SQLPutData to input data into the parameter, and then use SQLGetData to retrieve the output parameter. 输入数据必须位于执行时 (DAE) 窗体中 ,而不是将 其绑定到预分配的缓冲区。The input data must be in the data-at-execution (DAE) form, using SQLPutData instead of binding it to a preallocated buffer.

此功能可由 ODBC 3.8 应用程序或重新编译的 ODBC 1.x 和 ODBC 2.x 应用程序使用,这些应用程序必须具有支持使用 SQLGetData 和 Odbc 3.8 驱动程序管理器检索输出参数的 ODBC 3.8 驱动程序。This feature can be used by ODBC 3.8 applications or recompiled ODBC 3.x and ODBC 2.x applications, and these applications must have an ODBC 3.8 driver that supports retrieving output parameters using SQLGetData and ODBC 3.8 Driver Manager. 有关如何启用较旧的应用程序以使用新的 ODBC 功能的信息,请参阅 兼容性矩阵For information about how to enable an older application to use new ODBC features, see Compatibility Matrix.

用法示例Usage Example

例如,请考虑执行存储过程 {CALL sp_f (?,? ) },其中两个参数均绑定为 SQL_PARAM_OUTPUT_STREAM,存储过程返回的结果集 (在本主题后面的部分中,你将找到更复杂的方案) :For example, consider executing a stored procedure, {CALL sp_f(?,?)}, where both parameters are bound as SQL_PARAM_OUTPUT_STREAM, and the stored procedure returns no result set (later in this topic you will find a more complex scenario):

  1. 对于每个参数,请调用 SQLBindParameter ,将 InputOutputType 设置为 SQL_PARAM_OUTPUT_STREAM,并将 ParameterValuePtr 设置为标记,如参数号、指向数据的指针或指向应用程序用于绑定输入参数的结构的指针。For each parameter, call SQLBindParameter with InputOutputType set to SQL_PARAM_OUTPUT_STREAM and ParameterValuePtr set to a token, such as a parameter number, a pointer to data, or a pointer to a structure that the application uses to bind input parameters. 此示例将使用参数序号作为标记。This example will use the parameter ordinal as the token.

  2. 执行具有 SQLExecDirectSQLExecute的查询。Execute the query with SQLExecDirect or SQLExecute. 将返回 SQL_PARAM_DATA_AVAILABLE,指示有可用于检索的流式处理输出参数。SQL_PARAM_DATA_AVAILABLE will be returned, indicating that there are streamed output parameters available for retrieval.

  3. 调用 SQLParamData 可获取可用于检索的参数。Call SQLParamData to get the parameter that is available for retrieval. SQLParamData 将返回 SQL_PARAM_DATA_AVAILABLE,其中包含第一个可用参数的标记,该参数在 SQLBindParameter 中设置 (步骤 1) 。SQLParamData will return SQL_PARAM_DATA_AVAILABLE with the token of the first available parameter, which is set in SQLBindParameter (step 1). ValuePtrPtr 指向的缓冲区中返回该令牌。The token is returned in the buffer that the ValuePtrPtr points to.

  4. 使用参数_Or 调用SQLGetData _ Param_Num设置为参数序号,以检索第一个可用参数的数据。Call SQLGetData with the argument Col_or_Param_Num set to the parameter ordinal to retrieve the data of the first available parameter. 如果 SQLGetData 返回 SQL_SUCCESS_WITH_INFO 和 SQLState 01004 (数据截断) ,并且该类型在客户端和服务器上都是可变的,则从第一个可用参数检索更多数据。If SQLGetData returns SQL_SUCCESS_WITH_INFO and SQLState 01004 (data truncated), and the type is variable length on both the client and server, there is more data to retrieve from the first available parameter. 你可以继续调用 SQLGetData ,直到它返回不同 SQLStateSQL_SUCCESS 或 SQL_SUCCESS_WITH_INFO。You can continue to call SQLGetData until it returns SQL_SUCCESS or SQL_SUCCESS_WITH_INFO with a different SQLState.

  5. 重复步骤3和步骤4以检索当前参数。Repeat step 3 and step 4 to retrieve the current parameter.

  6. 再次调用 SQLParamDataCall SQLParamData again. 如果它返回除 SQL_PARAM_DATA_AVAILABLE 之外的任何内容,则没有更多要检索的流式处理参数数据,返回代码将是执行的下一条语句的返回代码。If it returns anything except SQL_PARAM_DATA_AVAILABLE, there is no more streamed parameter data to retrieve, and the return code will be the return code of the next statement that is executed.

  7. 调用 SQLMoreResults 以处理下一组参数,直到其返回 SQL_NO_DATA。Call SQLMoreResults to process the next set of parameters until it returns SQL_NO_DATA. 如果 SQL_ATTR_PARAMSET_SIZE 的语句属性设置为1,则SQLMoreResults将在此示例中返回 SQL_NO_DATA。SQLMoreResults will return SQL_NO_DATA in this example if the statement attribute SQL_ATTR_PARAMSET_SIZE was set to 1. 否则, SQLMoreResults 将返回 SQL_PARAM_DATA_AVAILABLE,以指示有可用于要检索的下一组参数的流式处理输出参数。Otherwise, SQLMoreResults will return SQL_PARAM_DATA_AVAILABLE to indicate that there are streamed output parameters available for the next set of parameters to retrieve.

与 DAE 输入参数类似, SQLBindParameter (第) 1 步中的参数ParameterValuePtr中使用的令牌可以是指向应用程序数据结构的指针,该结构包含参数的序号和应用程序特定的信息(如有必要)。Similar to a DAE input parameter, the token used in the argument ParameterValuePtr in SQLBindParameter (step 1) can be a pointer that points to an application data structure, which contains the ordinal of the parameter and more application-specific information, if necessary.

返回的流式处理输出参数或输入/输出参数的顺序是特定于驱动程序的,可能并不总是与查询中指定的顺序相同。The order of the returned streamed output or input/output parameters is driver specific and might not always be the same as the order specified in the query.

如果应用程序在步骤4中未调用 SQLGetData ,则会丢弃参数值。If the application does not call SQLGetData in step 4, the parameter value is discarded. 同样,如果应用程序在SQLGetData读取所有参数值之前调用SQLParamData ,则会丢弃该值的其余部分,应用程序可以处理下一个参数。Similarly, if the application calls SQLParamData before all of a parameter value has been read by SQLGetData, the remainder of the value is discarded, and the application can process the next parameter.

如果应用程序在处理所有流式处理输出参数之前调用 SQLMoreResults (SQLParamData 仍返回 SQL_PARAM_DATA_AVAILABLE) ,则放弃所有剩余的参数。If the application calls SQLMoreResults before all streamed output parameters are processed (SQLParamData does still return SQL_PARAM_DATA_AVAILABLE), all remaining parameters are discarded. 同样,如果应用程序在SQLGetData读取所有参数值之前调用SQLMoreResults ,则会丢弃该值的其余部分和所有剩余参数,应用程序可以继续处理下一个参数集。Similarly, if the application calls SQLMoreResults before all of a parameter value has been read by SQLGetData, the remainder of the value and all remaining parameters are discarded, and the application can continue to process the next parameter set.

请注意,应用程序可以在 SQLBindParameterSQLGetData中指定 C 数据类型。Note that an application can specify the C data type in both SQLBindParameter and SQLGetData. SQLGetData 指定的 c 数据类型将重写 SQLBindParameter中指定的 c 数据类型,除非在 SQLGetData 中指定的 c 数据类型 SQL_APD_TYPE。The C data type specified with SQLGetData overrides the C data type specified in SQLBindParameter, unless the C data type specified in SQLGetData is SQL_APD_TYPE.

尽管输出参数的数据类型为 BLOB 类型时,流式处理输出参数更为有用,但也可以将此功能与任何数据类型一起使用。Although a streamed output parameter is more useful when the data type of the output parameter is of type BLOB, this functionality can also be used with any data type. 流式处理输出参数支持的数据类型是在驱动程序中指定的。The data types supported by streamed output parameters are specified in the driver.

如果有 SQL_PARAM_INPUT_OUTPUT_STREAM 参数要处理,则 SQLExecuteSQLExecDirect 将首先返回 SQL_NEED_DATA。If there are SQL_PARAM_INPUT_OUTPUT_STREAM parameters to be processed, SQLExecute or SQLExecDirect will return SQL_NEED_DATA first. 应用程序可以调用 SQLParamDataSQLPUTDATA 来发送 DAE 参数数据。An application can call SQLParamData and SQLPutData to send DAE parameter data. 处理所有 DAE 输入参数时, SQLParamData 将返回 SQL_PARAM_DATA_AVAILABLE 以指示流式输出参数可用。When all DAE input parameters are processed, SQLParamData returns SQL_PARAM_DATA_AVAILABLE to indicate streamed output parameters are available.

当存在要处理的流式处理输出参数和绑定输出参数时,驱动程序将确定处理输出参数的顺序。When there are streamed output parameters and bound output parameters to be processed, the driver determines the order for processing output parameters. 因此,如果将输出参数绑定到缓冲区 (SQLBindParameter 参数 InputOutputType 设置为 SQL_PARAM_INPUT_OUTPUT 或 SQL_PARAM_OUTPUT) ,则在 SQLParamData 返回 SQL_SUCCESS 或 SQL_SUCCESS_WITH_INFO 之前,可能不会填充缓冲区。So, if an output parameter is bound to a buffer (the SQLBindParameter parameter InputOutputType is set to SQL_PARAM_INPUT_OUTPUT or SQL_PARAM_OUTPUT), the buffer may not be populated until SQLParamData returns SQL_SUCCESS or SQL_SUCCESS_WITH_INFO. 仅当 SQLParamData 返回了所有流式处理输出参数之后 SQL_SUCCESS 或 SQL_SUCCESS_WITH_INFO 之后,应用程序才应读取绑定缓冲区。An application should read a bound buffer only after SQLParamData returns SQL_SUCCESS or SQL_SUCCESS_WITH_INFO that is after all streamed output parameters are processed.

除流式处理输出参数外,数据源还可以返回警告和结果集。The data source can return a warning and result set, in addition to the streamed output parameter. 通常,通过调用 SQLMoreResults,与流式处理的输出参数分别处理警告和结果集。In general, warnings and result sets are processed separately from a streamed output parameter by calling SQLMoreResults. 在处理流式处理输出参数之前处理警告和结果集。Process warnings and the result set before processing the streamed output parameter.

下表描述了发送到服务器的单个命令的不同方案,以及应用程序的工作原理。The following table describes different scenarios of a single command sent to the server, and how the application should work.

方案Scenario 从 SQLExecute 或 SQLExecDirect 返回值Return value from SQLExecute or SQLExecDirect 下一步操作What to do next
数据仅包含流式输出参数Data only includes streamed output parameters SQL_PARAM_DATA_AVAILABLESQL_PARAM_DATA_AVAILABLE 使用 SQLParamDataSQLGetData 检索流式处理的输出参数。Use SQLParamData and SQLGetData to retrieve streamed output parameters.
数据包括结果集和流式输出参数Data includes a result set and streamed output parameters SQL_SUCCESSSQL_SUCCESS 检索包含 SQLBindColSQLGetData的结果集。Retrieve the result set with SQLBindCol and SQLGetData.

调用 SQLMoreResults 开始处理流式输出参数。Call SQLMoreResults to start processing streamed output parameters. 它应返回 SQL_PARAM_DATA_AVAILABLE。It should return SQL_PARAM_DATA_AVAILABLE.

使用 SQLParamDataSQLGetData 检索流式处理的输出参数。Use SQLParamData and SQLGetData to retrieve streamed output parameters.
数据包括警告消息和流式输出参数Data includes a warning message and streamed output parameters SQL_SUCCESS_WITH_INFOSQL_SUCCESS_WITH_INFO 使用 SQLGetDiagRecSQLGetDiagField 处理警告消息。Use SQLGetDiagRec and SQLGetDiagField to process warning messages.

调用 SQLMoreResults 开始处理流式输出参数。Call SQLMoreResults to start processing streamed output parameters. 它应返回 SQL_PARAM_DATA_AVAILABLE。It should return SQL_PARAM_DATA_AVAILABLE.

使用 SQLParamDataSQLGetData 检索流式处理的输出参数。Use SQLParamData and SQLGetData to retrieve streamed output parameters.
数据包括警告消息、结果集和流式输出参数Data includes a warning message, result set and streamed output parameters SQL_SUCCESS_WITH_INFOSQL_SUCCESS_WITH_INFO 使用 SQLGetDiagRecSQLGetDiagField 处理警告消息。Use SQLGetDiagRec and SQLGetDiagField to process warning messages. 然后调用 SQLMoreResults ,开始处理结果集。Then call SQLMoreResults to start processing the result set.

使用 SQLBindColSQLGetData检索结果集。Retrieve a result set with SQLBindCol and SQLGetData.

调用 SQLMoreResults 开始处理流式输出参数。Call SQLMoreResults to start processing streamed output parameters. SQLMoreResults 应返回 SQL_PARAM_DATA_AVAILABLE。SQLMoreResults should return SQL_PARAM_DATA_AVAILABLE.

使用 SQLParamDataSQLGetData 检索流式处理的输出参数。Use SQLParamData and SQLGetData to retrieve streamed output parameters.
使用 DAE 输入参数查询,例如 (DAE) 参数传输的输入/输出Query with DAE input parameters, for example, a streamed input/output (DAE) parameter SQL NEED_DATASQL NEED_DATA 调用 SQLParamDataSQLPUTDATA 以发送 DAE 输入参数数据。Call SQLParamData and SQLPutData to send DAE input parameter data.

处理完所有 DAE 输入参数后, SQLParamData 可以返回 SQLExecuteSQLExecDirect 可以返回的任何返回代码。After all DAE input parameters are processed, SQLParamData can return any return code that SQLExecute and SQLExecDirect can return. 然后,可以应用此表中的事例。The cases in this table can then be applied.

如果 SQL_PARAM_DATA_AVAILABLE 返回代码,则流输出参数可用。If the return code is SQL_PARAM_DATA_AVAILABLE, streamed output parameters are available. 应用程序必须再次调用 SQLParamData 来检索流式处理输出参数的令牌,如此表的第一行中所述。An application must call SQLParamData again to retrieve the token for the streamed output parameter, as described in the first row of this table.

如果返回代码为 SQL_SUCCESS,则可能是要处理的结果集或处理已完成。If the return code is SQL_SUCCESS, either there is a result set to process or the processing is complete.

如果 SQL_SUCCESS_WITH_INFO 返回代码,则会发出警告消息。If the return code is SQL_SUCCESS_WITH_INFO, there are warning messages to process.

SQLExecuteSQLExecDirectSQLMoreResults 返回 SQL_PARAM_DATA_AVAILABLE 后,如果应用程序调用的函数不在以下列表中,则会导致函数序列错误:After SQLExecute, SQLExecDirect, or SQLMoreResults returns SQL_PARAM_DATA_AVAILABLE, a function sequence error will result if an application calls a function that is not in the following list:

  • SQLAllocHandle / SQLAllocHandleStdSQLAllocHandle / SQLAllocHandleStd

  • SQLDataSources / SQLDriversSQLDataSources / SQLDrivers

  • SQLGetInfo / SQLGetFunctionsSQLGetInfo / SQLGetFunctions

  • SQLGetConnectAttr / SQLGetEnvAttr / SQLGetDescField / SQLGetDescRecSQLGetConnectAttr / SQLGetEnvAttr / SQLGetDescField / SQLGetDescRec

  • SQLNumParamsSQLNumParams

  • SQLDescribeParamSQLDescribeParam

  • SQLNativeSqlSQLNativeSql

  • SQLParamDataSQLParamData

  • SQLMoreResultsSQLMoreResults

  • SQLGetDiagField / SQLGetDiagRecSQLGetDiagField / SQLGetDiagRec

  • SQLCancelSQLCancel

  • 带有语句句柄) 的SQLCancelHandle (SQLCancelHandle (with statement handle)

  • 带有 Option = SQL_CLOSE、SQL_DROP 或 SQL_UNBIND 的SQLFreeStmt () SQLFreeStmt (with Option = SQL_CLOSE, SQL_DROP or SQL_UNBIND)

  • SQLCloseCursorSQLCloseCursor

  • SQLDisconnectSQLDisconnect

  • 带有 HandleType = SQL_HANDLE_STMT 的SQLFreeHandle () SQLFreeHandle (with HandleType = SQL_HANDLE_STMT)

  • SQLGetStmtAttrSQLGetStmtAttr

应用程序仍可使用 SQLSetDescFieldSQLSetDescRec 来设置绑定信息。Applications can still use SQLSetDescField or SQLSetDescRec to set the binding information. 字段映射不会更改。Field mapping will not be changed. 但是,描述符中的字段可能返回新值。However, fields inside the descriptor might return new values. 例如,SQL_DESC_PARAMETER_TYPE 可能返回 SQL_PARAM_INPUT_OUTPUT_STREAM 或 SQL_PARAM_OUTPUT_STREAM。For example, SQL_DESC_PARAMETER_TYPE might return SQL_PARAM_INPUT_OUTPUT_STREAM or SQL_PARAM_OUTPUT_STREAM.

使用方案:从结果集检索部件中的图像Usage Scenario: Retrieve an Image in Parts from a Result Set

当存储过程返回的结果集包含一个与图像有关的元数据,并且该图像在大的输出参数中返回时,可以使用SQLGetData在部分中获取数据。SQLGetData can be used to get data in parts when a stored procedure returns a result set that contains one row of metadata about an image and the image is returned in a large output parameter.

// CREATE PROCEDURE SP_TestOutputPara  
//      @ID_of_picture   as int,  
//      @Picture         as varbinary(max) out  
// AS  
//     output the image data through streamed output parameter  
// GO  
BOOL displayPicture(SQLUINTEGER idOfPicture, SQLHSTMT hstmt) {  
   SQLLEN      lengthOfPicture;    // The actual length of the picture.  
   BYTE        smallBuffer[100];   // A very small buffer.  
   SQLRETURN   retcode, retcode2;  
  
   // Bind the first parameter (input parameter)  
   SQLBindParameter(  
         hstmt,  
         1,                         // The first parameter.   
         SQL_PARAM_INPUT,           // Input parameter: The ID_of_picture.  
         SQL_C_ULONG,               // The C Data Type.  
         SQL_INTEGER,               // The SQL Data Type.  
         0,                         // ColumnSize is ignored for integer.  
         0,                         // DecimalDigits is ignored for integer.  
         &idOfPicture,              // The Address of the buffer for the input parameter.  
         0,                         // BufferLength is ignored for integer.  
         NULL);                     // This is ignored for integer.  
  
   // Bind the streamed output parameter.  
   SQLBindParameter(  
         hstmt,   
         2,                         // The second parameter.  
         SQL_PARAM_OUTPUT_STREAM,   // A streamed output parameter.   
         SQL_C_BINARY,              // The C Data Type.    
         SQL_VARBINARY,             // The SQL Data Type.  
         0,                         // ColumnSize: The maximum size of varbinary(max).  
         0,                         // DecimalDigits is ignored for binary type.  
         (SQLPOINTER)2,             // ParameterValuePtr: An application-defined  
                                    // token (this will be returned from SQLParamData).  
                                    // In this example, we used the ordinal   
                                    // of the parameter.  
         0,                         // BufferLength is ignored for streamed output parameters.  
         &lengthOfPicture);         // StrLen_or_IndPtr: The status variable returned.   
  
   retcode = SQLPrepare(hstmt, L"{call SP_TestOutputPara(?, ?)}", SQL_NTS);  
   if ( retcode == SQL_ERROR )  
      return FALSE;  
  
   retcode = SQLExecute(hstmt);  
   if ( retcode == SQL_ERROR )  
      return FALSE;  
  
   // Assume that the retrieved picture exists.  Use SQLBindCol or SQLGetData to retrieve the result-set.  
  
   // Process the result set and move to the streamed output parameters.  
   retcode = SQLMoreResults( hstmt );  
  
   // SQLGetData retrieves and displays the picture in parts.  
   // The streamed output parameter is available.  
   while (retcode == SQL_PARAM_DATA_AVAILABLE) {  
      SQLPOINTER token;   // Output by SQLParamData.  
      SQLLEN cbLeft;      // #bytes remained  
      retcode = SQLParamData(hstmt, &token);   // returned token is 2 (according to the binding)  
      if ( retcode == SQL_PARAM_DATA_AVAILABLE ) {  
         // A do-while loop retrieves the picture in parts.  
         do {  
            retcode2 = SQLGetData(   
               hstmt,   
               (UWORD) token,          // the value of the token is the ordinal.   
               SQL_C_BINARY,           // The C-type.  
               smallBuffer,            // A small buffer.   
               sizeof(smallBuffer),    // The size of the buffer.  
               &cbLeft);               // How much data we can get.  
         }  
         while ( retcode2 == SQL_SUCCESS_WITH_INFO );  
      }  
   }  
  
   return TRUE;  
}  

使用方案:发送和接收大型对象作为流式输入/输出参数Usage Scenario: Send and Receive a Large Object as a Streamed Input/Output Parameter

当存储过程将大型对象作为输入/输出参数传递时,可以使用SQLGetData在部分中获取和发送数据,并将值流式传输到数据库或从数据库流式传输。SQLGetData can be used to get and send data in parts when a stored procedure passes a large object as an input/output parameter, streaming the value to and from the database. 无需将所有数据存储在内存中。You do not have to store all of the data in memory.

// CREATE PROCEDURE SP_TestInOut  
//       @picture as varbinary(max) out  
// AS  
//    output the image data through output parameter   
// go  
  
BOOL displaySimilarPicture(BYTE* image, ULONG lengthOfImage, SQLHSTMT hstmt) {  
   BYTE smallBuffer[100];   // A very small buffer.  
   SQLRETURN retcode, retcode2;  
   SQLLEN statusOfPicture;  
  
   // First bind the parameters, before preparing the statement that binds the output streamed parameter.  
   SQLBindParameter(  
      hstmt,   
      1,                                 // The first parameter.  
      SQL_PARAM_INPUT_OUTPUT_STREAM,     // I/O-streamed parameter: The Picture.  
      SQL_C_BINARY,                      // The C Data Type.  
      SQL_VARBINARY,                     // The SQL Data Type.  
      0,                                 // ColumnSize: The maximum size of varbinary(max).  
      0,                                 // DecimalDigits is ignored.   
      (SQLPOINTER)1,                     // An application defined token.   
      0,                                 // BufferLength is ignored for streamed I/O parameters.  
      &statusOfPicture);                 // The status variable.  
  
   statusOfPicture = SQL_DATA_AT_EXEC;   // Input data in parts (DAE parameter at input).  
  
   retcode = SQLPrepare(hstmt, L"{call SP_TestInOut(?) }", SQL_NTS);  
   if ( retcode == SQL_ERROR )  
      return FALSE;  
  
   // Execute the statement.  
   retcode = SQLExecute(hstmt);  
   if ( retcode == SQL_ERROR )  
      return FALSE;  
  
   if ( retcode == SQL_NEED_DATA ) {  
      // Use SQLParamData to loop through DAE input parameters.  For  
      // each, use SQLPutData to send the data to database in parts.  
  
      // This example uses an I/O parameter with streamed output.  
      // Therefore, the last call to SQLParamData should return  
      // SQL_PARAM_DATA_AVAILABLE to indicate the end of the input phrase   
      // and report that a streamed output parameter is available.  
  
      // Assume retcode is set to the return value of the last call to  
      // SQLParamData, which is equal to SQL_PARAM_DATA_AVAILABLE.  
   }  
  
   // Start processing the streamed output parameters.  
   while ( retcode == SQL_PARAM_DATA_AVAILABLE ) {  
      SQLPOINTER token;   // Output by SQLParamData.  
      SQLLEN cbLeft;     // #bytes remained  
      retcode = SQLParamData(hstmt, &token);  
      if ( retcode == SQL_PARAM_DATA_AVAILABLE ) {  
         do {  
            retcode2 = SQLGetData(   
               hstmt,   
               (UWORD) token,          // the value of the token is the ordinal.   
               SQL_C_BINARY,           // The C-type.  
               smallBuffer,            // A small buffer.   
               sizeof(smallBuffer),    // The size of the buffer.  
               &cbLeft);               // How much data we can get.  
         }  
         while ( retcode2 == SQL_SUCCESS_WITH_INFO );  
      }  
   }   
  
   return TRUE;  
}  

另请参阅See Also

语句参数Statement Parameters