Batch Execute SQL Script with Progress

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Mimar

Batch Execute SQL Script with Progress

Post by Mimar » Mon 07 Feb 2005 18:55

Hello,

I want to batch execute a SQL script prepared by a user on the target system. During execution I want to display progress (execution percentage of script) and also allow a choice of aborting/continuing execution.

How can I do this with MYDAC?
Sinan

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 08 Feb 2005 16:18

Use TMyScript for a script execution.
To calculate progress use StartPos, EndPos, StartLine, EndLine properties in BeforeExecute handler.

bravecobra
Posts: 11
Joined: Tue 21 Mar 2006 11:20

Post by bravecobra » Fri 16 Jun 2006 11:28

These 4 properties are not enough to calculate the whole script progress.
They only give me the position of the current sql statement in the whole script.

What do I set as max value of my progressbar (what is my 100% value)? Myscript.SQL.Count? That value is totally different of what the Final endline is. In my testprogram, I have used a script of 49 statements written in 775 lines and the final endline value turns out to be 2322.
Or do I have to "read" the whole script first (use "ExecuteNext" together with "Omit:= True") first to know what the final EndLine will be, getting the "2322" value and then rerun the whole script (use "ExecuteNext" together with "Omit:= False")? That's the only way I can get a progress bar to work.

Would the implementation of a ReadScript function (to get the final Endline value ) be wise?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 20 Jun 2006 09:26

> What do I set as max value of my progressbar (what is my 100% value)? Myscript.SQL.Count?
Yes, it's right value

> ... what the final EndLine will be, getting the "2322" ...
Thank you for information. This is bug of MyDAC. We have reproduced and fixed it. This fix will be included in the next MyDAC build.

> Or do I have to "read" the whole script first...
> Would the implementation of a ReadScript function (to get the final Endline value ) be wise?
No, it's not necessary. Now, after bug was fixed, final EndLine value equals to Myscript.SQL.Count - 1.

bravecobra
Posts: 11
Joined: Tue 21 Mar 2006 11:20

Post by bravecobra » Wed 22 Nov 2006 15:29

I'm kinda late in replying, but tnx

Post Reply