IS
Code: Select all
procedure TZPostgreSQLConnection.Open;
var
LogMessage: string;
QueryHandle: PZPostgreSQLResult;
SQL: PAnsiChar;
begin
if not Closed then
Exit;
LogMessage := Format('CONNECT TO "%s" AS USER "%s"', [Database, User]);
{ Connect to PostgreSQL database. }
FHandle := FPlainDriver.ConnectDatabase(PAnsiChar(BuildConnectStr));
if FPlainDriver.GetStatus(FHandle) = CONNECTION_BAD then
CheckPostgreSQLError(nil, FPlainDriver, FHandle, lcConnect, LogMessage,nil)
else
DriverManager.LogMessage(lcConnect, FPlainDriver.GetProtocol, LogMessage);
{ Set the notice processor (default = nil)}
FPlainDriver.SetNoticeProcessor(FHandle,FNoticeProcessor,nil);
{ Sets a client codepage. }
if FClientCodePage <> '' then
begin
SQL := PAnsiChar(Format('SET CLIENT_ENCODING TO ''%s''', [FClientCodePage]));
QueryHandle := FPlainDriver.ExecuteQuery(FHandle, SQL);
CheckPostgreSQLError(nil, FPlainDriver, FHandle, lcExecute, SQL,QueryHandle);
FPlainDriver.Clear(QueryHandle);
DriverManager.LogMessage(lcExecute, FPlainDriver.GetProtocol, SQL);
end;
{ Turn on transaction mode }
StartTransactionSupport;
{ Setup notification mechanism }
// PQsetNoticeProcessor(FHandle, NoticeProc, Self);
inherited Open;
end;
Code: Select all
procedure TZPostgreSQLConnection.Open;
var
LogMessage: string;
QueryHandle: PZPostgreSQLResult;
SQL: PAnsiChar;
begin
if not Closed then
Exit;
LogMessage := Format('CONNECT TO "%s" AS USER "%s"', [Database, User]);
{ Connect to PostgreSQL database. }
FHandle := FPlainDriver.ConnectDatabase(PAnsiChar(BuildConnectStr));
if FPlainDriver.GetStatus(FHandle) = CONNECTION_BAD then
CheckPostgreSQLError(nil, FPlainDriver, FHandle, lcConnect, LogMessage,nil)
else
DriverManager.LogMessage(lcConnect, FPlainDriver.GetProtocol, LogMessage);
{ Set the notice processor (default = nil)}
FPlainDriver.SetNoticeProcessor(FHandle,FNoticeProcessor,nil);
{ Sets a client codepage. }
if FClientCodePage <> '' then
begin
{$IFDEF ZEOS_FULL_UNICODE}
SQL := PAnsiChar(utf8string(Format('SET CLIENT_ENCODING TO ''%s''', [FClientCodePage])));
{$ELSE}
SQL := PAnsiChar(Format('SET CLIENT_ENCODING TO ''%s''', [FClientCodePage]));
{$ENDIF}
QueryHandle := FPlainDriver.ExecuteQuery(FHandle, SQL);
CheckPostgreSQLError(nil, FPlainDriver, FHandle, lcExecute, SQL,QueryHandle);
FPlainDriver.Clear(QueryHandle);
DriverManager.LogMessage(lcExecute, FPlainDriver.GetProtocol, SQL);
end;
{ Turn on transaction mode }
StartTransactionSupport;
{ Setup notification mechanism }
// PQsetNoticeProcessor(FHandle, NoticeProc, Self);
inherited Open;
end;