#51 mORMot 1 » FormatUTF8 » 2015-06-03 10:15:32

noobies
Replies: 4

try modernize code ClientRest.ExecuteList([], s) with FormatUTF8 (executelist need - have several commands inner join)
old part code (work fine):

Result := Result + 'strftime("%Y", InputDate) = ' + cbbCurrentYear.Value.QuotedString

if change old part to new part code not work:

Result := Result + FormatUTF8('strftime("%Y", InputDate) = ?', [], [cbbCurrentYear.Value]);

if result i see: ' strftime("Y", InputDate) = ?'. any idea how format sql with expression?

#52 Re: mORMot 1 » Code to add hide drawgrid column » 2015-06-02 06:21:14

ab, sorry may be i slowpoke, but i dont understand how can i realize hidden columns by using TSQLTable.SetFieldLengthMean().
if write something like this:

  SetLength(len, tbl_patients.FieldCount - 1);
  for i := 0 to tbl_patients.FieldCount - 1 do len[i] := tbl_patients.FieldLengthMean(i);
  len[colAproove] := 0;
  len[colDecline] := 0;
  tbl_patients.SetFieldLengthMean(len);
  with TSQLTableToGrid.Create(dgList, tbl_Patients, ClientRest) do begin
    ShowHint := False;
    OnValueText := OnValueTextTablePatients;
    OnDrawCellBackground := OnDrawCellBackgroundPatients;
    Resize(nil);
...
   end;

it does not work, since resize run after this code, and all columns recalculated

P.S. i try use TSQLTableToGrid procedure, but procedure has different format and apply for all column(((

procedure TSQLTable.SetFieldLengthMean(const Lengths: array of cardinal);
...
procedure TSQLTableToGrid.SetFieldLengthMean(const Lengths: RawUTF8; aMarkAllowed: boolean);
...

#53 Re: mORMot 1 » Code to add hide drawgrid column » 2015-06-01 13:29:54

  TSQLFieldType = (
    sftUnknown, sftAnsiText, sftUTF8Text, sftEnumerate, sftSet,
    sftInteger, sftID, sftRecord, sftBoolean,
    sftFloat, sftDateTime, sftTimeLog, sftCurrency, sftObject,
    {$ifndef NOVARIANTS}
    sftVariant,
    {$endif}
    sftBlob, sftBlobDynArray, sftBlobCustom, sftUTF8Custom, sftMany,
    sftModTime, sftCreateTime, sftTID, sftRecordVersion, sftHidden); //<=== add sftHidden, and other constants too
function TSQLTable.CalculateFieldLengthMean(var aResult: TIntegerDynArray;
  FromDisplay: boolean=false): integer;
...
        case fFieldType[F].ContentType of
...
             sftHidden: aResult[F]:=0;
...
  for F := 0 to FieldCount-1 do begin
    if aResult[F] = 0 then Continue;
...

AB, can you add sftHidden to framework?

#55 Re: mORMot 1 » Code to add hide drawgrid column » 2015-06-01 06:36:35

quick fix

procedure TSQLTable.DeleteColumnValues(Field: integer);
var i: integer;
    U: PPUTF8Char;
begin
  if cardinal(Field)>=cardinal(FieldCount) then
    exit; // out of range
  U := @fResults[Field+FieldCount];  // U^ = column UTF-8 content for this field
  for i := 1 to fRowCount do begin
    if U^ <> nil then U^[0] := #0; // just void UTF-8 content text   //ADD if U^ <> nil then 
    inc(U,FieldCount);
  end;
end;

yes it works - column hide but have no data and no color((( Need only hide column without erase data

i think add sftNotVisible best solution

#56 Re: mORMot 1 » Code to add hide drawgrid column » 2015-06-01 06:05:39

I tried this function, but it's not what me need, especially as a function of the error if I specify the column in which the row 5 no data (for example, an empty string) function returns an error. (if all the rows have the data all works), though I do not understand why it can be necessary, because you can simply specify the column in the sql command.
I do not need to display an empty column without the data I need to hide a column.
i have wide monitor, but many users not have. User dont need last 2 column - color show approve or decline this record.
of course table show in auto resize

  with TSQLTableToGrid.Create(dgList, tbl_Patients, ClientRest) do begin
    ShowHint := False;
    OnValueText := OnValueTextTablePatients;
    OnDrawCellBackground := OnDrawCellBackgroundPatients;
    Resize(nil);
    ...
  end;

before
7173077.jpg
after
7166933.jpg

#57 mORMot 1 » Code to add hide drawgrid column » 2015-05-29 08:59:27

noobies
Replies: 9
function TSQLTable.CalculateFieldLengthMean(var aResult: TIntegerDynArray;
  FromDisplay: boolean=false): integer;
...
    for R := 1 to fRowCount do // sum all lengths by field
      for F := 0 to FieldCount-1 do begin
        case fFieldType[F].ContentType of
...
          sftUnknown: aResult[F]:=0; //  I ADD THIS TO WORK HIDE COLUMN
...
  for F := 0 to FieldCount-1 do begin
    if aResult[F] = 0 then Continue; // IF 0 HIDE COLUMN, SOME TIMES NEED HIDE COLUMN
    n := cardinal(aResult[F]) div Tot; // Mean = total/count
    if n=0  then n := 1;  // none should be 0
    aResult[F] := n;
    inc(result,n); // fast calculate mean sum
  end;

i hide column to save space in grid, approvedate - green color in table, declinedate - red color in table, not need show 2 column

  tbl_patients := ClientRest.ExecuteList([], s);
  tbl_patients.SetFieldType('approvedate',sftUnknown);
  tbl_patients.SetFieldType('declinedate',sftUnknown);

or may be add new type sftNotVisible?

#58 Re: mORMot 1 » TTimeLog and BETWEEN » 2015-05-26 11:02:05

ab wrote:

creating the WHERE clause with the overloaded FormatUTF8() allowing both Args and Bounds parameters.

thanks i change my code

   ...'where ' + FormatUTF8('r.mo = ? AND r.Created BETWEEN ? AND ?', [], [mo_id, TimeLogFromDateTime(db), TimeLogFromDateTime(de)]);

#59 Re: mORMot 1 » TTimeLog and BETWEEN » 2015-05-26 07:31:14

ab wrote:

Try to use TSQLRest.MultiFieldValues

but how create join with 4 tables?

    function MultiFieldValues(Table: TSQLRecordClass; const FieldNames: RawUTF8;
      const WhereClauseFormat: RawUTF8; const BoundsSQLWhere: array of const): TSQLTableJSON; overload;

if put inner join in FieldNames he placed before FROM, if put in WhereClauseFormat he placed after WHERE

#60 Re: mORMot 1 » TTimeLog and BETWEEN » 2015-05-26 06:24:47

ab wrote:

TTimeLog fields are stored as Integer SQLite3 values, so they should work.

it works, sorry gramma misstake BETWEEN not BEETWEN.

' AND (r.Created BETWEEN ? AND ?)');
  t := ClientRest.ExecuteFmt(s,[],[TimeLogFromDateTime(db),TimeLogFromDateTime(de)]);

yes but ExecuteFmt return boolean not table(((.
it would be wonderful to have a execute format returned table

#61 Re: mORMot 1 » TTimeLog and BETWEEN » 2015-05-22 08:50:39

i not using external DB.
server

  with TSQLite3HttpService.Create do
  try
    ServicesRun;
  finally
    Free;
  end;

client

  
  Model := CreateModel;
  ReadConfig;
  ClientRest := TSQLHttpClient.Create(ip, port, Model);
  ClientRest.ForceBlobTransfert := True;
  if not ClientRest.ServerTimeStampSynchronize then Result := False;

sql exec

  s :=
    'select ls.TradeNmR, ls.InnR, ls.DosageR, ls.PackQn, ls.EAN, r.Series, r.MnfPrice, r.PrcPrice, ' +
    'r.TotDrugQn, v.VendorNm, z.Name, r.RekvType, r.RekvNum, r.RekvDate ' +
    'from Recs r ' +
    'inner join RZLS ls on r.DrugID = ls.DrugID ' +
    'inner join RZVendor v on r.VendorID = v.VendorID ' +
    'inner join Zakupka z on r.ZakupkaID = z.ID ' +
    'where r.mo = ' + mo_id.ToString +
//    ' AND r.Created BEETWEN ' +  IntToStr(TimeLogFromDateTime(db)) + ' AND ' + IntToStr(TimeLogFromDateTime(de));
    ' AND r.Created >= ' + IntToStr(TimeLogFromDateTime(db)) + ' AND r.Created <= ' + IntToStr(TimeLogFromDateTime(de));
  t := ClientRest.ExecuteList([], s);

BETWEEN not work only in TTimeLog fields, with others work pretty fine

#62 mORMot 1 » TTimeLog and BETWEEN » 2015-05-22 06:47:35

noobies
Replies: 8

dont understand why this  work

...' AND Created >= ' + IntToStr(TimeLogFromDateTime(db)) + ' AND Created <= ' + IntToStr(TimeLogFromDateTime(de));

but this dont work

...' AND Created BEETWEN ' +  IntToStr(TimeLogFromDateTime(db)) + ' AND ' + IntToStr(TimeLogFromDateTime(de));

#63 Re: mORMot 1 » Manipulate data to server before send it to client » 2015-04-20 05:52:35

create pas, add constant with u path and add on client and server app or save in db in special options table paths and others sys info

#64 Re: mORMot 1 » implement push notifications » 2015-04-20 05:45:04

to warleyalex,
рш, сan you put your sample demo here (better if ab add it to ThirdPartyDemos)?

#65 Re: mORMot 1 » implement push notifications » 2015-04-09 05:36:19

to warleyalex:
see sample 26 - RESTful ORM

RESTServerClass.pas
procedure TNoteServer.Blob(Ctxt: TSQLRestServerURIContext);

#66 Re: mORMot 1 » show hint text in drawgrid in current language » 2015-03-11 06:41:16

i change in source from

procedure TSQLTableToGrid.DrawGridMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
...
  if ARow=0 then
  if (ssCtrl in Shift) or (Button<>mbLeft) then begin
    // Ctrl or right button pressed -> display first row as hint
    ShowHintString(U2S(Table.Get(ARow,ACol)),ACol,ARow,4000);

to

  SQLTableToGrid.OnHintText := OnListText;


procedure TSQLTableToGrid.DrawGridMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
...
  if ARow=0 then
  if (ssCtrl in Shift) or (Button<>mbLeft) then begin
    // Ctrl or right button pressed -> display first row as hint
    if Assigned(OnHintText) and OnHintText(Table,ACol,ARow,Hint) then
      ShowHintString(Hint,ACol,ARow,4000)
    else
      ShowHintString(U2S(Table.Get(ARow,ACol)),ACol,ARow,4000);

its work and view russian name column, but first i see english column name before draw russian column name. How draw text without this bug?

#67 mORMot 1 » show hint text in drawgrid in current language » 2015-03-11 06:19:09

noobies
Replies: 1

very simple replace text in header drawgirid use function

  fieldText: array [0..10] of string = (
    '№',
    '№ БЛ',
    'Выдан',
    'Фамилия',
    'Имя',
    'Отчество',
    'Д/р',
    'Место работы',
    'пред БЛ',
    'след БЛ',
    '#');
...

SQLTableToGrid.OnValueText := OnListText;
...
function TfrmMain.OnListText(Sender: TSQLTable; FieldIndex, RowIndex: Integer; var Text: string): boolean;
begin
  if RowIndex = 0 then begin
    Text := fieldText[FieldIndex];
    Result := True;
  end
  else
    Result := False;
end;

but how change hint (sample right click on header), i dont find this function, and no option to disable

#69 Re: mORMot 1 » save picture from blob to server folder » 2015-03-02 08:12:03

before it was, but still does not work.

    aClient.CallBackGet('blob', [], response, TSQLNoteFile);
    write(response);
    aClient.CallBackPut('blob', jpgRaw, response, TSQLNoteFile);

dont understand why, please try run this client with sample 26 server.

#70 Re: mORMot 1 » save picture from blob to server folder » 2015-03-02 07:14:12

problem how "call root/notefile/blob"

i run server from 26 sample and if i run client i get "<h1>Bad Request (Invalid Hostname)</h1>"

/// minimal REST client for a list of Persons from RESTserver.exe
program RESTclient;

{$APPTYPE CONSOLE}

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

var aModel: TSQLModel;
    aClient: TSQLHttpClient;
    aRootURI, response: RawUTF8;
    jpg: TJPEGImage;
    jpgRaw: RawByteString;
begin
  Gdip := TGDIPlusFull.Create;

  aModel := DataModel(aRootURI);
  try
    aClient := TSQLHttpClientWinHTTP.Create('localhost','888',aModel);
    jpg := TJPEGImage.Create;
    jpg.LoadFromFile('d:\scans\1.jpg');
    SaveAsRawByteString(jpg, jpgRaw, gptJPG);
    aClient.CallBackGet('root/notefile/blob', [], response, TSQLNoteFile);
    write(response);
    aClient.CallBackPut('root/notefile/blob', jpgRaw, response, TSQLNoteFile);
    write(response);
    write(#10'Press [Enter] to quit');
    readln;
  finally
    aModel.Free;
  end;

  Gdip.Free;
end.

#71 Re: mORMot 1 » save picture from blob to server folder » 2015-02-27 14:31:29

thanks, i see sample, but dont understand how it works. all samples have client and server files, but 26 - RESTful ORM\RESTServerClass.pas have only server side

#72 mORMot 1 » save picture from blob to server folder » 2015-02-27 06:16:39

noobies
Replies: 9

hi, i use sample 10 - Background Http service.
is it possible use client side procedure to save the image from blob to server folder?

#73 Re: mORMot 1 » Third-party Samples » 2014-07-10 05:07:35

How to connect to MySQL Server via ZEOS or UNIDAC with Mormot
http://synopse.info/forum/viewtopic.php?id=1547

i see many question how connect to different base, ab may be better create sample for connect to all base and put it into sample folder with source?
ab's answer: there are so many combination of DB / Library possible, that we could not be exhaustive. But any valuable input will be added to the documentation.

#74 Re: mORMot 1 » Select DISTINCT » 2014-05-15 10:58:21

any news about distinct?

need to write repetitive code, sample

procedure Fill_combobox_data(r: TSQLRecord; s: TStrings; field: string);
begin
  s.Clear;
  r.CreateAndFillPrepare(Database, '');
  try
    while r.FillOne do s.Add(r.RecordProps.Fields.ByRawUTF8Name(field).GetValue(r, False));
  finally
    r.Free;
  end;
end;

if me need add distinct need write additional procedure

procedure Fill_distinct_combobox_data(r: TSQLRecord; s: TStrings; field: string);
var
 t: TSQLTable;
begin
  s.Clear;
  t := Database.List([r.RecordClass], 'distinct trim(' + field + ') as ' + field, '');
  if t = nil then Exit;
  t.OwnerMustFree := False;
  r.FillPrepare(t);
  try
    while r.FillOne do s.Add(r.RecordProps.Fields.ByRawUTF8Name(field).GetValue(r, False));
  finally
    r.Free;
    t.Free;
  end;
end;

what is currently the best option for the use of a distinct in framework?

#75 mORMot 1 » User authentication with sample 04 - HTTP Client-Server » 2014-04-16 07:44:02

noobies
Replies: 1

I read the documentation and can not understand how to do the following in Example 04:
1) change the name, password and the right standard account (Database.SetUser ('User', 'synopse'))
2) add a new account
Maybe there is a simple example of management accounts?

#76 mORMot 1 » How display custom message and close programm when server is down? » 2014-04-11 13:22:50

noobies
Replies: 1

Sample 04

  Form1.Database := TSQLHttpClient.Create(Server,'8080',Form1.Model);
  TSQLHttpClient(Form1.Database).SetUser('User','synopse');

if run in Delphi we see message Project Project04Client.exe raised exception class EWinHTTP with message 'Unable to connect to localhost:8080 - server may be down or unavailable'.
i try use terminate on except but nothing happends

  Form1.Database := TSQLHttpClient.Create(Server,'8080',Form1.Model);
  try
    TSQLHttpClient(Form1.Database).SetUser('User','synopse');
  except
    Application.Terminate;
  end;

How to verify that the server is down?

#77 Re: mORMot 1 » MAX_SQLLOCKS problem » 2014-04-10 04:37:16

mpv wrote:

As a workaround (If your businnes logic allow) - use commit on every 512 record. In all case this is faster compared to long transaction.

i try but no effect

ab wrote:

We have just removed MAX_SQLLOCKS constant non-sense (replaced by two dynamic arrays).
Should work as you expected now.:)

thanks, now work pretty well

#78 mORMot 1 » MAX_SQLLOCKS problem » 2014-04-09 14:43:45

noobies
Replies: 3
  TSQLProduct = class(TSQLRecord)
  private
    ...
    fPreview: TByteDynArray;
  published
    ...
    property preview: TByteDynArray read fPreview write fPreview;

procedure FillPreview;
var
  prd, p: TSQLProduct;
  ids: TIntegerDynArray;
  picBin: TByteDynArray;
  ms: TMemoryStream;
begin
  p := TSQLProduct.CreateAndFillPrepare(Database, '');
  if Database.TransactionBegin(TSQLProduct) then
  try
    Database.BatchStart(TSQLProduct);
    while p.FillOne do begin
      if p.preview <> nil then Continue;
      prd := TSQLProduct.Create(Database, p.ID, True);
      try
        ms := TMemoryStream.Create;
        try
          ms.LoadFromFile(pathDir + p.fPath);
          SetLength(picBin, ms.Size);
          Move(ms.Memory^, picBin[0], ms.Size);
          prd.preview := picBin;
        finally
          ms.Free;
        end;
        Database.BatchUpdate(prd);
      finally
        FreeAndNil(prd);
      end;

    end;
    Database.BatchSend(ids);
    Database.Commit;
  except
    Database.RollBack;
  end;
  FreeAndNil(p);
end;

directory contains about 3000 jpg, but update only 512, i found in source MAX_SQLLOCKS constant and change to 1024 and re run test, 1024 record updated

  /// maximum number of the locked record in a Table (used in TSQLLocks)
  // - code is somewhat faster and easier with a fixed cache size
  // - 512 seems big enough on practice
  MAX_SQLLOCKS = 1024;

how to update all records regardless of the constants MAX_SQLLOCKS?

#81 Re: Low level and performance » How to unzip or zip files content » 2014-03-03 11:30:30

http://rouse.drkb.ru/components.php#fwzip
open source alternative with plenty of opportunities: large files, few need memory, password protect archive and unarchive, ppmd

#82 Re: mORMot 1 » autosize column width » 2014-02-21 04:28:08

yes at the moment, in the six months were no complaints.
but I think it is not the best option, because know only superficially framework

#83 Re: mORMot 1 » autosize column width » 2014-02-20 10:05:25

problem see on last 3 column, he have data not in each row and standart algoritm compress column. fix normalize size column

#84 mORMot 1 » autosize column width » 2014-02-20 07:42:37

noobies
Replies: 3

i use drawgrid autosize column width, but it work terrible, maybe I do not see how you can control the functions they.
small rewrite source mormot.pas from (https://www.dropbox.com/s/iwf6npz0lufle … column.JPG)

    for R := 1 to RowCount do // sum all lengths by field
      for F := 0 to FieldCount-1 do begin
        case fFieldType[F].ContentType of
        sftInteger, sftBlob, sftBlobCustom, sftUTF8Custom, sftRecord,
        sftID, sftSet, sftCurrency:
          inc(aResult[F],8);
        else inc(aResult[F],Utf8FirstLineToUnicodeLength(U^));
        end;
        inc(U); // points to next value
      end;

to

var nullfield: integer;

    for R := 1 to RowCount do // sum all lengths by field
      for F := 0 to FieldCount-1 do begin
        case fFieldType[F].ContentType of
          sftDateTime: inc(aResult[F],8)
          else begin
            nullfield := Utf8FirstLineToUnicodeLength(U^);
            if nullfield = 0 then nullfield := 8;
            inc(aResult[F],nullfield + 1);
          end;  
        end;
        inc(U); // points to next value
      end;

and see more better i think (https://www.dropbox.com/s/xmnveo759oskn … column.JPG)

#85 Re: mORMot 1 » getHTTP problem » 2014-02-19 15:59:34

ab wrote:

If I understand well, the difference between computers is also the proxy definition?

AFAIK TWinINet.Get() will transparently use the system (aka Internet Explorer) proxy settings.

no, all computers have some proxy. i know about proxy setting and they are the same everywhere.
I do not understand why HttpGet not working on 4 computers.
In my home pc on win 8.1 work fine without problem.

#86 Re: mORMot 1 » getHTTP problem » 2014-02-19 05:12:13

i dont understand, try all variant but no one not work.

ShowMessage(HttpGet('koscrb.dzo-kostroma.ru', '80', 'index.php?page_id=1'));
ShowMessage(TWinHTTP.Get('koscrb.dzo-kostroma.ru/index.php?page_id=1'));
ShowMessage(TWinINet.Get('koscrb.dzo-kostroma.ru/index.php?page_id=1'));

my program use chromium and in chromium this link koscrb.dzo-kostroma.ru/index.php?page_id=1 work fine, no problem connection and in any browser on this pc (ie, chrome) link also works well.

I'd like to use mormot HttpGet, very simple command, but this bug puzzles me.

i install last version OverbyteIcs, try use and this code works

  With HttpCli1 do begin
    URL            := 'http://koscrb.dzo-kostroma.ru/index.php?page_id=1';
    Proxy          := '10.44.1.163';
    ProxyPort      := '3128';
    RequestVer     := '1.1';
    RcvdStream := TMemoryStream.Create;
    try
        Get;
    except
      RcvdStream.Free;
      Exit;
    end;
    RcvdStream.Seek(0,0);
    Memo1.Lines.LoadFromStream(RcvdStream);
    RcvdStream.Free;
  end;

#87 Re: mORMot 1 » getHTTP problem » 2014-02-18 13:26:58

hi, i again get problem, in my work on win xp, win 7 work fine, no problem.
but on infomat pc (win 7 maximal) httpget dont work.
all computers work in same proxy. code for test:

ShowMessage(HttpGet('www.ecb.europa.eu', '80', '/stats/eurofxref/eurofxref-daily.xml'));

in module syncrtsock i place message for test, after message size sin = 16, long wait and then message connect failed and empty message.

function CallServer(const Server, Port: RawByteString; doBind: boolean; aLayer: TCrtSocketLayer): TSocket;
...
  showmessage('try connect');
  showmessage('size sin = ' + IntToStr(SizeOfVarSin(Sin))); // size sin = 16
  if Connect(result,Sin)<>0 then begin
     CloseSocket(result);
     showmessage('connect failed');

#88 Re: mORMot 1 » getHTTP problem » 2014-02-04 09:07:27

i solve my problem, but may be add HttpGet TimeOut parameter?

function HttpGet(const server, port: AnsiString; const url: RawByteString): RawByteString;
var Http: THttpClientSocket;
begin
  result := '';
  Http := OpenHttp(server,port); <--- next see OpenHttp declaration
  if Http<>nil then
  try
    if Http.Get(url)=200 then
      result := Http.Content;
  finally
    Http.Free;
  end;
end;

function OpenHttp(const aServer, aPort: AnsiString): THttpClientSocket;
begin
  try
    result := THttpClientSocket.Open(aServer,aPort); <--- next see Open declaration
  except
    on ECrtSocket do
      result := nil;
  end;
end;
function Open(const aServer, aPort: AnsiString): TCrtSocket;
begin
  try
    result := TCrtSocket.Open(aServer,aPort);
  except
    on ECrtSocket do
      result := nil;
  end;
end;

constructor Open(const aServer, aPort: AnsiString; aLayer: TCrtSocketLayer=cslTCP; aTimeOut: cardinal=5000); <--- bingo find aTimeOut parameters and set 15000 and work fine.

#89 Re: mORMot 1 » getHTTP problem » 2014-02-04 06:15:29

hi again, it work fine for normal sites, but if i load slow sites i raised exception class ECrtSocket with message 'SockRecvLn 1'.
site slow load in browser 6-10 second, but load!
http://kobsme.dzo-kostroma.ru/index.php?page_id=3
my project - free infomat for medical institutions, please help how load data from slow site

#90 Re: mORMot 1 » My mORMot Videos » 2013-12-17 07:44:58

may be stick this topic?
maybe other user too post videos in this topic

#91 mORMot 1 » Fastest way to delete from a large table » 2013-10-10 07:44:11

noobies
Replies: 1

dont see drop table method, current realization

Database.EngineExecute('delete from Products');
VacuumBase;


procedure VacuumBase;
begin
  with TSQLRestClientDB(Database).Server do begin
    DB.Lock('');
    try
      EngineExecuteAll('VACUUM');
    finally
      DB.UnLock;
    end;
  end;
end;

but i think drop table and recreate table more faster?

#92 Re: mORMot 1 » Writing Blobs in BatchModes » 2013-10-10 04:48:28

ab wrote:

I've just added a new optional CustomFields parameter to TSQLRestClientURI.BatchUpdate() and BatchAdd() methods.
See http://synopse.info/fossil/info/56f240ed05

It would be able to do directly what you expect to do.
smile

great, but I do not understand how to use this opportunity

my current realization

  TSQLProduct = class(TSQLRecord)
  private
    fCategory: Integer;
    fPath, fName, fWeight: string;
    fPicture: TByteDynArray;
  published
    property category: Integer read fCategory write fCategory;
    property path:       string read fPath       write fPath;
    property name:    string read fArtikul    write fArtikul;
    property weight:     string read fWeight     write fWeight;
    property picture: TByteDynArray read fPicture write fPicture;
  end;

...

  if Database.TransactionBegin(TSQLProduct) then
  try
    Database.BatchStart(TSQLProduct);

    cat_id := 1;
    d := SetPathSep([TDirectory.GetCurrentDirectory, 'zl', 'valuables']);
    for directory in TDirectory.GetDirectories(d, TSearchOption.soTopDirectoryOnly, nil) do begin
      for f in TDirectory.GetFiles(Directory) do begin
        prd := TSQLProduct.Create;
        try
          with prd do begin
            category := cat_id;
            path := ExtractRelativePath(d, f);
            GetInfoFromFileName;
            name := sl[0];
            weight  := sl[1];
            ms := TMemoryStream.Create;
            try
              ms.LoadFromFile(f);
              SetLength(picBin, ms.Size);
              Move(ms.Memory^, picBin[0], ms.Size);
            finally
              ms.Free;
            end;
            picture := picBin;

            Database.BatchAdd(prd, True);
          end;
        finally
          FreeAndNil(prd);
        end;
      end;
      Inc(cat_id);
    end;
    Database.BatchSend(ids);
    Database.Commit;
  except
    Database.RollBack;
  end;

I deliberately removed checks for the existence of records, as each time the database will be clear.
after approv base will not be changing.

#94 Re: mORMot 1 » Writing Blobs in BatchModes » 2013-10-09 11:01:15

in sample i trying set DataBase.ForceBlobTransfert := True; but nothing happend
how correct allow blob batch mode?

ab wrote:

Updating BLOB fields should already be available, if you retrieve the fields using a FillPrepare (since updated fields will follow the one retrieved with the FillPrepare).

i try use this code  but it too not work

  if Database.TransactionBegin(TSQLProduct) then
  try
    Database.BatchStart(TSQLProduct);

    prd := TSQLProduct.Create;
    try
      prdtable := Database.ExecuteList([TSQLProduct], 'select * from product');
      prd.FillPrepare(prdtable);
      while prd.FillOne do
        with prd do begin
          pic := '';
          g := TPicture.Create;
          g.LoadFromFile(prd.pathtofile);
          SaveAsRawByteString(g, pic, gptJPG);
          picture := pic;
          Database.BatchUpdate(prd);
        end;
      finally
        FreeAndNil(prd);
      end;

    Database.BatchSend(ids);
    Database.Commit;
  except
    Database.RollBack;
  end;

#95 Re: mORMot 1 » Writing Blobs in BatchModes » 2013-10-09 10:00:06

i too try add images in batch mode, but blob field is null
how fast add many records with one image in blob?
i write simple sample with 1 record, but me need add about 2000-4000 record
https://www.dropbox.com/s/5j07635nwt387 … om_base.7z

#96 Re: mORMot 1 » FishFacts for mORMot » 2013-04-25 09:04:26

indeed it would be great to already have some videos, but unfortunately there is no source projects.
It would be possible to add them to the branch samples repository.

#97 Re: mORMot 1 » Remote Filtering using mORMot with ExtJS » 2013-04-03 09:24:08

Yes, I can share this project, but I don't have any repository... send by email?

thanks, may be post source on github?

#98 mORMot 1 » Third-party Samples » 2013-03-04 05:00:17

noobies
Replies: 5

I think it very good idea create samples repository or Sticky topic with samples.

Few old demo posted on this forum:
Drives by gclaxton
http://synopse.info/forum/viewtopic.php?id=329

Record generator tool by migajek
http://synopse.info/forum/viewtopic.php?id=350

Demo application (users-customer-task-roles) by migajek
http://synopse.info/forum/viewtopic.php?id=164

LiveBindingsFireMonkey by AntonE
http://synopse.info/forum/viewtopic.php?id=1115

#99 Re: mORMot 1 » getHTTP problem » 2013-02-22 12:04:15

i have some problem. (XE2 and XE3 on latest source)
may be you write small sample of httpget:
1) get xml
2) get jpeg

#100 Re: mORMot 1 » Save and load PNG image » 2012-11-07 12:01:17

if try assign png runtime from file or pngimagecollection i see png
too dont understand why enable Gdip.RegisterPictures; dont show png

Board footer

Powered by FluxBB