1

我想在调用 TIBControlAndQueryServiceGetNextLine 时添加 isc_info_svc_timeout(1 秒)选项。我复制并修改了 IBServices 以在 isc_info_svc_line 之后以类似的方式将 isc_info_svc_timeout 附加到 ServiceQueryParams,例如 ServiceStartAddParam (Value: Integer; param: Integer),但我收到错误消息“不支持功能”

编辑

首先,我决定将超时添加到 InternalServiceQuery 而不是 GetNextLine。其次,我将超时参数附加到我不应该的 FQueryParams 中。第三,超时参数在 isc_service_query 函数中有自己的位置,4 和 5 位置(数据长度和数据指针)。现在它看起来像它的工作,我的意思是没有“不支持的功能”错误,但不幸的是它没有。在没有数据要发回时调用 GetNextLine(调用 InternalServiceQuery)后,我的应用程序挂起并等待数据,就像超时参数没有效果一样。

procedure TIBCustomService.InternalServiceQuery;

  function AddParam (Value: Integer; param: Integer): string;
  begin
  Result  := Char(Param) +
         PChar(@Value)[0] +
         PChar(@Value)[1] +
         PChar(@Value)[2] +
         PChar(@Value)[3];
  end;

var
  FTimeout: string;
  PTimeout: PChar;
  FTimeoutLen: short;
begin
  FTimeout := AddParam(1, isc_info_svc_timeout);
  FTimeoutLen := Length(FTimeout);
  PTimeout := nil;
  IBAlloc(PTimeout, 0, FTimeoutLen);
  Move(FTimeout[1], PTimeout[0], FTimeoutLen);

  FQuerySPBLength := Length(FQueryParams);
  if FQuerySPBLength = 0 then
    IBError(ibxeQueryParamsError, [nil]);
  IBAlloc(FQuerySPB, 0, FQuerySPBLength);
  Move(FQueryParams[1], FQuerySPB[0], FQuerySPBLength);
  if (FOutputBuffer = nil) then
    IBAlloc(FOutputBuffer, 0, FBufferSize);
  try
  if call(FGDSLibrary.isc_service_query(StatusVector, @FHandle, nil,
               FTimeoutLen, PTimeout,
               FQuerySPBLength, FQuerySPB,
               FBufferSize, FOutputBuffer), False) > 0 then
  begin
4

0 回答 0