[bug_fixed] Shortcut for Execute in TZConnection
Posted: 21.01.2008, 14:01
Hi, mdaems.
I am MSEide users. As I tell you in MSEide forum, I want to use ZeosLib in MSEide. AFAIK, sometimes we need to execute SQL directly to database without care the resultset. For example for sql syntax : update, insert, delete, create database, create table, etc.
AFAIK, currently we should use IZStatement to do it. like this.
var conn: TZConnection;
stmt: IZStatement;
res1: Boolean;
...
conn.Connect;
stmt := conn.DbcConnection.CreateStatement;
res1:= stmt.Execute('update employee set active=true);
stmt:=nil;
My propose is cut these syntax to TZConnection only, like this :
var conn: TZConnection;
res1: Boolean;
...
conn.Connect;
res1:= conn.Execute('update employee set active=true);
I add new code like this in ZConnection.pas:
TZConnectio = class(.....
protected
FStatement: IZStatement;
public
function Execute(const SQL: string): Boolean;
I modified this procedure :
procedure TZConnection.Connect;
...
if not FConnection.IsClosed then
FStatement:= FConnection.CreateStatement;
DoAfterConnect;
end;
procedure TZConnection.Disconnect;
....
try
...
FStatement:=nil;
I hope it can be usefull efficient coding.
regards,
wahono
I am MSEide users. As I tell you in MSEide forum, I want to use ZeosLib in MSEide. AFAIK, sometimes we need to execute SQL directly to database without care the resultset. For example for sql syntax : update, insert, delete, create database, create table, etc.
AFAIK, currently we should use IZStatement to do it. like this.
var conn: TZConnection;
stmt: IZStatement;
res1: Boolean;
...
conn.Connect;
stmt := conn.DbcConnection.CreateStatement;
res1:= stmt.Execute('update employee set active=true);
stmt:=nil;
My propose is cut these syntax to TZConnection only, like this :
var conn: TZConnection;
res1: Boolean;
...
conn.Connect;
res1:= conn.Execute('update employee set active=true);
I add new code like this in ZConnection.pas:
TZConnectio = class(.....
protected
FStatement: IZStatement;
public
function Execute(const SQL: string): Boolean;
I modified this procedure :
procedure TZConnection.Connect;
...
if not FConnection.IsClosed then
FStatement:= FConnection.CreateStatement;
DoAfterConnect;
end;
procedure TZConnection.Disconnect;
....
try
...
FStatement:=nil;
I hope it can be usefull efficient coding.
regards,
wahono