Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Lazarus Version and Transactions
Tue, Mar 24 2020 6:31 AMPermanent Link

Teco

TECHNOLOG Systems GmbH

Hi to all,

I am using ElevateDB with Lazarus.

Whenever I try to use

EDBDatabase1.StartTransaction(EmptyEDBStringsArray);

I get an errormessage when compiling
unit1.pas(---,--) Error: Identifier not found "EmptyEDBStringsArray"

Are transactions are not included in the Lazarus version or does I am missing something?

Any example available so that I can check my source code against a working example?

Thank you.
Tue, Mar 24 2020 7:02 AMPermanent Link

Teco

TECHNOLOG Systems GmbH

For this problem I have found a solution:
edbtype was not added to "uses" automaticly.

New Issue: when I start a transaction I get the error
ElevateDB Error #409 The configuration path is empty.

Any idea what throw the error?
Following the sourcecode I am using:

Thank you.
procedure TForm1.FormCreate(Sender: TObject);
var
 tmp1 : string;
 tmpint : integer;
 answers : TDataset;
begin
 Application.Processmessages;
 edbpassword := 'elevatesoft';
 appdir1 := extractfilepath(application.exename);
 dbdir1 :=  appdir1 + 'db\';
 if not (directoryexists(dbdir1)) then
 begin
   createdir(dbdir1);
 end;

 Form1.DBGrid1.Clear;
 Form1.DBGrid2.Clear;

 Form1.EDBEngine1.Active := false;
 Form1.EDBEngine1.ConfigName := 'econfig';;
 Form1.EDBEngine1.ConfigPath := dbdir1;
 Form1.EDBEngine1.CharacterSet:=csUnicode;
 Form1.EDBEngine1.UseLocalSessionEngineSettings:=true;
 Form1.EDBEngine1.EncryptionPassword:=edbpassword;;
 Form1.EDBEngine1.Active := true;

 form1.textausgabe.Lines.Add('EDB Version: '+form1.EDBEngine1.EngineVersion);

 Form1.EDBSession1.Connected:=false;;
 Form1.EDBSession1.LocalConfigName:='econfig';
 Form1.EDBSession1.LoginUser:='Administrator';
 Form1.EDBSession1.LoginPassword:='EDBDefault';
 Form1.EDBSession1.CharacterSet:=csUnicode;
 Form1.EDBSession1.LocalEncryptionPassword:=edbpassword;
 Form1.EDBSession1.LocalConfigPath:=dbdir1;
 Form1.EDBSession1.LocalCatalogName:='ecatalog';
 Form1.EDBSession1.LocalConfigPath := dbdir1;
 Form1.EDBSession1.SessionName:='EDBSession1';
 Form1.EDBSession1.Connected:=true;

 tmpint := Form1.EDBSession1.Execute('select name from users where name = ''edbconnect''');
 if (tmpint<1) then
 begin
   Form1.Textausgabe.Lines.Add('Einfügen '+inttostr(Form1.EDBSession1.Execute('CREATE USER edbconnect PASSWORD ''edbc''')));
   Form1.EDBSession1.Execute('GRANT "Administrators" TO "edbconnect"');
   Form1.Textausgabe.Lines.Add('New Admin added(edbconnect/edbc)');
 end
 else
 begin
   Form1.Textausgabe.Lines.Add('Admin exits (edbconnect/edbc)');
 end;


 tmpint := Form1.EDBSession1.Execute('select name from databases where name= ''Testdaten1''');
 Form1.Textausgabe.Lines.Add('Datenbanktest: '+inttostr(tmpint));
 if (tmpint<1) then
 begin
   Form1.EDBSession1.Execute('create database "Testdaten1" Path ''.'' Description ''Testdatenbank per Script''');
 end;

 Form1.EDBDatabase1.Connected:=false;
 
Form1.EDBDatabase1.Database:='Testdaten1';
 Form1.EDBDatabase1.DatabaseName:='test1';
 Form1.edbdatabase1.Sessionname :='EDBSession1';
 Form1.EDBDatabase1.Connected:=true;

 tmpint := Form1.EDBDatabase1.Execute('select name from information.tables where name= ''Tabelle1''');
 Form1.Textausgabe.Lines.Add('Tabellentest: '+inttostr(tmpint));

 if (tmpint<1) then
 begin
   Form1.EDBDatabase1.Execute('Create Table "Tabelle1" ("ID" INTEGER GENERATED ALWAYS AS IDENTITY (Start with 0, increment by 1), "Name" Varchar(1000) collate "UNI_CI", "Zahl" Integer) VERSION 1.00 READWRITE UNENCRYPTED INDEX PAGE SIZE 8192 BLOB BLOCK SIZE 1024 PUBLISH BLOCK SIZE 1024 PUBLISH COMPRESSION 0 MAX ROW BUFFER SIZE 32768 MAX INDEX BUFFER SIZE 65536 MAX BLOB BUFFER SIZE 32768 MAX PUBLISH BUFFER SIZE 32768');
 end;

 for tmpint :=0 to 1 do
 begin
   Form1.EDBQuery1.SQL.Clear;
   Form1.EDBQuery1.SQL.Add('Insert into "tabelle1" values (NULL, ''Name'',1)');
   showmessage('Exception follows');
   Form1.EDBQuery1.Prepare;
   Form1.EDBDatabase1.StartTransaction(EmptyEDBStringsArray);
   Form1.EDBQuery1.ExecSQL;
   form1.EDBDatabase1.Commit();
 end;                                 
Tue, Mar 24 2020 9:56 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Teco


My guess would be that you're confusing the catalog and configuration paths. EleveateDB has two essential files - .EDBCfg and .EDBCat the former being the configuration. Have a look and see if they're in the same directory, if not you're pointing to the wrong place.


Couple of points - this line appears twice for the session

Form1.EDBSession1.LocalConfigPath:=dbdir1;

don't know about Lazarus but in Delpfi "  Application.Processmessages;" can have unexpected consequences. It should also not be needed as the first line of a FormCreate event. You really don't want to process messages from elsewhere at that point.

Roy Lambert
Tue, Mar 24 2020 10:31 AMPermanent Link

Teco

TECHNOLOG Systems GmbH

Hi Roy,

Thank you for the information. I have removed the mentioned double line.

The .EDBCfg and .EDBCat files are in the same folder. When I do not use transaction I get not the error message.

Thank you.
Teco



Roy Lambert wrote:

Teco


My guess would be that you're confusing the catalog and configuration paths. EleveateDB has two essential files - .EDBCfg and .EDBCat the former being the configuration. Have a look and see if they're in the same directory, if not you're pointing to the wrong place.


Couple of points - this line appears twice for the session

Form1.EDBSession1.LocalConfigPath:=dbdir1;

don't know about Lazarus but in Delpfi "  Application.Processmessages;" can have unexpected consequences. It should also not be needed as the first line of a FormCreate event. You really don't want to process messages from elsewhere at that point.

Roy Lambert
Tue, Mar 24 2020 12:26 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Teco


Reading further down the post - does Form1.EDBQuery1 have session & database set?

Roy Lambert
Wed, Mar 25 2020 3:49 AMPermanent Link

Teco

TECHNOLOG Systems GmbH

Hi Roy,

Ups.

I have had the set delcared in another procedure, but not here. After adding the declaration to this procedure, it works...

Thank you for helping.
Teco




Roy Lambert wrote:

Teco


Reading further down the post - does Form1.EDBQuery1 have session & database set?

Roy Lambert
Image