Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Running script get EDatabaseError - Error creating table handle
Fri, Feb 16 2018 4:47 AMPermanent Link

Peter Evans

Subject : Running script get EDatabaseError - Error creating table handle

Using Delphi. ElevateDB Engine Version = 2.24 Build 2.

I have one script which is loaded from a file.

The script is run and I get one EDatabaseError. The error is "Error creating table handle".

Curiously the script does insert the required rows into the table!

The database is defined in the component EDBDatabase.
The script is defined in the component EDBScript.

Here is the guts of the code :-

     
     MyDatabase.Connected := True;
     
     MyScript.SQL.LoadFromFile(aFilePath);

     { The exception is in the next line }
     MyScript.Active := True;

The script in file aFilePath looks like this :-

SCRIPT
BEGIN

EXECUTE IMMEDIATE 'INSERT INTO "Contacts" VALUES (1,
                 ''Email'',
                 TRUE,
                 TIMESTAMP ''2017-07-29 15:09:38.144'')';

EXECUTE IMMEDIATE 'INSERT INTO "Contacts" VALUES (2,
                 ''Mail'',
                 TRUE,
                 TIMESTAMP ''2017-07-29 15:09:56.098'')';

EXECUTE IMMEDIATE 'INSERT INTO "Contacts" VALUES (3,
                 ''Intermediary'',
                 TRUE,
                 TIMESTAMP ''2017-07-29 15:10:22.725'')';
END

How can I eliminate the exception?

Has this been fixed in a more recent version?
Mon, Feb 19 2018 11:32 AMPermanent Link

Adam Brett

Orixa Systems

Dear Peter,

I cannot see an obvious flaw in your SQL, and I run similar scripts to this all the time, so I am pretty sure it is not an EDB bug.

Are you 100% sure that the Script is linked to the correct database containing the tables? It would be worth putting in a "Showmessage(SQLScript.DatabaseName)" debug prompt just to test for this, and to run the same script in EDBManager to test it ... obvious steps I know, so sorry if you have already tried them.
Mon, Feb 19 2018 5:33 PMPermanent Link

Peter Evans

Adam Brett wrote:

I cannot see an obvious flaw in your SQL, and I run similar scripts to this all the time, so I am pretty sure it is not an EDB bug.

I will try your two suggestions and report back.

I rechecked and the 3 rows get inserted into the correct table in the correct database!
Thu, Feb 22 2018 3:21 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Peter,

<< The script is run and I get one EDatabaseError. The error is "Error creating table handle". >>

Be sure to use the ExecScript method instead of trying to set the Active property to True.  Using the Active property assumes that the script will return a result set that can be opened (similar to Open method), hence the error.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Feb 23 2018 5:20 AMPermanent Link

Peter Evans

Tim Young [Elevate Software] wrote:

<<Be sure to use the ExecScript method instead of trying to set the Active property to True.  Using the Active property assumes that the script will return a result set that can be opened (similar to Open method), hence the error.>>

Thank you Tim for that advice. You identified the cause. I now have my script running and completing without the exception.
Image