#1 2014-12-06 20:17:20

Almadrav
Member
Registered: 2014-09-10
Posts: 3

Very Strange problem in BatchSend

Hello AB,

I have a very strange problem, when I try to use batchSend and send 7 records, BatchSend resturns error 400, If I try to send 6 or 8 records then Works Ok!!!
I Have the particulary that the SQLRecord has 82 Fields, so I have to change the MAX_SQLFIELDS to 128.

The Problem is in Delphi 7 and also in Delphi XE7U1

This is the sample code to reproduce the problem

// SQL Model

  TPerson = class(TSQLRecord)
  private
    fField39: RawUTF8;
    fField81: RawUTF8;
    fField80: RawUTF8;
    fField38: RawUTF8;
    fField29: RawUTF8;
    fField18: RawUTF8;
    fField78: RawUTF8;
    fField19: RawUTF8;
    fField68: RawUTF8;
    fField7: RawUTF8;
    fField4: RawUTF8;
    fField55: RawUTF8;
    fField45: RawUTF8;
    fField6: RawUTF8;
    fField5: RawUTF8;
    fField28: RawUTF8;
    fField82: RawUTF8;
    fField21: RawUTF8;
    fField12: RawUTF8;
    fField30: RawUTF8;
    fField33: RawUTF8;
    fField20: RawUTF8;
    fField8: RawUTF8;
    fField13: RawUTF8;
    fField9: RawUTF8;
    fField26: RawUTF8;
    fField62: RawUTF8;
    fField31: RawUTF8;
    fField48: RawUTF8;
    fField22: RawUTF8;
    fField79: RawUTF8;
    fField69: RawUTF8;
    fField23: RawUTF8;
    fField59: RawUTF8;
    fField32: RawUTF8;
    fField58: RawUTF8;
    fField49: RawUTF8;
    fField54: RawUTF8;
    fField43: RawUTF8;
    fField34: RawUTF8;
    fField52: RawUTF8;
    fField70: RawUTF8;
    fField61: RawUTF8;
    fField25: RawUTF8;
    fField53: RawUTF8;
    fField40: RawUTF8;
    fField66: RawUTF8;
    fField16: RawUTF8;
    fField71: RawUTF8;
    fField27: RawUTF8;
    fField10: RawUTF8;
    fField36: RawUTF8;
    fField72: RawUTF8;
    fField63: RawUTF8;
    fField73: RawUTF8;
    fField24: RawUTF8;
    fField11: RawUTF8;
    fField37: RawUTF8;
    fField60: RawUTF8;
    fField42: RawUTF8;
    fField74: RawUTF8;
    fField65: RawUTF8;
    fField3: RawUTF8;
    fField46: RawUTF8;
    fField15: RawUTF8;
    fField56: RawUTF8;
    fField44: RawUTF8;
    fField1: RawUTF8;
    fField57: RawUTF8;
    fField47: RawUTF8;
    fField75: RawUTF8;
    fField67: RawUTF8;
    fField50: RawUTF8;
    fField76: RawUTF8;
    fField35: RawUTF8;
    fField17: RawUTF8;
    fField41: RawUTF8;
    fField64: RawUTF8;
    fField51: RawUTF8;
    fField77: RawUTF8;
    fField14: RawUTF8;
    fField2: RawUTF8;
  published
    property Field1: RawUTF8 read fField1 write fField1;
    property Field2: RawUTF8 read fField2 write fField1;
    property Field3: RawUTF8 read fField3 write fField1;
    property Field4: RawUTF8 read fField4 write fField1;
    property Field5: RawUTF8 read fField5 write fField1;
    property Field6: RawUTF8 read fField6 write fField1;
    property Field7: RawUTF8 read fField7 write fField1;
    property Field8: RawUTF8 read fField8 write fField1;
    property Field9: RawUTF8 read fField9 write fField1;

    property Field10: RawUTF8 read fField10 write fField10;
    property Field11: RawUTF8 read fField11 write fField11;
    property Field12: RawUTF8 read fField12 write fField12;
    property Field13: RawUTF8 read fField13 write fField13;
    property Field14: RawUTF8 read fField14 write fField14;
    property Field15: RawUTF8 read fField15 write fField15;
    property Field16: RawUTF8 read fField16 write fField16;
    property Field17: RawUTF8 read fField17 write fField17;
    property Field18: RawUTF8 read fField18 write fField18;
    property Field19: RawUTF8 read fField19 write fField19;

    property Field20: RawUTF8 read fField20 write fField20;
    property Field21: RawUTF8 read fField21 write fField21;
    property Field22: RawUTF8 read fField22 write fField22;
    property Field23: RawUTF8 read fField23 write fField23;
    property Field24: RawUTF8 read fField24 write fField24;
    property Field25: RawUTF8 read fField25 write fField25;
    property Field26: RawUTF8 read fField26 write fField26;
    property Field27: RawUTF8 read fField27 write fField27;
    property Field28: RawUTF8 read fField28 write fField28;
    property Field29: RawUTF8 read fField29 write fField29;

    property Field30: RawUTF8 read fField30 write fField30;
    property Field31: RawUTF8 read fField31 write fField31;
    property Field32: RawUTF8 read fField32 write fField32;
    property Field33: RawUTF8 read fField33 write fField33;
    property Field34: RawUTF8 read fField34 write fField34;
    property Field35: RawUTF8 read fField35 write fField35;
    property Field36: RawUTF8 read fField36 write fField36;
    property Field37: RawUTF8 read fField37 write fField37;
    property Field38: RawUTF8 read fField38 write fField38;
    property Field39: RawUTF8 read fField39 write fField39;

    property Field40: RawUTF8 read fField40 write fField40;
    property Field41: RawUTF8 read fField41 write fField41;
    property Field42: RawUTF8 read fField42 write fField42;
    property Field43: RawUTF8 read fField43 write fField43;
    property Field44: RawUTF8 read fField44 write fField44;
    property Field45: RawUTF8 read fField45 write fField45;
    property Field46: RawUTF8 read fField46 write fField46;
    property Field47: RawUTF8 read fField47 write fField47;
    property Field48: RawUTF8 read fField48 write fField48;
    property Field49: RawUTF8 read fField49 write fField49;

    property Field50: RawUTF8 read fField50 write fField50;
    property Field51: RawUTF8 read fField51 write fField51;
    property Field52: RawUTF8 read fField52 write fField52;
    property Field53: RawUTF8 read fField53 write fField53;
    property Field54: RawUTF8 read fField54 write fField54;
    property Field55: RawUTF8 read fField55 write fField55;
    property Field56: RawUTF8 read fField56 write fField56;
    property Field57: RawUTF8 read fField57 write fField57;
    property Field58: RawUTF8 read fField58 write fField58;
    property Field59: RawUTF8 read fField59 write fField59;

    property Field60: RawUTF8 read fField60 write fField60;
    property Field61: RawUTF8 read fField61 write fField61;
    property Field62: RawUTF8 read fField62 write fField62;
    property Field63: RawUTF8 read fField63 write fField63;
    property Field64: RawUTF8 read fField64 write fField64;
    property Field65: RawUTF8 read fField65 write fField65;
    property Field66: RawUTF8 read fField66 write fField66;
    property Field67: RawUTF8 read fField67 write fField67;
    property Field68: RawUTF8 read fField68 write fField68;
    property Field69: RawUTF8 read fField69 write fField69;

    property Field70: RawUTF8 read fField70 write fField70;
    property Field71: RawUTF8 read fField71 write fField71;
    property Field72: RawUTF8 read fField72 write fField72;
    property Field73: RawUTF8 read fField73 write fField73;
    property Field74: RawUTF8 read fField74 write fField74;
    property Field75: RawUTF8 read fField75 write fField75;
    property Field76: RawUTF8 read fField76 write fField76;
    property Field77: RawUTF8 read fField77 write fField77;
    property Field78: RawUTF8 read fField78 write fField78;
    property Field79: RawUTF8 read fField79 write fField79;

    property Field80: RawUTF8 read fField80 write fField80;
    property Field81: RawUTF8 read fField81 write fField81;
    property Field82: RawUTF8 read fField82 write fField82;
  end;
// Server

program RESTserver;

{$APPTYPE CONSOLE}

uses
  SynCommons,
  mORMot,
  mORMotSQLite3,
  SynSQLite3Static,
  mORMotHttpServer,
  SysUtils,
  RESTModel;
var
  aModel: TSQLModel;
  aRestServer: TSQLRestServerDB;
  aHttpServer: TSQLHttpServer;
begin
  aModel := DataModel;
  try
    aRestServer := TSQLRestServerDB.Create(aModel, ChangeFileExt(paramstr(0),'.db3') ,false); 
    try
      aRestServer.CreateMissingTables;
      aHttpServer := TSQLHttpServer.Create('888', aRestServer);
      try
        writeln('Background server is running.'#10);
        write('Press [Enter] to close the server.');
        readln;
      finally
        aHttpServer.Free;
      end;
    finally
      aRestServer.Free;
    end;
  finally
    aModel.Free;
  end;
end.
// Client

program RESTclient;

{$APPTYPE CONSOLE}

uses
    SynCommons,          // framework core
    mORMot,              // RESTful server & ORM
    mORMotHttpClient,    // HTTP client to a mORMot RESTful server
    RESTModel;           // data model unit, shared between server and client

var aModel: TSQLModel;
    aClient: TSQLHttpClient;
    aPerson: TPerson;
    R: TIDDynArray;
    I: Integer;
    RV: Integer;
begin
  aModel := DataModel;
  try
    aClient := TSQLHttpClientWinHTTP.Create('localhost', '888', aModel);
    try
      aPerson := TPerson.Create;
      try
        aClient.BatchStart(TPerson);
        try
          for I  := 1 to 7 do
            aClient.BatchAdd(aPerson, True);
        finally
          RV := aClient.BatchSend(R);
          if RV <> HTML_SUCCESS then
            write(#10'Error in BatchAdd: ', RV)
          else
            write(#10'HTML_SUCCESS in BatchAdd')
        end
      finally
        aPerson.Free;
      end;
    finally
      aClient.Free;
    end;
    write(#10'Press [Enter] to quit');
    readln;
  finally
    aModel.Free;
  end;
end.

Offline

#2 2015-01-08 14:12:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Very Strange problem in BatchSend

Offline

Board footer

Powered by FluxBB