17.00 - 17.05 - FNC_LobOpen_CLの使用例 - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL外部ルーチン プログラミング

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
17.05
Published
2020年6月
Content Type
プログラミング リファレンス
Publication ID
B035-1147-170K-JPN
Language
日本語 (日本)

以下のコードは、入力ストリームからLOBを読み取り、その内容を出力ストリームにコピーします。

LOB_RESULT_LOCATOR   lrl_a;
int                  streamno=0;
int                  i;
BYTE                 *locator;
int                  locatorLength;
int                  null_ind;
FNC_LobLength_t      lobLength;
LOB_CONTEXT_ID       lobid;
BYTE                 Buffer[BufferSize];
int                  length;
int                  truncerr;
FNC_TblOpHandle_t    *Handle, *OutHandle;
.......

   // Get locator for LOB in column  i  of output stream  streamno 
   lrl_a = FNC_LobCol2Loc(streamno, i);
   // Get client locator for input LOB
   FNC_TblOpGetAttributeByNdx(Handle, i, (void **) &locator, &null_ind, &locatorLength);
   if (null_ind != -1) {
      // Open input LOB
      FNC_LobOpen_CL(locator, &lobid, 0, 0);
      truncerr = 0;
      // Read input LOB and append it to output LOB
      while( FNC_LobRead(lobid, Buffer, BufferSize, &length) == 0 && !truncerr)
         truncerr=FNC_LobAppend (lrl_a, Buffer, length, &actlen);
         // Close input LOB
      FNC_LobClose(lobid);
   }
   else
      // Set output column to NULL
      FNC_TblOpBindAttributeByNdx(OutHandle, i, locator, null_ind, locatorLength);