DB2 10.5 for Linux, UNIX, and Windows

DB2DataReader.GetChars 方法

从指定列偏移位置开始读取字符流,并从给定缓冲区偏移位置开始将其以数组形式写入缓冲区。

名称空间:
IBM.Data.DB2
组合件:
IBM.Data.DB2(在 IBM.Data.DB2.dll 中)

语法

[Visual Basic]
Public Function GetChars( _
   ByVal i As Integer, _
   ByVal dataIndex As Long, _
   ByVal buffer() As Char, _
   ByVal bufferIndex As Integer, _
   ByVal length As Integer _
) As Long
[C#]
public long GetChars(
   int i,
   long dataIndex,
   char[] buffer,
   int bufferIndex,
   int length
);
[C++]
public: __int64 GetChars(
   int i,
   __int64 dataIndex,
   __wchar_t buffer __gc[],
   int bufferIndex,
   int length
);
[JScript]
public function GetChars(
   i : int,
   dataIndex : long,
   buffer : Char[],
   bufferIndex : int,
   length : int
) : long;

参数

i
从零开始的列序号。
dataIndex
读操作的起始行索引。
buffer
复制数据的目标缓冲区。
bufferIndex
buffer 中写操作的起始位置索引。
length
要读取的字符数。

返回值

读取的实际字符数。

异常

异常类型 条件
DB2Exception 转换无效。

注释

GetChars 返回字段中的可用字符数。大多数情况下,这是该字段的准确长度。但是,如果已使用 GetChars 来获取字段中的字符数,那么返回的数字可能小于该字段的真实长度。例如,如果 DB2®DataReader 正在将 CLOB 读入缓冲区中,那么可能存在这种情况。有关更多信息,请参阅 Microsoft(R) .NET Framework SDK 文档中 System.Data.CommandBehavior 的 SequentialAccess 设置。

如果传递的 buffer 为空值,那么 GetChars 返回字段的长度(以字符计)。

不执行转换。要检索的数据必须为下列其中一种类型:
  • DB2Type.Char
  • DB2Type.VarChar
  • DB2Type.LongVarChar
  • DB2Type.Clob
  • DB2Type.Graphic
  • DB2Type.VarGraphic
  • DB2Type.LongVarGraphic
  • DB2Type.DbClob
下表描述了返回对象数据类型与数据服务器数据类型之间的映射。
DB2Type 数据类型 DB2 数据类型 Informix® 数据类型
Char CHAR CHAR
VarChar VARCHAR VARCHAR
LongVarChar LONG VARCHAR LVARCHAR
Clob CLOB CLOB 和 TEXT
Graphic GRAPHIC  
VarGraphic VARGRAPHIC  
LongVarGraphic LONG VARGRAPHIC  
DbClob DBCLOB