I've just tried to implement a TZQuery event, it looks to work fine when calling Open, to retrieve resultsets.
I wonder what if running the query by ExecSql, for SQL statements that have no resultsets.
I've done it this way :
[font=Courier New]
type
TMyZQuery = class(TZQuery)
private
procedure BeforeOpenHandler(DataSet: TDataSet);
public
constructor Create(AOwner: TComponent); override;
end;
...
constructor TMyZQuery.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
BeforeOpen:=BeforeOpenHandler;
end;
{$B-}
procedure TMyZQuery.BeforeOpenHandler(DataSet: TDataSet);
begin
if IniParams.Log.Database and (DataSet.ClassName='TMyZQuery') then
FileLog(DatabaseAll,(DataSet as TZQuery).SQL.Text);
end;
[/font]
I also wonder if Delphi F1 key usable .hlp help files are being planned or not.
Any suggestions are welcome.
I've done some testing and assume that ExecSql does not call BeforeOpen.
Can someone confirm that ?
If yes, is there an event that's called both times, before executing any kind of queries ?
(As you can see, I wanna log any and all SQL statements to a text file automatically)
Isn't there a manual that describes when the TZQuery events are called, I didn't find this info on test.bravecobra.com .
THX & Cheers
btw. what if I Open an UPDATE or INSERT statement ?
EDatabaseError ?
procedure TMyZQuery.ExecSQL;
begin
if Assigned(BeforeOpen) then BeforeOpen(Self);
inherited ExecSQL;
end;[/font]
Solves the original problem.
Gotta find another stuff you maybe interested in.
Try to set a datetime column to 2010.04.31 00:00 using TZQuery.
No Exception raised (run through IDE), statement simply thrown away.
Database not changed.
ZeosDBO 6.6.0 stable
Does Zeos have something like bug tracker publicly visible ?
Conversion ?
Sorry, but I must contradict that.
I give the SQL statement as a string.
SQL server accepts the statement as a string.
There's no need for Zeos to convert anything.
Zeos is not in the position to be able to convert.
What you probably point occurs inside the database server, but that place it cannot raise anything or cause any and all event or any change to happen in the client.
If I run the same query in a database manager, it correctly answers :
"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated."
This is what Zeos does not catch, I suppose.
well, you're right, it happens on the server, but zeos checks for errors an passes them through ; I tried it ( zeos 6.6.5; lazarus 0.9.26.2, xp)
i get a dialog with :
SQL error : conversion error from string "31/04/2010". Error code : -413. Overflow occured during data type conversion. (...and then my sql string)
the field value in the table remains unchanged of course.