fcl-db: formatting (char case)

git-svn-id: trunk@23139 -
This commit is contained in:
lacak 2012-12-14 07:00:39 +00:00
parent ecd81ed514
commit 7e2627f047
2 changed files with 34 additions and 35 deletions

View File

@ -357,7 +357,7 @@ begin
if (PQresultStatus(res) <> PGRES_COMMAND_OK) then
begin
E:=GetPQDatabaseError(res,ErrMsg);
pqclear(res);
PQclear(res);
res:=nil;
if assigned(conn) then
PQFinish(conn);
@ -497,7 +497,7 @@ procedure TPQConnection.PrepareStatement(cursor: TSQLCursor;ATransaction : TSQLT
const TypeStrings : array[TFieldType] of string =
(
'Unknown', // ftUnknown
'text', // ftString
'text', // ftString
'smallint', // ftSmallint
'int', // ftInteger
'int', // ftWord
@ -556,10 +556,10 @@ begin
// Only available for pq 8.0, so don't use it...
// Res := pqprepare(tr,'prepst'+name+nr,pchar(buf),params.Count,pchar(''));
s := 'prepare '+StmtName+' ';
if Assigned(AParams) and (AParams.count > 0) then
if Assigned(AParams) and (AParams.Count > 0) then
begin
s := s + '(';
for i := 0 to AParams.count-1 do if TypeStrings[AParams[i].DataType] <> 'Unknown' then
for i := 0 to AParams.Count-1 do if TypeStrings[AParams[i].DataType] <> 'Unknown' then
s := s + TypeStrings[AParams[i].DataType] + ','
else
begin
@ -572,7 +572,7 @@ begin
buf := AParams.ParseSQL(buf,false,sqEscapeSlash in ConnOptions, sqEscapeRepeat in ConnOptions,psPostgreSQL);
end;
s := s + ' as ' + buf;
res := pqexec(tr.PGConn,pchar(s));
res := PQexec(tr.PGConn,pchar(s));
CheckResultError(res,nil,SErrPrepareFailed);
// if statement is INSERT, UPDATE, DELETE with RETURNING clause, then
// override the statement type derrived by parsing the query.
@ -586,7 +586,7 @@ begin
FPrepared := True;
end
else
statement := AParams.ParseSQL(buf,false,sqEscapeSlash in ConnOptions, sqEscapeRepeat in ConnOptions,psPostgreSQL);
Statement := AParams.ParseSQL(buf,false,sqEscapeSlash in ConnOptions, sqEscapeRepeat in ConnOptions,psPostgreSQL);
end;
end;
@ -600,7 +600,7 @@ begin
begin
if not tr.ErrorOccured then
begin
res := pqexec(tr.PGConn,pchar('deallocate '+StmtName));
res := PQexec(tr.PGConn,pchar('deallocate '+StmtName));
CheckResultError(res,nil,SErrPrepareFailed);
PQclear(res);
res:=nil;
@ -619,7 +619,6 @@ var ar : array of pchar;
ParamNames,
ParamValues : array of string;
cash: int64;
E: EPQDatabaseError;
begin
with cursor as TPQCursor do
@ -627,13 +626,13 @@ begin
PQclear(res);
if FStatementType in [stInsert,stUpdate,stDelete,stSelect] then
begin
if Assigned(AParams) and (AParams.count > 0) then
if Assigned(AParams) and (AParams.Count > 0) then
begin
l:=Aparams.count;
l:=AParams.Count;
setlength(ar,l);
setlength(lengths,l);
setlength(formats,l);
for i := 0 to AParams.count -1 do if not AParams[i].IsNull then
for i := 0 to AParams.Count -1 do if not AParams[i].IsNull then
begin
case AParams[i].DataType of
ftDateTime:
@ -665,8 +664,8 @@ begin
end
else
FreeAndNil(ar[i]);
res := PQexecPrepared(tr.PGConn,pchar(StmtName),Aparams.count,@Ar[0],@Lengths[0],@Formats[0],1);
for i := 0 to AParams.count -1 do
res := PQexecPrepared(tr.PGConn,pchar(StmtName),AParams.Count,@Ar[0],@Lengths[0],@Formats[0],1);
for i := 0 to AParams.Count -1 do
FreeMem(ar[i]);
end
else
@ -676,20 +675,20 @@ begin
begin
tr := TPQTrans(aTransaction.Handle);
if Assigned(AParams) and (AParams.count > 0) then
if Assigned(AParams) and (AParams.Count > 0) then
begin
setlength(ParamNames,AParams.Count);
setlength(ParamValues,AParams.Count);
for i := 0 to AParams.count -1 do
for i := 0 to AParams.Count -1 do
begin
ParamNames[AParams.count-i-1] := '$'+inttostr(AParams[i].index+1);
ParamValues[AParams.count-i-1] := GetAsSQLText(AParams[i]);
ParamNames[AParams.Count-i-1] := '$'+inttostr(AParams[i].index+1);
ParamValues[AParams.Count-i-1] := GetAsSQLText(AParams[i]);
end;
s := stringsreplace(statement,ParamNames,ParamValues,[rfReplaceAll]);
s := stringsreplace(Statement,ParamNames,ParamValues,[rfReplaceAll]);
end
else
s := Statement;
res := pqexec(tr.PGConn,pchar(s));
res := PQexec(tr.PGConn,pchar(s));
if (PQresultStatus(res) in [PGRES_COMMAND_OK]) then
begin
PQclear(res);

View File

@ -628,8 +628,8 @@ begin
Cursor := AllocateCursorHandle;
Cursor.FStatementType := stUnknown;
PrepareStatement(cursor,ATransaction,SQL,Nil);
execute(cursor,ATransaction, Nil);
PrepareStatement(Cursor,ATransaction,SQL,Nil);
Execute(Cursor,ATransaction, Nil);
UnPrepareStatement(Cursor);
finally;
DeAllocateCursorHandle(Cursor);
@ -644,7 +644,7 @@ end;
procedure TSQLConnection.SetPort(const AValue: cardinal);
begin
if AValue<>0 then
params.Values['Port']:=IntToStr(AValue)
Params.Values['Port']:=IntToStr(AValue)
else with params do if IndexOfName('Port') > -1 then
Delete(IndexOfName('Port'));
end;
@ -1051,7 +1051,7 @@ begin
if ServerFiltered then s := AddFilter(s);
TSQLConnection(Database).PrepareStatement(Fcursor,(transaction as tsqltransaction),S,FParams);
TSQLConnection(Database).PrepareStatement(FCursor,(Transaction as TSQLTransaction),S,FParams);
Execute;
inherited InternalOpen;
@ -1123,22 +1123,22 @@ begin
// and thus calls unprepare.
// A call to unprepare while the cursor is not prepared at all can lead to
// unpredictable results.
if not assigned(fcursor) then
if not assigned(FCursor) then
FCursor := Db.AllocateCursorHandle;
FCursor.FSelectable:=True; // let PrepareStatement and/or Execute alter it
FCursor.FStatementType:=StmType;
FCursor.FSchemaType := FSchemaType;
if ServerFiltered then
begin
If LogEvent(detprepare) then
If LogEvent(detPrepare) then
Log(detPrepare,AddFilter(FSQLBuf));
Db.PrepareStatement(Fcursor,sqltr,AddFilter(FSQLBuf),FParams)
Db.PrepareStatement(FCursor,sqltr,AddFilter(FSQLBuf),FParams)
end
else
begin
If LogEvent(detprepare) then
If LogEvent(detPrepare) then
Log(detPrepare,FSQLBuf);
Db.PrepareStatement(Fcursor,sqltr,FSQLBuf,FParams);
Db.PrepareStatement(FCursor,sqltr,FSQLBuf,FParams);
end;
FCursor.FInitFieldDef := FCursor.FSelectable;
end;
@ -1167,7 +1167,7 @@ begin
if not FCursor.FSelectable then
Exit;
if not FIsEof then FIsEOF := not TSQLConnection(Database).Fetch(Fcursor);
if not FIsEof then FIsEOF := not TSQLConnection(Database).Fetch(FCursor);
Result := not FIsEOF;
end;
@ -1177,7 +1177,7 @@ begin
FMasterLink.CopyParamsFromMaster(False);
If LogEvent(detExecute) then
Log(detExecute,FSQLBuf);
TSQLConnection(Database).execute(Fcursor,Transaction as tsqltransaction, FParams);
TSQLConnection(Database).Execute(FCursor,Transaction as TSQLTransaction, FParams);
end;
function TCustomSQLQuery.LoadField(FieldDef : TFieldDef;buffer : pointer; out CreateBlob : boolean) : boolean;
@ -1227,7 +1227,7 @@ begin
try
FieldDefs.Clear;
if not Assigned(Database) then DatabaseError(SErrDatabasenAssigned);
TSQLConnection(Database).AddFieldDefs(fcursor,FieldDefs);
TSQLConnection(Database).AddFieldDefs(FCursor,FieldDefs);
finally
FLoadingFieldDefs := False;
if Assigned(FCursor) then FCursor.FInitFieldDef := false;
@ -1421,7 +1421,7 @@ begin
ReadFromFile:=IsReadFromPacket;
if ReadFromFile then
begin
if not assigned(fcursor) then
if not assigned(FCursor) then
FCursor := TSQLConnection(Database).AllocateCursorHandle;
FCursor.FSelectable:=True;
FCursor.FStatementType:=stSelect;
@ -1499,7 +1499,7 @@ begin
finally
// FCursor has to be assigned, or else the prepare went wrong before PrepareStatment was
// called, so UnPrepareStatement shoudn't be called either
if (not IsPrepared) and (assigned(database)) and (assigned(FCursor)) then TSQLConnection(database).UnPrepareStatement(Fcursor);
if (not IsPrepared) and (assigned(database)) and (assigned(FCursor)) then TSQLConnection(database).UnPrepareStatement(FCursor);
end;
end;
@ -1765,7 +1765,7 @@ end;
procedure TCustomSQLQuery.LoadBlobIntoBuffer(FieldDef: TFieldDef;
ABlobBuf: PBufBlobField);
begin
TSQLConnection(DataBase).LoadBlobIntoBuffer(FieldDef, ABlobBuf, FCursor,(Transaction as tsqltransaction));
TSQLConnection(DataBase).LoadBlobIntoBuffer(FieldDef, ABlobBuf, FCursor,(Transaction as TSQLTransaction));
end;
procedure TCustomSQLQuery.BeforeRefreshOpenCursor;
@ -1817,7 +1817,7 @@ begin
FInsertSQL.Assign(AValue);
end;
Procedure TCustomSQLQuery.SetDataSource(AVAlue : TDatasource);
Procedure TCustomSQLQuery.SetDataSource(AValue : TDatasource);
Var
DS : TDatasource;