You are not logged in.
@ab
Because I do not understand how to make an example without using generics in fmx
@mvp
my pull first commit
https://github.com/synopse/mORMot/pull/99
i think be a cool if u add Project04ClientFMX.dpr to sample source folder
hi, i try create sample use example https://synopse.info/forum/viewtopic.php?id=1115
and all be ok, but i find new function
function ToObjectList<T: TSQLRecord>: TObjectList<T>; overload;
and try to use it, but function not works fine, only get all records but not data in fields
i try debug and find forgot RecordType
function ToObjectList<T: TSQLRecord>(RecordType: TSQLRecordClass=nil): TObjectList<T>; overload;
AB pls add
Type
TSQLRest = class
...
function RetrieveList(Table: TSQLRecordClass; const FormatSQLWhere: PUTF8Char;
const BoundsSQLWhere: array of const;
const aCustomFieldsCSV: RawUTF8=''): TObjectList<TSQLRecord>; overload;
...
function TSQLRest.RetrieveList(Table: TSQLRecordClass; const FormatSQLWhere: PUTF8Char;
const BoundsSQLWhere: array of const;
const aCustomFieldsCSV: RawUTF8=''): TObjectList<TSQLRecord>;
var SQL: RawUTF8;
T: TSQLTable;
begin
result := nil;
if (self=nil) or (Table=nil) then
exit;
T := MultiFieldValues(Table,aCustomFieldsCSV,FormatSQLWhere,BoundsSQLWhere);
if T<>nil then
try
result := T.ToObjectList<TSQLRecord>(Table);
finally
T.Free;
end;
end;
and fix function to ToObjectList<T: TSQLRecord>
function ToObjectList<T: TSQLRecord>(RecordType: TSQLRecordClass=nil): TObjectList<T>; overload;
...
function TSQLTable.ToObjectList<T>(RecordType: TSQLRecordClass=nil): TObjectList<T>;
var R,Item: TSQLRecord;
Row: PPUtf8Char;
i: integer;
begin
result := TObjectList<T>.Create; // TObjectList<T> will free each T instance
if (self=nil) or (fRowCount=0) then
exit;
R := RecordType.Create;
// R := TSQLRecordClass(T).Create;
try
R.FillPrepare(self);
Row := @fResults[FieldCount]; // Row^ points to first row of data
result.Count := fRowCount;
for i := 0 to fRowCount-1 do begin
// Item := TSQLRecordClass(T).Create;
Item := RecordType.Create;
{$ifdef ISDELPHIXE3}
PPointerArray(result.List)[i] := Item; // faster than manual Add()
{$else}
Result.Add(Item);
{$endif}
R.fFill.Fill(pointer(Row),Item);
Item.fInternalState := Self.InternalState; // Filling InternalState property
Inc(Row,FieldCount); // next data row
end;
finally
R.Free;
end;
end;
all sample project is based on a project (04 - HTTP Client-Server) by add Project04ClientFMX.dpr
https://www.dropbox.com/sh/64f4j4akzp8r … D-Y7a?dl=0
hi, AntonE sample link is broken, can u reupload sample, ty
polidados, pls share sample then u solve problem, i have too problem collation with russian letter(
To Chaa
i cant, in real code many operation before i get final RawUTF8 string, and next i run ExecuteNoResult
but i find answer, i change source code SybCommons adding parameter JSONEscape: TTextWriterKind = twJSONEscape
function FormatUTF8(const Format: RawUTF8; const Args, Params: array of const;
JSONFormat: boolean=false; JSONEscape: TTextWriterKind = twJSONEscape): RawUTF8; overload;
...
function FormatUTF8(const Format: RawUTF8; const Args, Params: array of const; JSONFormat: boolean; JSONEscape: TTextWriterKind): RawUTF8; overload;
{$ifndef NOVARIANTS}
if JSONFormat and (Params[P].VType=vtVariant) then
VariantSaveJSON(Params[P].VVariant^,JSONEscape,tmp[tmpN]) else //<==== change parameter
{$endif}
begin
VarRecToUTF8(Params[P],tmp[tmpN]);
wasString := not (Params[P].VType in NOTTOQUOTE[JSONFormat]);
if wasString then
if JSONFormat and (JSONEscape = twJSONEscape) then //<==== add additional parameter
QuotedStrJSON(tmp[tmpN],tmp[tmpN]) else
tmp[tmpN] := QuotedStr(pointer(tmp[tmpN]),'''');
if not JSONFormat then begin
inc(L,4); // space for :():
include(inlin,tmpN);
end;
end;
i think it best solution on this time. Ty Chaa!
To Chaa
Yea, u right, but i used execute to insert in dbf file, if i set false - no one sql command run (ado dont understand : (...) : tokens), if set Yes - symbol \ dubles
FormatUTF8 should 2 parameter array ([] - for default, [JSON] - for JSON, [none] - without any change or use [] for none and [Token] for current behavior)
Simple fix
r := FormatUTF8('insert into ' + dbf_TFOMS4 + ' (SNILS_DOCT, POST_DOCT, OBR_SVED, CERT_NUM, CERT_DATE, PRVS) VALUES (?, ?, ?, ?, ?, ?)', [], [ss, post_rmis, edu_s, cer_num, cer_date, prvs_rmis], True);
r := string(r).Replace('\\', '\', [rfReplaceAll]);
database_dbf.ExecuteNoResult(r, []);
but may be in foture ab can change parameter FormatUTF8 add option without any change
r := FormatUTF8('insert into ' + dbf_TFOMS4 + ' (SNILS_DOCT, POST_DOCT, OBR_SVED, CERT_NUM, CERT_DATE, PRVS) VALUES (?, ?, ?, ?, ?, ?)', [], [ss, post_rmis, edu_s, cer_num, cer_date, prvs_rmis], True);
database_dbf.ExecuteNoResult(r, []);
edu_s contains in text character \, after FormatUTF8, it turns out \\ and an error occurs when running ExecuteNoResult.
In this case, if you run the query without FormatUTF8 with the generated string with one \ error, it does not pass.
Why FormatUTF8 doubles \?
absolutly not easy, i try convert ExtJS 4 sample to ExtJS 6 and cant do it(((
Hope any member mormot forum, sometimes create simple sample with ExtJS 6 based on MVVC
Hi all, i start learn web with mormot.
i modificate sample 18 to work with webserver using sample 30.
https://www.dropbox.com/s/mljuhvkt3475w … id.7z?dl=0
without auth sample work perfect (http://localhost:8092/web/default) and i see extjs grid with data, but if delete database and change
DB := TSQLRestServerDB.Create(Model, ChangeFileExt(paramstr(0),'.db3'), False);
to
DB := TSQLRestServerDB.Create(Model, ChangeFileExt(paramstr(0),'.db3'), True); //Create DB with auth
and try auth with standart login and password (Admin, synopse) and success login i get error in logs
20170406 08163601 - 00.001.422
20170406 08163606 + mORMotSQLite3.TSQLRestServerDB(027E31F0).URI(GET web/SampleRecord/?SELECT=*&page=1&start=0&limit=10 inlen=0)
20170406 08163606 auth mORMot.TSQLRestRoutingREST(047EFCD0) AuthenticationFailed(afInvalidSignature) for web/SampleRecord/?SELECT=*&page=1&start=0&limit=10 (session=0)
20170406 08163606 debug mORMotSQLite3.TSQLRestServerDB(027E31F0) TSQLRestRoutingREST.Error: { "errorCode":403, "errorText":"Authentication Failed: Invalid signature (0)" }
20170406 08163606 srvr mORMotSQLite3.TSQLRestServerDB(027E31F0) GET web/SampleRecord -> 403 with outlen=82 in 4406 us
20170406 08163606 - 00.010.922
i read forum and find post https://synopse.info/forum/viewtopic.php?pid=2995#p2995
with sample auth with extjs, but i only start learn and dont understand how combine code auth extjs from albanirneves to sample 18.
Can any help me? Thank you.
fix bug in source
Hi, thx for sample.
I try change project to work with webserver mormot, here link changed source: https://www.dropbox.com/s/pq73gosbf3rma … ws.7z?dl=0
Login: User
Pass: synopse
s := FormatUTF8(SELECT * from lm where code = ?', [], ['101'], False);
//s = 'SELECT * from lm where code = :(''101''):'
qry := database_oledb.MainConnection.NewStatementPrepared(s, True);
//not work, reason - not MSSQL syntax
//error Project client.exe raised exception class EOleDBException with message 'TOleDBConnection: OLEDB Error 80040E14 - Incorrect syntax near the structure ":".'.
s := FormatUTF8(SELECT * from lm where code = ?', [], ['101'], True);
//s = 'SELECT * from lm where code = "101"'
qry := database_oledb.MainConnection.NewStatementPrepared(s, True);
//not work, reason - different quotechar
//error Project client.exe raised exception class EOleDBException with message 'TOleDBConnection: OLEDB Error 80040E14 - Invalid column name "101".'.
if change source to ' quotechar query fork fine
procedure QuotedStrJSON(const aText: RawUTF8; var result: RawUTF8);
var i: integer;
begin
for i := 1 to length(aText) do
case aText[i] of
#0..#31,'\','"':
with TTextWriter.CreateOwnedStream do
try
Add('"');
AddJSONEscape(pointer(aText));
Add('"');
SetText(result);
exit;
finally
Free;
end;
end;
// if we reached here, no character needs to be escaped in this string
result := ''+aText+''; //<= CHANGED
end;
i wont use FormatUTF8 and get string s = 'SELECT * from lm where code= ''101'''
i connect to MSSQL server and run query
s :=
'SELECT distinct st.StateNumber ' +
'FROM T_STATE st ' +
'LEFT JOIN T_LPU_MAIN lm on st.LpuMain = lm.LpuID ';
s := FormatUTF8(s + sql_where + 'lm.TFomsCode = ? AND lm.TFomsCode <> ?', [], [TFomsCode, '101'], True);
qry := database_oledb.MainConnection.NewStatementPrepared(s, True);
and get error "TFomsCode" and "101" not column in database. I search source and find function QuotedStrJSON
procedure QuotedStrJSON(const aText: RawUTF8; var result: RawUTF8);
var i: integer;
begin
for i := 1 to length(aText) do
case aText[i] of
#0..#31,'\','"':
with TTextWriter.CreateOwnedStream do
try
Add('"');
AddJSONEscape(pointer(aText));
Add('"');
SetText(result);
exit;
finally
Free;
end;
end;
// if we reached here, no character needs to be escaped in this string
result := '"'+aText+'"';
end;
problem in quotechar = ", if replace last result to
result := string(aText).QuotedString;
or
result := ''+aText+'';
all work fine, ab can u add in procedure FormatUTF8 parameter QuoteChar?
ab, can u add RowCount, i want get rowcount from select like
qry := database_oledb.MainConnection.NewStatementPrepared(sql, True);
qry.ExecutePreparedAndFetchAllAsJSON(false, buf);
i := qry.RowCount;
i small modifity source by add RowCount like ColumnCount
ISQLDBRows = interface
...
function RowCount: integer;
...
TSQLDBStatement = class(TInterfacedObject, ISQLDBRows, ISQLDBStatement)
...
fRowCount: integer;
...
function RowCount: integer;
...
function TSQLDBStatement.RowCount: integer;
begin
if self=nil then
result := 0 else
result := fTotalRowsRetrieved;
end;
any idea?
Batch mode add record is best performance or have other ways?
procedure Fill_RMIS_REG_PN;
var
i: Integer;
batch: TSQLRestBatch;
r: TSQLReg;
s: string;
begin
qry := database_oledb.MainConnection.NewStatementPrepared(sql_pn, True);
qry.Bind(1, 1); //T_REGISTRATION.Status = 1
qry.Bind(2, 2); //T_REGISTRATION_CANCEL.Status <> 2
qry.Bind(3, 0); //T_REGISTRATION.AttachmentStatus > 0
qry.Bind(4, 1); //T_REGISTRATION.Profile in (1, 2)
qry.Bind(5, 2); //T_REGISTRATION.Profile in (1, 2)
qry.Bind(6, 101); //T_STATE.StateNumber <> 101
qry.ExecutePreparedAndFetchAllAsJSON(false, buf);
tblTemp := TSQLTableJSON.Create('', buf);
batch := TSQLRestBatch.CreateTSQLRestBatch.Create(ServerDB, TSQLReg, 10000);
for i := 0 to tblTemp.RowCount - 1 do begin
s := tblTemp.getU(i, 0); //GUID
r := TSQLReg.Create;
try
r.PatientId := s;
r.TFomsCode := tblTemp.getU(i, 1);
r.SNILS := tblTemp.getU(i, 2);
r.PolicyOmsNumber := tblTemp.GetU(i, 3);
r.LastName := tblTemp.GetU(i, 4);
r.FirstName := tblTemp.GetU(i, 5);
r.FatherName := tblTemp.GetU(i, 6);
r.Sex := tblTemp.GetU(i, 7);
r.Birthday := DateOf(tblTemp.GetAsDateTime(i, 8));
r.Address := tblTemp.GetU(i, 9);
r.Diff := tblTemp.GetAsInteger(i, 10);
if r.ID = 0 then batch.Add(r, True);
finally
r.Free;
end;
end;
ServerDB.BatchSend(batch);
batch.Free;
end;
how speedup insert?
SOLVED!
1) install psqlodbc_09_05_0400-x86
2) copy all files from "c:\Program Files (x86)\psqlODBC\0905\bin\" into 15 - External DB performance folder
mormot - latest source
zeos - latest 7.2 from https://github.com/svn2github/ZeosLib/t … esting-7.2
zeos 7.3 same result
installed PostgreSQL-9.6.1-1-win64-bigsql.exe
but if i put into folder not renamed libpq74.dll i get error (lib from "c:\Program Files\PostgreSQL\pg96\bin\libpq.dll" )
Project PerfTest.exe raised exception class Exception with message 'Client-Library libpq.dll found but could not be loaded. Check compile-target and library compatibility!'.
i try donwload x32 (postgresql-9.6.1-1-windows-binaries.zip) and x64 (postgresql-9.6.1-1-windows-x64-binaries.zip) version dll always "Client-Library libpq.dll found but could not be loaded. Check compile-target and library compatibility!"
run sample 15 - External DB performance
1) install latest postgresql (PostgreSQL 9.6.1 on x86_64-pc-mingw64, compiled by gcc.exe (Rev5, Built by MSYS2 project) 4.9.2, 64-bit)
2) uncomment
{$define USEZEOS}
{$define USEFIREDAC}
3) comment all except Postresql
4) install odbc and setup
5) put \zeoslib\lib\postgresql\libpq74.dll into 15 - External DB performance folder and rename to libpq.dll
6) run
odbc test success
firedac test success
zeos test failed
Project PerfTest.exe raised exception class EZSQLException with message 'SQL Error: ERROR: prepared statement "518270435119021832" does not exist'.
press continue on error and next exception
Project PerfTest.exe raised exception class ESQLite3Exception with message 'Error SQLITE_ERROR (1) [Step] using 3.15.2 - SQL Error: ERROR: prepared statement "518270435119021832" does not existrthDate,, extended_errcode=1'.
press continue on error and next exception
Project PerfTest.exe raised exception class ESQLite3Exception with message 'Error SQLITE_ERROR (1) [drop table Sample] using 3.15.2 - no such table: Sample, extended_errcode=1'.
where i wrong?
after analize search copypast misstake in naming fCommand as ISSCommandWithParameters and need simple change to ICommandWithParameters
ICommandWithParameters = interface(IUnknown)
['{0C733A64-2A1C-11CE-ADE5-00AA0044773D}']
function GetParameterInfo(var pcParams: UINT; out prgParamInfo: PDBPARAMINFO;
ppNamesBuffer: PPOleStr): HResult; stdcall;
function MapParameterNames(cParamNames: UINT; rgParamNames: POleStrList;
rgParamOrdinals: PUintArray): HResult; stdcall;
function SetParameterInfo(cParams: UINT; rgParamOrdinals: PUintArray;
rgParamBindInfo: PDBParamBindInfoArray): HResult; stdcall;
end;
ISSCommandWithParameters = interface(ICommandWithParameters)
['{EEC30162-6087-467C-B995-7C523CE96561}']
function GetParameterProperties(var pcParams: PtrUInt; var prgParamProperties: PSSPARAMPROPS): HResult; stdcall;
function SetParameterProperties (cParams: PtrUInt; prgParamProperties: PSSPARAMPROPS): HResult; stdcall;
end;
code before
OleDBConnection.OleDBCheck(self,
(fCommand as ISSCommandWithParameters).SetParameterInfo( //COPYPAST ERROR?
fParamCount, pointer(fParamOrdinals), pointer(fParamBindInfo)));
if ssParamPropsCount>0 then
OleDBConnection.OleDBCheck(self,
(fCommand as ISSCommandWithParameters).SetParameterProperties(
ssParamPropsCount, pointer(ssParamProps)));
code after
OleDBConnection.OleDBCheck(self,
(fCommand as ICommandWithParameters).SetParameterInfo( //COPYPAST ERROR?
fParamCount, pointer(fParamOrdinals), pointer(fParamBindInfo)));
if ssParamPropsCount>0 then
OleDBConnection.OleDBCheck(self,
(fCommand as ISSCommandWithParameters).SetParameterProperties(
ssParamPropsCount, pointer(ssParamProps)));
if change work fine
sorry my bad eng, I read the previous post and realized that he put it incorrectly.
interesting, i try run sample on 2 pc and 2 servers work well
It means that the 1 button works correctly on all 4 computers
I suspect the dbf driver does not support the parametrized queries.
This is what "interface not supported means".
I do not think so (commenting 3 lines in source code framework of check make the code work), and standart Delphi way by ADOCommand support parameters, but i think FormatUTF8 and execute inline completely suits me.
Thanks for all reply this post.
interesting, i try run sample on 2 pc and 2 servers work well
if put first button visual no changes, but string '111' add to field CERT_NUM in record with SNILS = '124-864-626 74'
P.S. need unzip folder, before run exe file, connection string get base from folder where run exe file.
fix first error add 4 parameter true in FormatUTF8
2: begin
r := FormatUTF8('update postcert SET CERT_NUM = ? where SNILS_DOCT = ?', [], [cer_num, ss], True);
database_dbf.ExecuteNoResult(r, []); //no error
end;
r contain 'update postcert SET CERT_NUM = "111" where SNILS_DOCT = "124-864-626 74"'
second error fixed if correct set second parameters to false (no expect result) and comment 3 lines in SynOleDB
if not OleDBConnection.OleDBProperties.fSupportsOnlyIRowset then begin
// OleDBConnection.OleDBCheck(self,
// (fCommand as ISSCommandWithParameters).SetParameterInfo(
// fParamCount, pointer(fParamOrdinals), pointer(fParamBindInfo)));
dont understand why OleDBCheck run 'Interface not supported'.
pls fix OleDBCheck
I changed the project, but the error is still present
var
database_dbf: TOleDBConnectionProperties;
const
ADOProviderJet = 'Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;Persist Security Info=False;Mode=ReadWrite;Data Source=';
procedure TForm1.Button1Click(Sender: TObject);
var
path, ss, edu, cer_num: RawUTF8;
r: RawUTF8;
begin
path := IncludeTrailingPathDelimiter(TDirectory.GetParent(ParamStr(0)));
database_dbf := TOleDBConnectionProperties.Create('','','','');
database_dbf.ConnectionString := ADOProviderJet + path;
cer_num := '111';
ss := '124-864-626 74';
case TButton(Sender).Tag of
1: begin
r := 'update POSTCERT SET CERT_NUM = "' + cer_num + '" where SNILS_DOCT = "' + ss + '"';
database_dbf.ExecuteNoResult(r, []); //work fine
end;
2: begin
r := FormatUTF8('update postcert SET CERT_NUM = ? where SNILS_DOCT = ?', [], [cer_num, ss]);
database_dbf.ExecuteNoResult(r, []); //error
end;
3: begin
with database_dbf.NewThreadSafeStatementPrepared('update postcert SET CERT_NUM = ? where SNILS_DOCT = ?', True, True) do begin
BindTextS(1, cer_num);
BindTextS(2, ss);
ExecutePrepared; //error
end;
end;
end;
end;
first button: work fine
second button: Project Parameters.exe raised exception class EOleDBException with message 'TOleDBConnection: OLEDB Error 80040E14 - Ошибка синтаксиса (пропущен оператор) в выражении запроса ':('111'):'.'.
third button: Project Parameters.exe raised exception class EIntfCastError with message 'Interface not supported'.
link to updated sample project with dbf and exe
https://www.dropbox.com/s/sdiq1a6z6a1ug … rs.7z?dl=0
yea, see my sample, first ExecuteNoResult work fine and in dbf in field CERT_NUM put 111. But next 2 command work with error.
code from sample
var
database_dbf: TOleDBConnectionProperties;
const
ADOProviderJet = 'Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;Persist Security Info=False;Mode=ReadWrite;Data Source=';
procedure TForm1.Button1Click(Sender: TObject);
var
path, ss, edu: RawUTF8;
cer_num: Integer;
r: RawUTF8;
begin
path := IncludeTrailingPathDelimiter(TDirectory.GetParent(ParamStr(0)));
database_dbf := TOleDBConnectionProperties.Create('','','','');
database_dbf.ConnectionString := ADOProviderJet + path;
cer_num := 111;
ss := '124-864-626 74';
r := 'update POSTCERT SET CERT_NUM = "' + cer_num.ToString + '" where SNILS_DOCT = "' + ss + '"';
database_dbf.ExecuteNoResult(r, []); //work fine
//comment next 2 row to get second error
r := FormatUTF8('update postcert SET CERT_NUM = ? where SNILS_DOCT = ?', [], [cer_num, ss]);
database_dbf.ExecuteNoResult(r, []); //error
r := FormatUTF8('update postcert SET CERT_NUM = ? where SNILS_DOCT = ?', [], [cer_num, ss]);
with database_dbf.NewThreadSafeStatementPrepared('update postcert SET CERT_NUM = ? where SNILS_DOCT = ?', True, True) do begin
BindVariant(1, cer_num, True);
BindTextS(2, ss);
ExecutePrepared; //error
end;
end;
sample project
https://www.dropbox.com/s/sdiq1a6z6a1ug … rs.7z?dl=0
firsrt error
Project Parameters.exe raised exception class EOleDBException with message 'TOleDBConnection: OLEDB Error 80040E14 - Ошибка синтаксиса (пропущен оператор) в выражении запроса ':(111):'.'.
second error
Project Parameters.exe raised exception class EIntfCastError with message 'Interface not supported'.
Hi all, need advice i have some working code
const
ADOProviderJet = 'Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;Persist Security Info=False;Mode=ReadWrite;Data Source=';
...
database_dbf := TOleDBConnectionProperties.Create('','','','');
database_dbf.ConnectionString := ADOProviderJet + path_imp;
...
r := 'update POSTCERT SET OBR_SVED = "' + edu_s + '" where SNILS_DOCT = "' + ss + '"';
database_dbf.ExecuteNoResult(r, []); //work fine
i try use parameters but code not work.
...
r := FormatUTF8('update postcert SET CERT_NUM = ? where SNILS_DOCT = ?', [], [cer_num, ss]);
database_dbf.ExecuteNoResult(r, []); //error
...
r := FormatUTF8('update postcert SET CERT_NUM = ? where SNILS_DOCT = ?', [], [cer_num, ss]);
with database_dbf.NewThreadSafeStatementPrepared('update postcert SET CERT_NUM = ? where SNILS_DOCT = ?', True, True) do begin
BindTextS(1, cer_num);
BindTextS(2, ss);
ExecutePrepared; //error
end;
Not free - only special offer up to 9 semptember 16
i created inheriting class from TSQLAuthUser
TSQLUser = class(TSQLAuthUser)
private
fMO: TSQLMO;
fRole: TUserRole;
fMOReadOnly: Integer;
fDateB, fDateE: TDateTime;
published
property MO: TSQLMO read fMO write fMO;
property Role: TUserRole read fRole write fRole;
property MOReadOnly: Integer read fMOReadOnly write fMOReadOnly;
property DateB: TDateTime read fDateB write fDateB;
property DateE: TDateTime read fDateE write fDateE;
end;
and add it to model
Result := TSQLModel.Create([TSQLAuthGroup, TSQLUser, ... ]);
in auth i have code
if not ClientRest.SetUser(login, password) then Exit;
u := TSQLUser.Create(ClientRest, 'LogonName = ? and Date(DateE) is Null', [login]);
try
if u.ID <> 0 then begin
...
finally
u.Free;
end;
if GroupRights of auth client = 2 (supervisor) all ok - supervisor have right to read AuthUser table, but if i set GroupRights = 3 (user) not have permission.
i try
u := TSQLUser(ClientRest.SessionUser);
but in this case i not have all additional TSQLUSER fields (MO, Role, MOReadOnly, DateB, DateE)
how can i get additional TSQLUSER fields from class inheriting from TSQLAuthUser?
any find answer?
i too want create small web part with 2 button, each button only generate and download excel file.
docwiki.embarcadero.com/RADStudio/Seattle/en/What's_New
New Clang-based C++ Compiler for 32-bit Windows
BCC32C and BCC64, Clang-based C++ compilers for Windows, are both updated to Clang 3.3 and LLVM 3.3.
thx, i install home xe8u1, and compile sample 15 all work fine. problem in work pc. Next time before post question i test in home and work.
in xe7 test work fine in latest version. but in xe8u1 dont.
OK, thanks i solve problem delete if Rest.TransactionBegin(TSQLDiagnose) (in post #5) then but u new create "test" and this test get error in my pc i tomorrow try compile sample in xe7 and some more tests.
in latest mormot
procedure TSQLRest.Commit(SessionID: cardinal; RaiseException: boolean);
begin
if self<>nil then begin
fAcquireExecution[execORMWrite].Safe.Lock; //FREEZE here
try
if (fTransactionActiveSession<>0) and
(fTransactionActiveSession=SessionID) then begin
fTransactionActiveSession := 0; // by default, just release flag
fTransactionTable := nil;
end;
finally
fAcquireExecution[execORMWrite].Safe.UnLock;
end;
end;
end;
i comment
// fAcquireExecution[execORMWrite].Safe.Lock;
...
// fAcquireExecution[execORMWrite].Safe.UnLock;
and commit work fine
in 1440 mormot this procedure have another syntax
procedure TSQLRest.Commit(SessionID: cardinal; RaiseException: boolean);
begin
if self<>nil then begin
fAcquireExecution[execORMWrite].Enter;
try
if (fTransactionActiveSession<>0) and
(fTransactionActiveSession=SessionID) then begin
fTransactionActiveSession := 0; // by default, just release flag
fTransactionTable := nil;
end;
finally
fAcquireExecution[execORMWrite].Leave;
end;
end;
end;
in my code in first post i delete
if Rest.TransactionBegin(TSQLDiagnose) then
and all work fine,
but intresting why not work test in 15 - External DB performance, but in old 1440 version test work fine
Delphi XE8U1
intresting test, i download latest version and run test with 100 count
records prepared but not inserting - program FREEZE
Prepared 100 rows in 312us
FREEZE
if comment test and uncomment test2
Prepared 100 rows in 339us
Inserted 100 rows in 10.93ms i.e. 9144 per second
in ids[] after BatchSend i see
(1, 2, 3, 4, 5,...
after change mormot to old 1440 and run u sample (15 - External DB performance) test work fine (and test2 too)
Prepared 100 rows in 390us
Inserted 100 rows in 9.37ms i.e. 10663 per second //test
Prepared 100 rows in 374us
Inserted 100 rows in 11.32ms i.e. 8832 per second //test2
i put 2 exe compiled 15 - External DB performance sample with 1440 and latest version framework to u see problem
https://www.dropbox.com/sh/vy1hm8mr550w … 8zlGa?dl=0
today i compile my code with latest version and Butch not work (after butch program run, i see fields have data isnerting and work fine, close program, but data dont save in base, db3 20kb (except 1,2mb if compile with version 1440))
i have some backup version framework, 1622 not work too, but 1440 work fine
Now more info:
i try add to base diagnoses from csv file in batch mode
InitClient(not TFile.Exists(path_app + DBFile));
function CreateDataModel: TSQLModel;
begin
result := TSQLModel.Create([TSQLDataRecord, TSQLDiagnose, TSQLOptions]);
end;
procedure InitClient(LoadData: Boolean = False);
begin
Model := CreateDataModel;
Rest := TSQLRestClientDB.Create(Model, CreateDataModel, ChangeFileExt(paramstr(0), '.db3'), TSQLRestServerDB);
TSQLRestClientDB(Rest).Server.CreateMissingTables(0);
if LoadData then TSQLDiagnose.CreateDiagnoses(Rest);
end;
class procedure TSQLDiagnose.CreateDiagnoses(const ARest: TSQLRest);
var
i: integer;
diagnose: TSQLDiagnose;
sl, slES: TStringlist;
ids: TIDDynArray;
begin
sl := TStringList.Create;
sl.LoadFromFile('MKB10.csv');
slES := TStringList.Create;
if Rest.TransactionBegin(TSQLDiagnose) then
try
Rest.BatchStart(TSQLDiagnose);
for i := 0 to sl.Count - 1 do begin
slES.Clear;
ExtractStrings([';'], [' '], PChar(sl.Strings[i]), slES);
diagnose := TSQLDiagnose.Create(Rest, 'Code = ?', [slES.Strings[0]]);
try
if diagnose.ID = 0 then begin
diagnose.Code := slES.Strings[0];
diagnose.Desc := slES.Strings[1];
Rest.BatchAdd(diagnose, True);
end
finally
FreeAndNil(diagnose);
end;
end;
Rest.BatchSend(ids);
Rest.Commit;
except
Rest.RollBack;
end;
end;
this code work fine in version 1440 and create base 1.2mb, but in new version created 20kb blank base.
thanks, all work fine
i fix it, add this before create drawgrid
tblList.SetFieldType('dr', sftDateTime, nil, -1);
but i dont understand why if i define dr as TDatetime and this field contain only date not considered sftDateTime in this code new version framework
result := FieldType(Field,@EnumType); //in new version return sftUTF8Text except sftDateTime
AB, please fix this problem.
i try SynDBExplorer but the problem with regional date is still there
screen shot
https://www.dropbox.com/s/dbkc5es84k8nu … m.JPG?dl=0
base
https://www.dropbox.com/s/aeweca43ezhag … h.db3?dl=0
i execute sql simple 'select dr from recs', field dr: TDateTime, in field stored data born without time. in prev version framework (1.18.1440) date show in drawgrid ok '01.01.1991', but today i get latest version and drawgrid show field dr '1991-01-01'.
datetime stored date+time view ok in latest version '01.01.1990 10.00.00' and prev too.
How change view datetime with only date to regional setting?
try this?
function TPhoMessartCommand.Select: TCQRSResult;
begin
Result := ORMSelectAll('', []);
end
i found solution from source
{$ifdef MSWINDOWS}
procedure TTimeLogBits.Expand(out Date: TSystemTime);
begin
Date.wYear := (Value shr (6+6+5+5+4)) and 4095;
Date.wMonth := 1+(Int64Rec(Value).Lo shr (6+6+5+5)) and 15;
Date.wDay := 1+(Int64Rec(Value).Lo shr (6+6+5)) and 31;
Date.wDayOfWeek := 0;
Date.wHour := (Int64Rec(Value).Lo shr (6+6)) and 31;
Date.wMinute := (Int64Rec(Value).Lo shr 6) and 63;
Date.wSecond := Int64Rec(Value).Lo and 63;
end;
{$endif}
work solution (y must be integer)
Result := sql + FormatUTF8('(r.Created >> (6+6+5+5+4)) & 4095 = ?', [], [y]);
or if y string
Result := sql + '(r.Created >> (6+6+5+5+4)) & 4095 = ' + y;
if i use InputDate: TDateTime i write
Result := sql + FormatUTF8('strftime("%Y", InputDate) = ?', ['%'], [y]);
but if i use Created: TTimeLog how get all records only 2015 year?
ab, i rewrite some code and delete sftHidden, and add only 2 line to work hide, please add this line to framework.
how use to hide column
tblList.SetFieldType('approvedate', sftDateTime, nil, 0); //set ContentSize to 0
tblList.SetFieldType('declinedate', sftDateTime, nil, 0); //set ContentSize to 0
changes
function TSQLTable.CalculateFieldLengthMean(var aResult: TIntegerDynArray;
FromDisplay: boolean=false): integer;
...
case fFieldType[F].ContentType of
...
if fFieldType[F].ContentSize = 0 then aResult[F]:=0; // ADD THIS TO WORK
inc(U); // points to next value
end;
...
for F := 0 to FieldCount-1 do begin
if aResult[F] = 0 then Continue; // ADD THIS TO WORK
...
ab, big thanks it work!
change to
Result := Result + FormatUTF8('strftime("%%Y", InputDate) = ?', [], [cbbCurrentYear.Value]);
and not work, in result: ' strftime("%Y", InputDate) = ?'
FormatUTF8 dont parse string with %% and dont change ? to
:(''2015''):
if i remove % all parse ok, but strftime not work, i think it but in FormatUTF8