Page 1 of 1
Verbose mode for TMyScript or TMyCommand
Posted: Thu 21 Jun 2007 09:24
by GuzunNicolae
Hello
I have a question.
How can I get the results of MyScript or MyCommand queries as in MySQL console?
For example:
Code: Select all
Query ok: xx rows affected, (yy seconds)
or
Is this possible? Also I would like to get from a MyScript the result of each statement.
Thanks
Posted: Thu 21 Jun 2007 12:10
by Antaeus
Just attach a TMyQuery object to TMyScript and use it to display data and read affected rows count. This may look like this:
Code: Select all
MyScript1.SQL.Clear;
MyScript1.SQL.Add('UPDATE emp SET empno=empno;');
MyScript1.SQL.Add('SELECT * FROM emp;');
MyScript1.SQL.Add('SELECT * FROM dept;');
MyScript1.DataSet := MyQuery1;
MyScript1.ExecuteNext;
ShowMessage('Affected rows count: ' + IntToStr(MyQuery1.RowsAffected));
DataSource1.DataSet := MyQuery1;
MyScript1.ExecuteNext; // display the `emp` table
ShowMessage('The `emp` table is displayed');
MyScript1.ExecuteNext; // display the `dept` table
ShowMessage('The `dept` table is displayed');
In order to catch errors when executing the script, you should add a handler to the OnError event of TMyScript.
Posted: Fri 22 Jun 2007 08:17
by GuzunNicolae
Won't this decrease visibly the performance?
Posted: Sat 23 Jun 2007 09:23
by Antaeus
No, the performance loss should be insignificant.
Posted: Wed 18 Jul 2007 11:09
by GuzunNicolae
What about the time in which the query executes? Should I calculate it by myself?
Also in MySQL when I issue an UPDATE/DELETE statement I get the following result:
'Rows matched: xx Changed: yy Warnings: zz
How I can get matched rows and warnings?
And how can I get the last error message of a script or command?
Thank you.
Posted: Wed 18 Jul 2007 13:55
by Antaeus
GuzunNicolae wrote:What about the time in which the query executes? Should I calculate it by myself?
Yes, you should.
GuzunNicolae wrote:How I can get matched rows and warnings?
You can get the matched rows count from the TMyQuery.RowsAffected property. MyDAC does not support functionality with returning information about changed recodrs count, and warnings count.
GuzunNicolae wrote:And how can I get the last error message of a script or command?
You can handle errors in the TMyScript.OnError event, and cache their messages.