#1 2018-02-04 21:06:53

ianc
Member
Registered: 2017-01-12
Posts: 17

ODBC Error

Hi All Any help will be appreciated
Im running a SOA server which functions perfectly with authentication and a SQLite database. I needed to extract data from a propitiatory database. initial tests where positive. 
However when I extract many records I get an out of memory error. I hope someone can advise me how to trace the source of the error. I think its in the ODBC driver for the propitiatory database. I would need to trap the error as i have to restart the server for it to continue operating. I am using Delphi Berlin 1.1 Starter edition and a zeos TZConnection and TZReadOnlyQuery
The code and the error are listed below.

function TServiceAttache.OneAttache(partNo: RawUTF8; var Desc: string):double;
var
  ta: TZConnection;
  qu: TZReadOnlyQuery;
begin
  ta := nil;
  try
    ta := TZConnection.Create(nil);
    qu := TZReadOnlyQuery.Create(nil);
    ta.AutoCommit := false;
    ta.ReadOnly := true;
    ta.Version := '7.2.1-rc';
    ta.AutoEncodeStrings := false;
    ta.UseMetadata := false;
    ta.Protocol := 'ado';

    ta.Database := 'Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DSN=att;DBQ=G:\prophet\DataHL;CODEPAGE=1252';
    ta.Connected := true;
    qu.Connection := ta;
    qu.SQL.Clear;
    qu.Active := false;
    qu.SQL.text := 'Select AverageCost, Description from ICBase where Code = ''' + partNo + '''';
    qu.Active := true;

    result := qu.FieldByName('AverageCost').AsFloat;
    Desc := qu.FieldByName('Description').AsString;
    qu.active := false;
    ta.Connected := false;
    ta.Free;
    qu.Free;
  except
    ta.free;
    qu.free;

  end;
end;

error

20180202 02431342  +    mORMotSQLite3.TSQLRestServerDB(01B0D880).URI(POST root/Attache.OneAttache?session_signature=5EE133260025BC633E826F3F inlen=23)
20180202 02431342 auth  	mORMot.TSQLRestRoutingREST(01AC0330) admin1/1591816998 fe80::9885:a7f8:6d1d:320a%13
20180202 02431342 call  	mORMotSQLite3.TSQLRestServerDB(01B0D880) IAttache.OneAttache["LVFAEA12100001R1",""]
20180202 02431412 srvr  	mORMotSQLite3.TSQLRestServerDB(01B0D880) admin1 fe80::9885:a7f8:6d1d:320a%13 POST root/Attache.OneAttache SOA-Interface -> 200 with outlen=17 in 514555 us
20180202 02431412 ret   	mORMotSQLite3.TSQLRestServerDB(01B0D880) {"result":["",0]}
20180202 02431412  -    00.516.404
20180202 02431412  +    mORMotSQLite3.TSQLRestServerDB(01B0D880).URI(POST root/Attache.OneAttache?session_signature=5EE133260025BC658EBF3D6F inlen=14)
20180202 02431412 auth  	mORMot.TSQLRestRoutingREST(01AC0330) admin1/1591816998 fe80::9885:a7f8:6d1d:320a%13
20180202 02431412 call  	mORMotSQLite3.TSQLRestServerDB(01B0D880) IAttache.OneAttache["EFV3630",""]
20180202 02431439 EXC   	EOleException 80004005 [.NET/CLR unhandled ExternalException] [.NET/CLR unhandled SEHException] ("Unspecified error") at 0077C367  stack trace API 0056F983 0056F9AC 
20180202 02431439 EXC   	EOleException 80004005 [.NET/CLR unhandled ExternalException] [.NET/CLR unhandled SEHException] ("Unspecified error") at 0077C367  stack trace API 0056F983 0056F9AC 0040B3B8 77106D4B 77106BD7 0077C367 0077C367 00AD75A9 00AD76DA 006C8B74 00AE4013 0063A0DB 
20180202 02431448 EXC   	EOleException 80040E14 ("[Simba][SimbaEngine ODBC Driver]Memory allocation error") at 0077A2CB  stack trace API 0056F983 0056F9AC 0040B3B8 77106D4B 77106BD7 0077A2CB 0077A2CB 0077A5BD 0077CBFB 0075FB61 0077B649 0041171A 004104A7 00AD7E34 00AD99D9 00ACD6F4 00ACD0E2 00ACC751 00AE4099 0063A0DB 
20180202 02431448 srvr  	mORMotSQLite3.TSQLRestServerDB(01B0D880) admin1 fe80::9885:a7f8:6d1d:320a%13 POST root/Attache.OneAttache SOA-Interface -> 200 with outlen=17 in 573163 us
20180202 02431448 ret   	mORMotSQLite3.TSQLRestServerDB(01B0D880) {"result":["",0]}
20180202 02431448  -    00.574.765
20180202 02431448  +    mORMotSQLite3.TSQLRestServerDB(01B0D880).URI(POST root/Attache.OneAttache?session_signature=5EE133260025BC675784F160 inlen=15)
20180202 02431448 auth  	mORMot.TSQLRestRoutingREST(01AC0330) admin1/1591816998 fe80::9885:a7f8:6d1d:320a%13
20180202 02431448 call  	mORMotSQLite3.TSQLRestServerDB(01B0D880) IAttache.OneAttache["EFV00160",""]
20180202 02431508 EXC   	EOleException 80040E14 ("[Simba][SimbaEngine ODBC Driver]Memory allocation error") at 0077C367  stack trace API 0056F983 0056F9AC 
20180202 02431508 EXC   	EOleException 80040E14 ("[Simba][SimbaEngine ODBC Driver]Memory allocation error") at 0077C367  stack trace API 0056F983 0056F9AC 0040B3B8 77106D4B 77106BD7 0077C367 0077C367 00AD75A9 00AD76DA 006C8B74 00AE4013 0063A0DB 
20180202 02431515 EXC   	EOleException 80004005 [.NET/CLR unhandled ExternalException] [.NET/CLR unhandled SEHException] ("[Simba][SimbaEngine ODBC Driver][DRM File Library]Out of Memory") at 0077A2CB  stack trace API 0056F983 0056F9AC 0040B3B8 77106D4B 77106BD7 0077A2CB 0077A2CB 0077A5BD 0077CBFB 0075FB61 0077B649 0041171A 004104A7 00AD7E34 00AD99D9 00ACD6F4 00ACD0E2 00ACC751 00AE4099 0063A0DB 

Offline

#2 2018-02-04 22:29:40

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

Re: ODBC Error

Since you are using directly the Zeos library, I guess you should  better ask for support on their forum...

Offline

#3 2018-02-04 22:36:28

ianc
Member
Registered: 2017-01-12
Posts: 17

Re: ODBC Error

Many Thanks will do

Offline

#4 2018-02-05 09:05:30

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

Re: ODBC Error

Or try to use SynOleDB.pas instead of Zeos, if you want to access an MSSQL database.
It has JSON-specific functions which may help work with the framework SOA/ORM, and better performance.

Offline

#5 2018-02-05 19:12:39

ianc
Member
Registered: 2017-01-12
Posts: 17

Re: ODBC Error

Thanks AB
Its unfortunately a little known database used only in its own business application. My only connection to this database is an ODBC driver.
I had a look at SynDBODBC but it is my understanding that Mormot supports certain drivers but not all. I will read the documentation more closely
for SynDODBC and SynOleDB. Thanks for the tip.

Offline

#6 2018-02-07 18:37:38

EgonHugeist
Member
From: Germany
Registered: 2013-02-15
Posts: 190

Re: ODBC Error

Use the TZReadOnlyQuery in unidirectional mode.

Looking to the thrown Error .. Is it possible you do fetch to many rows? Use chunks instead.

Offline

#7 2018-02-08 18:17:41

ianc
Member
Registered: 2017-01-12
Posts: 17

Re: ODBC Error

Thanks Egonhugeist
I set TZReadOnlyQuery to unidirectional mode. The fault still occurs. the function fetches only 1 record at a time as the 'partno' is unique.
The function is used in a loop returning max 20 'partno' for each session. The fault occurs after about 10 sessions. As a new programmer i am trying
to understand the text 'memory allocation error'. I am going to learn how to use fastmm to see if there is a memory leak. I am also weary
because in my short programming career i have learnt that it is possible for a error message to lead you down a wrong direction. Many
thanks for your help. If I shut the server down and start again it works again for approx another ten sessions. The server works correctly for all
sqlite calls using mormot functionality.

Offline

Board footer

Powered by FluxBB