#1 Re: mORMot 1 » OCI-21560 error with Delphi 10.1 x64 app » 2023-02-04 14:09:41

Similar error with oracle xe 21c, delphi 7, win64.

vProps.Execute('select item_no from items where item_no = ?',['GA-002']);

But ok, with syndb.tquery params and newthreadsafestatementprepared.

vRow:=vProps.NewThreadSafeStatementPrepared('select item_no from items where item_no=%',['''GA-002'''],true);

#2 Re: mORMot 1 » [Solved] https. Cant seem to get it to work » 2022-05-22 16:06:23

Hi,

I'm sorry, I get wrong direction.

Reserved URL            : http://+:888/root/
        User: \Everyone
            Listen: Yes
            Delegate: Yes
            SDDL: D:(A;;GA;;;WD)

I need to delete url = http... not https. I don't know how windows add that URI.
After delete it and add url = https .... finally it done.

I follow this thread step with a few modification.

Thank you.

#3 Re: mORMot 1 » [Solved] https. Cant seem to get it to work » 2022-05-22 15:53:43

dualarrow wrote:

After much googling and trail and error, I resolved the issue. Heres what I found in case anyone else has this issue.

netsh http add urlacl url=https://+:888/rpc/ user=\Everyone

again, replace the appropriate parts with your URI
This was done on a windows 10 pro OS and I have confirmed with both chrome and wireshark that the https is working correctly.

Hi,

Do you know what is the problem of this error :
TSQLHttpServer(0255EA88) http.sys URI registration error #183 for https://+:888/root stack trace API

Thank you

#4 mORMot 1 » Sample - 14 Interface-based SOA Javascript Client » 2022-05-22 02:40:35

Cahaya
Replies: 1

Dear AB,

function registerSoa(){ //access mORMot SOA
  let xhr = new XMLHttpRequest();
  let url = new URL("http://localhost:888/root/Calculator._contract_");
  signature = sessionSignature();
  url.searchParams.set("session_signature",signature);
  xhr.onload = function() {
    if (xhr.status == 200){ 
      let hasil = xhr.response;
      console.log(hasil.result[0]);
      runSoa();
    };  
  };
  xhr.open('POST', url);
  xhr.responseType = 'json';
  xhr.send();
};

Calculator._contract_ return a number. What number is it ? Do I need to use it before call Calculator.Add ?
So far I just ignore it, and send the next step, server response it.

Tq

#5 Re: mORMot 1 » About ZLib/SynLZ/Snappy/LZ4 » 2021-08-26 04:53:24

Is it compatible between lz and lzw algo ?
Is it compatible between lz compression and synlz ?

Thank you.

#6 Re: mORMot 1 » TAESCBC compatibility » 2021-08-24 08:47:01

I use manual IV based on PHP script and success.
Here is code for manual IV :

procedure TForm1.Button5Click(Sender: TObject);
var
  aes: TAESCBC;
  Key: TSHA256Digest;
  s  : RawBytestring;
  iv : array[0..15] of AnsiChar;
begin
  SynCommons.HexToBin(Pointer(SHA256(my_key)),@key,32);
  SynCommons.HexToBin(Pointer(SHA256(my_key)),@iv,16);
  aes := TAESCBC.Create(Key,256);
  aes.IV := TAESBlock(iv);
  try
    s := StringToUTF8(EdEncrypt.Text);
    s := aes.DecryptPKCS7(Base64ToBin(s));
    EdToEncrypt.Text := UTF8ToString(s);
  finally
    aes.Free;
  end;
end;

#7 Re: mORMot 1 » About ZLib/SynLZ/Snappy/LZ4 » 2021-08-24 07:45:37

Lzstring same with synlz ?

(decompressFromEncodedURIComponent) any method in mormot support that ?

Thank you

#8 Re: mORMot 1 » TAESCBC compatibility » 2021-08-24 02:22:52

Mormot AES encrypt and PHP decrypt

I used this code :
  SynCommons.HexToBin(Pointer(SHA256(my_key)),@key,32);
  aes := TAESCBC.Create(Key,256);
  try
    s := StringToUTF8(EdToEncrypt.Text);
    s := BinToBase64(aes.EncryptPKCS7(s,true));
    EdEncrypt.Text := UTF8ToString(s);
  finally
    aes.Free;
  end;

And for php :

$encrypt_method = 'AES-256-CBC';

    // hash
    $key_hash = hex2bin(hash('sha256', $key));

    // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
    $iv = substr(hex2bin(hash('sha256', $key)), 0, 16);

    $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key_hash, OPENSSL_RAW_DATA, $iv);

    return $output;

Why php can not decrypt properly ?

Text : Hello world
key : testkey
encrypt : UfSnUFH0p1BR9KdQUfSnUOrKd0falUmp/hI8tik+UjU=

Php decrypt : i~UIJ8nkHello world

Please help.....

#9 Re: mORMot 1 » Issue when convert variant to TVarRec » 2015-07-25 02:32:42

Sorry AB, I will answer my own question. smile

procedure TForm1.btVariantClick(Sender: TObject);
var
   vVar : variant;
   vVarRec : TTVarRecDynArray;
   //vJsonContent : rawUTF8;
begin
  //vJSONContent := '{"customers":[{"Customer_No":1,"Name":"Cahaya Harapan"},{"Customer_No":2,"Name":"Dustin Tsai"}]}';
  //vJSONContent := '{"Customer_No":1,"Name":"Cahaya Harapan"}';
  //v := _Json(vJsonContent);
  vVar := _ArrFast([]); {Custom type of variant by mormot}
  DocVariantData(vVar)^.AddItem(1);
  DocVariantData(vVar)^.AddItem('Cahaya Harapan');
  vVarRec := DocVariantData(vVar)^.ToArrayOfConst;
  SQLValues(vVarRec);
end;

AB, I can not pass array of variant to DocVariantData.ToArrayOfConst. Is it normal because you use custom vartype in mormot variant.

Thank you alot.

#10 Re: mORMot 1 » Issue when convert variant to TVarRec » 2015-07-24 16:20:22

Hi AB,

  vJSONContent := '{"Customer_No":1,"Name":"Cahaya Harapan"}';
  v := _Json(vJsonContent);

how to convert DocVariantDataSafe(v)^.Values to array of const ? In this case [1,'Cahaya Harapan']

Thanks a lot

#11 Re: mORMot 1 » ForceID parameter inside TSQLRest » 2015-07-20 13:24:26

Here server code, please advice me.

var
  aData       : TSQLModel;
  aHTTPServer : TSQLHttpServer;
  aProps      : TSQLDBConnectionProperties;
  aRestServer : TSQLRestServerDB;
begin
  with TSQLLog.Family do begin
    Level := LOG_VERBOSE;
    EchoToConsole := LOG_VERBOSE;
    PerThreadLog := ptIdentifiedInOnFile;
  end;
  AllocConsole;
  TextColor(ccLightGray);
  aData  := DataModel;
  aProps := TSQLDBOracleConnectionProperties.Create('localhost','XE','hr','oracle');
  try
    VirtualTableExternalRegisterAll(aData,aProps);
    aRestServer := TSQLRestServerDB.Create(aData,':memory:',false);
    try
      aRestServer.AcquireExecutionMode[execORMGet]   := amBackgroundORMSharedThread;
      aRestServer.AcquireExecutionMode[execORMWrite] := amBackgroundORMSharedThread;
      aRestServer.CreateMissingTables;
      aHTTPServer := TSQLHttpServer.Create('888',[aRestServer],'+',useHttpApiRegisteringURI);
      try
        aHTTPServer.AccessControlAllowOrigin := '*'; // for AJAX requests to work
        Sleep(200); // allow all HTTP threads to be launched and logged
        writeln(#10'Background server is running.'#10);
        writeln('Press [Enter] to close the server.'#10);
        ConsoleWaitForEnterKey;
      finally
        aHTTPServer.Free;
      end;
    finally
      aRestServer.Free;
    end;
  finally
    aData.Free;
  end;
end.

My table desc,

SQL> desc countries
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 COUNTRY_ID                                NOT NULL CHAR(2)
 COUNTRY_NAME                                       VARCHAR2(40)
 REGION_ID                                          NUMBER

A new error,

20150720 20181013  B EXC   ESQLDBException {"Message":"TSQLRestStorageExternal.J
SONDecodedPrepareToSQL(TSQLCountries): No column for \"ID\" field in table Count
ries"} at 004A51C0  stack trace API 00444C96 00402E60 77C6B67F 77C20163 004A51C0
 004A4E55 004A2F45 0048E05B 00441C38 0041DFE7 00403706 7585337A 77C492E2 77C492B
5
20150720 20181013  $ EXC        ESQLDBException {"Message":"TSQLRestStorageExter
nal.JSONDecodedPrepareToSQL(TSQLCountries): No column for \"ID\" field in table
Countries"} at 00441A74  stack trace 77C3E3CC 004B1C4D 004A9613 004AD181 0041DFE
7 00403706 7585337A 77C492E2 77C492B5

RestServer always assume it needs ID field. I thought, forceID parameter is an option to use ID or not.

Thank you again.

#12 Re: mORMot 1 » ForceID parameter inside TSQLRest » 2015-07-20 01:07:49

Hi AB,

I still got an error,

20150720 08001859  B EXC   ESQLite3Exception {"ErrorCode":1,"SQLite3ErrorCode":2,"Message":"Error SQ
LITE_ERROR (1) using 3.8.10.2 - 'no such table: Countries' extended_errcode=1"} at 00498E1A  stack t
race 400030FC 40003473 400074C7 40007236 0049A4A4 00452895 0045B5CB 00456699 0045677E 00470D4B 00424
85C 75851148 004243C3 004243F0 00424439 0042447A 4003C067 40006DC6 7585337A 77C492E2 77C492B5

How to set ID property ? My TSQLRecord is,

  TSQLCountries = class(TSQLRecord) // TSQLRecord has already ID: integer primary key
  private
    fCountryID : RawUTF8;
    fName : RawUTF8;
    fRegionID : integer;
  published
    /// ORM will create a NAME VARCHAR(80) column
    property Country_Id : RawUTF8 index 2 read fCountryID write fCountryID;
    property Country_Name : RawUTF8 index 40 read fName write fName;
    property Region_Id : integer read fRegionID write fRegionID;
  end;

My client code is,

  vClient := Nil;
  vCountries := TSQLCountries.Create;
  try
    vClient := TSQLHttpClient.Create(Edit1.Text,PORT_NAME,fData);
    try
      vCountries.IDValue := 1;
      vCountries.Country_Id := StringToUTF8('ID');
      vCountries.Country_Name := StringToUTF8('Indonesia');
      vCountries.Region_Id := 3;
      vClient.Add(vCountries,True,True);
      Showmessage('Succeeded.');
    finally
      vCountries.Free;
    end;
  finally
    vClient.Free;
  end;

ID property is readonly.

Thank you.

#13 mORMot 1 » ForceID parameter inside TSQLRest » 2015-07-19 15:36:00

Cahaya
Replies: 5

Hi AB,

How to use ForceID parameter inside, function TSQLRest.Add(Value: TSQLRecord; SendData: boolean;
ForceID,DoNotAutoComputeFields: boolean): TID;

Can I obey ID field inside table ? I try to send True to ForceID, but still get an error.

Thank you very much.

#14 Re: mORMot 1 » Fast JSON parsing » 2015-07-17 16:42:57

Hi AB,

Thank you for your fast respond. By the way, is it possible to use mormot RESTful without ID field ? Or any option for it ?
If I'm not wrong, mormot will generate error if, table inside database does not have ID field.

Thank you.

#15 Re: mORMot 1 » Fast JSON parsing » 2015-07-17 15:06:03

Hi AB,

How to use GetJSONField ? Any example ? Any function to convert from JSON to DML SQL statement ?
I don't want ID field inside mormot RESTful.

An example, browser send JSON, '{"Customers:" [{"Customer_No":1,"Name":"Cahaya Harapan"}] }', and I want to change it into DML, something like "INSERT INTO Customers VALUES (?,?)" or "UPDATE Customers SET Name = ? WHERE CUSTOMER_NO = ?"

Thank you very much.

#16 Re: mORMot 1 » Issue when convert variant to TVarRec » 2015-06-30 06:37:26

Thank you AB.

It becomes,

 ShowMessage(vArrOfConst[1].vVariant^);

It is a very useful feature for passing param Query.

#17 Re: mORMot 1 » Issue when convert variant to TVarRec » 2015-06-29 15:01:30

Hi AB,

procedure TForm1.Button1Click(Sender: TObject);
var
    vBounds : variant;
    vArrOfConst : TTVarRecDynArray;
begin
  vBounds := _ArrFast([1000,'HELLO WORLD',NOW]);
  vArrOfConst := TDocVariantData(vBounds).ToArrayOfConst;

  ShowMessage(String(vArrOfConst[1].vPChar));
end;

Why I don't see "HELLO WORLD" ?

Thank you.

#18 mORMot 1 » Real world example » 2015-06-26 08:19:52

Cahaya
Replies: 1

Hi all,

I'm looking for an example "select, update and delete" application on server side and client side.
I like to use ORM, class based. I'm confuse how to use link between TSqlRecord and Table inside database oracle.

And on client side how to link data and control.

Thank you.

#19 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-25 15:21:14

I got those speed after declare FastMM4 unit. Delphi SynDBOracle vs Lazarus SynDbOracle.
Delphi is faster now.

Great job.

By the way I'm looking an article on how ORM link to vcl. With my slow brain, I did not find any real example from your lengthy pdf. smile

Thank you anyway.

#20 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-25 03:42:52

AB,

After using your RTL properly, I got an amazing speed. FetchAllAsJson boost 3x faster. Impressing.
And now, SynDbOracle is faster than Zeos, for select stmt, around 14% faster.

Amazing !

#21 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-25 01:40:30

AB,

Both between SynDB and Zeos get all data for TDataset. But of course SynDBOracle has a very nice feature, need one oci.dll only. I just guessing, both is very efficient.

Your framework is great. I'm still exploring before decide to moving my hospital apps.

#22 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-24 17:15:40

Thank you AB,

By the way I tried to test your SynDBOracle compare to Zeos, the result zeos for many times is faster around 5%.
Your blog said http://blog.synopse.info/post/2011/07/0 … cle-access, Syndboracle 10x faster.

I used delphi 7 to test it. All inside the same coding for 33.402 rows.

FetchallAsJson also slow compare to todataset. sad

#23 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-23 17:32:50

How to use your optimize RTL for delphi 7 ? I failed to run SynopseRTL042004.exe
Can I just replace my dcu with SynopseRTLdcu.zip ?

Thank you again.

#24 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-23 17:29:29

AB,

procedure TForm1.Button3Click(Sender: TObject);
var
  rows  : ISQLDBRows;
  vStr  : string;
  vStart,vEnd: dword;
begin
  try
    vStart := GetTickCount;
    rows := DB.Execute('select * from truck_trans;',[]);
    vStr := Utf8ToString(rows.FetchAllAsJSON(true));
    vEnd := GetTickCount - vStart;
    ShowMessage(IntToStr(vEnd));
  finally
    rows._Release;
    rows := nil;
    DB.Free;
  end;
end;

I work well after release ISQLDBRows and set it to nil;
By the way, I use the same code and measure performance executable between delphi 7 and lazarus 1.2.6, and I found lazarus code is faster around 4x. I use gettickcount to measure the timing.

#25 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-23 17:16:43

I did, this before as you suggested,

procedure TForm1.Button1Click(Sender: TObject);
var
  Props      : TSQLDBOracleConnectionProperties;
  rows       : ISQLDBRows;
begin
  Props := TSQLDBOracleConnectionProperties.Create('localhost','XE','scott','tiger');
  try
    rows := Props.Execute('select * from truck_trans',[]);
    rows.Step;
    Showmessage(utf8ToString(rows.ColumnUTF8(0)));
  finally
    rows := nil; // should be freed BEFORE Props
    Props.Free;
  end;
end;

I still got an error for delphi 7 but it work for lazarus 1.2.6

By the way, I can not hack my delphi 7 for system and sysutils. Is it enough if I just replace the dcu ?

Thank you.

#26 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-23 16:42:53

Did you test it, for delphi 7 ? The same problem arise when you free TSQLDBOracleConnectionProperties;
The problem is OCI.StmtRelease. Any solution ?

Thank you.

#27 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-23 16:02:53

AB,

I got the same error when I free TSQLDBOracleConnectionProperties from lazarus 1.2.6.

I think you don't get my problem. Did you test it for oracle xe ?

Thank you.

#28 Re: mORMot 1 » Sample 17, DBCommon and FPC » 2015-06-23 15:53:18

Any futher action for this issue ? I got the same problem for lazarus 1.2.6

Thank you AB.

#29 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-23 14:57:21

Your procedure TSQLDBOracleStatement.FreeHandles(AfterError: boolean) probably has problem. Because I got an error when I execute Free. The error probably because your code :

if fUseServerSideStatementCache then
      OCI.Check(nil,self,OCI.StmtRelease(fStatement,fError,nil,0,RELEASE_MODE[AfterError]),fError) else
      OCI.HandleFree(fStatement,OCI_HTYPE_STMT);

I don't understand your last posted. What sub function you mean ?

#30 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-23 03:17:44

This code is good without error. I guess something wrong with OCI.Check line.
By the way, any problem with my oracle XE 32 bit inside 64 bit windows ? In my view, my oracle database is good, but I don't know whether any connection inside your code, related to memory.

  if fStatement<>nil then begin
    {
    if fUseServerSideStatementCache then
      OCI.Check(nil,self,OCI.StmtRelease(fStatement,fError,nil,0,RELEASE_MODE[AfterError]),fError) else
      OCI.HandleFree(fStatement,OCI_HTYPE_STMT);
    }
    OCI.HandleFree(fStatement,OCI_HTYPE_STMT);
    fStatement := nil;
  end;

#31 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-23 03:01:38

Hi AB,

Your last code still error.
Something wrong with this,       OCI.Check(nil,self,OCI.StmtRelease(fStatement,fError,nil,0,RELEASE_MODE[AfterError]),fError) else
      OCI.HandleFree(fStatement,OCI_HTYPE_STMT);

Delphi 7 debug come to that line when Props.Free execute.

Thank you.

#32 Re: mORMot 1 » Get Start with SynDBOracle » 2015-06-22 16:16:59

procedure TForm1.Button1Click(Sender: TObject);
var
  Props      : TSQLDBOracleConnectionProperties;
  rows       : ISQLDBRows;
begin
  Props := TSQLDBOracleConnectionProperties.Create('localhost','XE','scott','tiger');
  try
    rows := Props.Execute('select * from truck_trans',[]);
    rows.Step;
    Showmessage(utf8ToString(rows.ColumnUTF8(0)));
  finally
    //Props.Free;
  end;
end;

It is running well for oracle XE 11g, OS windows 7 64bit (apps compiled inside 32bit windows XP).
Props.Free will raise exception "access violation, ntdll.dll"

#33 mORMot 1 » Get Start with SynDBOracle » 2015-06-22 15:47:52

Cahaya
Replies: 21

Hi AB,

I try to use, TSQLDBOracleConnectionProperties.Create('ORCL81','orcl81','scott','tiger');
I got error, "raise ESQLDBOracle.CreateFmt('Invalid oci.dll: missing %s',[OCI_ENTRIES[]]);"

I use oracle 8.1.7, is it compatible with mormot 1.18 ?

Thank you.

#34 Re: mORMot 1 » Error compile TestSql3 » 2015-06-22 01:01:48

Thank you ab, it works. By the way, the testsql3 failed for a few module.

! Low level types - Encode decode JSON
! Exception EAccessViolation raised with messsage:
!  Access violation at address 005BD964 in module 'TestSQL3.exe'. Read of address 00000004

!  - Mustache renderer: 5 / 49 FAILED  10.66s

Do you have any idea why ?

#35 Re: mORMot 1 » Error compile TestSql3 » 2015-06-21 18:51:11

Thank you AB.

I use version 1.17. I will test the latest version.

#36 mORMot 1 » Error compile TestSql3 » 2015-06-21 17:38:52

Cahaya
Replies: 7

Hi AB,

I use Delphi 7 inside vmware (windows xp). I tried to compile TestSql3 and got error,
[Error] SynSQLite3.pas(1): Unsatisfied forward or external declaration: '_endthreadex'.

Thank you.

Board footer

Powered by FluxBB