mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-08 01:27:42 +01:00
* fcl-db oracleconnection.pp: cosmetic: replace Dutch tel variable with counter; translate Dutch comment
git-svn-id: trunk@26212 -
This commit is contained in:
parent
80c67337ed
commit
5ae858fbf5
@ -81,7 +81,7 @@ type
|
|||||||
// - Statement execution
|
// - Statement execution
|
||||||
procedure Execute(cursor:TSQLCursor; ATransaction:TSQLTransaction; AParams:TParams); override;
|
procedure Execute(cursor:TSQLCursor; ATransaction:TSQLTransaction; AParams:TParams); override;
|
||||||
function RowsAffected(cursor: TSQLCursor): TRowsCount; override;
|
function RowsAffected(cursor: TSQLCursor): TRowsCount; override;
|
||||||
// - Result retrieving
|
// - Result retrieval
|
||||||
procedure AddFieldDefs(cursor:TSQLCursor; FieldDefs:TFieldDefs); override;
|
procedure AddFieldDefs(cursor:TSQLCursor; FieldDefs:TFieldDefs); override;
|
||||||
function Fetch(cursor:TSQLCursor):boolean; override;
|
function Fetch(cursor:TSQLCursor):boolean; override;
|
||||||
function LoadField(cursor:TSQLCursor; FieldDef:TFieldDef; buffer:pointer; out CreateBlob : boolean):boolean; override;
|
function LoadField(cursor:TSQLCursor; FieldDef:TFieldDef; buffer:pointer; out CreateBlob : boolean):boolean; override;
|
||||||
@ -258,7 +258,7 @@ begin
|
|||||||
scale:=result.Precision-(exp*2+2);
|
scale:=result.Precision-(exp*2+2);
|
||||||
if scale>=0 then
|
if scale>=0 then
|
||||||
begin
|
begin
|
||||||
if (scale>result.Precision) then // need to add leading 0's
|
if (scale>result.Precision) then // need to add leading 0s
|
||||||
begin
|
begin
|
||||||
for i:=0 to (scale-result.Precision+1) div 2 do
|
for i:=0 to (scale-result.Precision+1) div 2 do
|
||||||
result.Fraction[i]:=0;
|
result.Fraction[i]:=0;
|
||||||
@ -284,7 +284,7 @@ begin
|
|||||||
result.SignSpecialPlaces:=result.SignSpecialPlaces or scale;
|
result.SignSpecialPlaces:=result.SignSpecialPlaces or scale;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin // add trailing zero's, increase precision to take them into account
|
begin // add trailing zeroes, increase precision to take them into account
|
||||||
i:=0;
|
i:=0;
|
||||||
while i<=result.Precision do // copy nibbles
|
while i<=result.Precision do // copy nibbles
|
||||||
begin
|
begin
|
||||||
@ -401,7 +401,7 @@ begin
|
|||||||
if OCIServerAttach(FOciServer,FOciError,@(ConnectString[1]),Length(ConnectString),OCI_DEFAULT) <> OCI_SUCCESS then
|
if OCIServerAttach(FOciServer,FOciError,@(ConnectString[1]),Length(ConnectString),OCI_DEFAULT) <> OCI_SUCCESS then
|
||||||
HandleError();
|
HandleError();
|
||||||
|
|
||||||
// Create temporary service-context handle for user-authentication
|
// Create temporary service-context handle for user authentication
|
||||||
if OciHandleAlloc(FOciEnvironment,TempServiceContext,OCI_HTYPE_SVCCTX,0,FUserMem) <> OCI_SUCCESS then
|
if OciHandleAlloc(FOciEnvironment,TempServiceContext,OCI_HTYPE_SVCCTX,0,FUserMem) <> OCI_SUCCESS then
|
||||||
DatabaseError(SErrHandleAllocFailed,self);
|
DatabaseError(SErrHandleAllocFailed,self);
|
||||||
|
|
||||||
@ -472,15 +472,15 @@ end;
|
|||||||
|
|
||||||
procedure TOracleConnection.DeAllocateCursorHandle(var cursor: TSQLCursor);
|
procedure TOracleConnection.DeAllocateCursorHandle(var cursor: TSQLCursor);
|
||||||
|
|
||||||
var tel : word;
|
var counter : word;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
with cursor as TOracleCursor do
|
with cursor as TOracleCursor do
|
||||||
begin
|
begin
|
||||||
if Length(FieldBuffers) > 0 then
|
if Length(FieldBuffers) > 0 then
|
||||||
for tel := 0 to high(FieldBuffers) do freemem(FieldBuffers[tel].buffer);
|
for counter := 0 to high(FieldBuffers) do freemem(FieldBuffers[counter].buffer);
|
||||||
if Length(ParamBuffers) > 0 then
|
if Length(ParamBuffers) > 0 then
|
||||||
for tel := 0 to high(ParamBuffers) do freemem(ParamBuffers[tel].buffer);
|
for counter := 0 to high(ParamBuffers) do freemem(ParamBuffers[counter].buffer);
|
||||||
end;
|
end;
|
||||||
FreeAndNil(cursor);
|
FreeAndNil(cursor);
|
||||||
end;
|
end;
|
||||||
@ -517,7 +517,7 @@ end;
|
|||||||
procedure TOracleConnection.PrepareStatement(cursor: TSQLCursor;
|
procedure TOracleConnection.PrepareStatement(cursor: TSQLCursor;
|
||||||
ATransaction: TSQLTransaction; buf: string; AParams: TParams);
|
ATransaction: TSQLTransaction; buf: string; AParams: TParams);
|
||||||
|
|
||||||
var tel : integer;
|
var counter : integer;
|
||||||
FOcibind : POCIDefine;
|
FOcibind : POCIDefine;
|
||||||
|
|
||||||
OFieldType : ub2;
|
OFieldType : ub2;
|
||||||
@ -530,7 +530,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
if OCIStmtPrepare2(TOracleTrans(ATransaction.Handle).FOciSvcCtx,FOciStmt,FOciError,@buf[1],length(buf),nil,0,OCI_NTV_SYNTAX,OCI_DEFAULT) = OCI_ERROR then
|
if OCIStmtPrepare2(TOracleTrans(ATransaction.Handle).FOciSvcCtx,FOciStmt,FOciError,@buf[1],length(buf),nil,0,OCI_NTV_SYNTAX,OCI_DEFAULT) = OCI_ERROR then
|
||||||
HandleError;
|
HandleError;
|
||||||
//get statement type
|
// get statement type
|
||||||
if OCIAttrGet(FOciStmt,OCI_HTYPE_STMT,@stmttype,nil,OCI_ATTR_STMT_TYPE,FOciError) = OCI_ERROR then
|
if OCIAttrGet(FOciStmt,OCI_HTYPE_STMT,@stmttype,nil,OCI_ATTR_STMT_TYPE,FOciError) = OCI_ERROR then
|
||||||
HandleError;
|
HandleError;
|
||||||
case stmttype of
|
case stmttype of
|
||||||
@ -550,35 +550,35 @@ begin
|
|||||||
if assigned(AParams) then
|
if assigned(AParams) then
|
||||||
begin
|
begin
|
||||||
setlength(ParamBuffers,AParams.Count);
|
setlength(ParamBuffers,AParams.Count);
|
||||||
for tel := 0 to AParams.Count-1 do
|
for counter := 0 to AParams.Count-1 do
|
||||||
begin
|
begin
|
||||||
|
|
||||||
case AParams[tel].DataType of
|
case AParams[counter].DataType of
|
||||||
ftInteger : begin OFieldType := SQLT_INT; OFieldSize := sizeof(integer); end;
|
ftInteger : begin OFieldType := SQLT_INT; OFieldSize := sizeof(integer); end;
|
||||||
ftFloat : begin OFieldType := SQLT_FLT; OFieldSize := sizeof(double); end;
|
ftFloat : begin OFieldType := SQLT_FLT; OFieldSize := sizeof(double); end;
|
||||||
ftDate, ftDateTime : begin OFieldType := SQLT_DAT; OFieldSize := 7; end;
|
ftDate, ftDateTime : begin OFieldType := SQLT_DAT; OFieldSize := 7; end;
|
||||||
ftString : begin OFieldType := SQLT_STR; OFieldSize := 4000; end;
|
ftString : begin OFieldType := SQLT_STR; OFieldSize := 4000; end;
|
||||||
ftFMTBcd,ftBCD : begin OFieldType := SQLT_VNU; OFieldSize := 22; end;
|
ftFMTBcd,ftBCD : begin OFieldType := SQLT_VNU; OFieldSize := 22; end;
|
||||||
else
|
else
|
||||||
DatabaseErrorFmt(SUnsupportedParameter,[Fieldtypenames[AParams[tel].DataType]],self);
|
DatabaseErrorFmt(SUnsupportedParameter,[Fieldtypenames[AParams[counter].DataType]],self);
|
||||||
end;
|
end;
|
||||||
parambuffers[tel].buffer := getmem(OFieldSize);
|
parambuffers[counter].buffer := getmem(OFieldSize);
|
||||||
parambuffers[tel].Len := OFieldSize;
|
parambuffers[counter].Len := OFieldSize;
|
||||||
parambuffers[tel].Size := OFieldSize;
|
parambuffers[counter].Size := OFieldSize;
|
||||||
|
|
||||||
|
|
||||||
FOciBind := nil;
|
FOciBind := nil;
|
||||||
|
|
||||||
if AParams[tel].ParamType=ptInput then
|
if AParams[counter].ParamType=ptInput then
|
||||||
begin
|
begin
|
||||||
if OCIBindByName(FOciStmt,FOcibind,FOciError,pchar(AParams[tel].Name),length(AParams[tel].Name),ParamBuffers[tel].buffer,OFieldSize,OFieldType,@ParamBuffers[tel].ind,nil,nil,0,nil,OCI_DEFAULT )= OCI_ERROR then
|
if OCIBindByName(FOciStmt,FOcibind,FOciError,pchar(AParams[counter].Name),length(AParams[counter].Name),ParamBuffers[counter].buffer,OFieldSize,OFieldType,@ParamBuffers[counter].ind,nil,nil,0,nil,OCI_DEFAULT )= OCI_ERROR then
|
||||||
HandleError;
|
HandleError;
|
||||||
end
|
end
|
||||||
else if AParams[tel].ParamType=ptOutput then
|
else if AParams[counter].ParamType=ptOutput then
|
||||||
begin
|
begin
|
||||||
if OCIBindByName(FOciStmt,FOcibind,FOciError,pchar(AParams[tel].Name),length(AParams[tel].Name),nil,OFieldSize,OFieldType,nil,nil,nil,0,nil,OCI_DATA_AT_EXEC )= OCI_ERROR then
|
if OCIBindByName(FOciStmt,FOcibind,FOciError,pchar(AParams[counter].Name),length(AParams[counter].Name),nil,OFieldSize,OFieldType,nil,nil,nil,0,nil,OCI_DATA_AT_EXEC )= OCI_ERROR then
|
||||||
HandleError;
|
HandleError;
|
||||||
if OCIBindDynamic(FOcibind, FOciError, nil, @cbf_no_data, @parambuffers[tel], @cbf_get_data) <> OCI_SUCCESS then
|
if OCIBindDynamic(FOcibind, FOciError, nil, @cbf_no_data, @parambuffers[counter], @cbf_get_data) <> OCI_SUCCESS then
|
||||||
HandleError;
|
HandleError;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -741,7 +741,7 @@ end;
|
|||||||
procedure TOracleConnection.AddFieldDefs(cursor: TSQLCursor; FieldDefs: TFieldDefs);
|
procedure TOracleConnection.AddFieldDefs(cursor: TSQLCursor; FieldDefs: TFieldDefs);
|
||||||
|
|
||||||
var Param : POCIParam;
|
var Param : POCIParam;
|
||||||
tel : ub4;
|
counter : ub4;
|
||||||
|
|
||||||
FieldType : TFieldType;
|
FieldType : TFieldType;
|
||||||
FieldName : string;
|
FieldName : string;
|
||||||
@ -763,10 +763,10 @@ begin
|
|||||||
if OCIAttrGet(FOciStmt,OCI_HTYPE_STMT,@numcols,nil,OCI_ATTR_PARAM_COUNT,FOciError) = OCI_ERROR then
|
if OCIAttrGet(FOciStmt,OCI_HTYPE_STMT,@numcols,nil,OCI_ATTR_PARAM_COUNT,FOciError) = OCI_ERROR then
|
||||||
HandleError;
|
HandleError;
|
||||||
|
|
||||||
// Let op, moet gewist worden. En in een keer gealloceerd
|
// Note: needs to be cleared then allocated in one go.
|
||||||
Setlength(FieldBuffers,numcols);
|
Setlength(FieldBuffers,numcols);
|
||||||
|
|
||||||
for tel := 1 to numcols do
|
for counter := 1 to numcols do
|
||||||
begin
|
begin
|
||||||
// Clear OFieldSize. Oracle 9i, 10g doc says *ub4 but some clients use *ub2 leaving
|
// Clear OFieldSize. Oracle 9i, 10g doc says *ub4 but some clients use *ub2 leaving
|
||||||
// high 16 bit untouched resulting in huge values and ORA-01062
|
// high 16 bit untouched resulting in huge values and ORA-01062
|
||||||
@ -774,7 +774,7 @@ begin
|
|||||||
// To be tested if BE systems have this *ub2<->*ub4 problem
|
// To be tested if BE systems have this *ub2<->*ub4 problem
|
||||||
OFieldSize:=0;
|
OFieldSize:=0;
|
||||||
|
|
||||||
if OCIParamGet(FOciStmt,OCI_HTYPE_STMT,FOciError,Param,tel) = OCI_ERROR then
|
if OCIParamGet(FOciStmt,OCI_HTYPE_STMT,FOciError,Param,counter) = OCI_ERROR then
|
||||||
HandleError;
|
HandleError;
|
||||||
|
|
||||||
if OCIAttrGet(Param,OCI_DTYPE_PARAM,@OFieldType,nil,OCI_ATTR_DATA_TYPE,FOciError) = OCI_ERROR then
|
if OCIAttrGet(Param,OCI_DTYPE_PARAM,@OFieldType,nil,OCI_ATTR_DATA_TYPE,FOciError) = OCI_ERROR then
|
||||||
@ -827,7 +827,7 @@ begin
|
|||||||
OFieldType := SQLT_VNU;
|
OFieldType := SQLT_VNU;
|
||||||
OFieldSize:= 22;
|
OFieldSize:= 22;
|
||||||
end
|
end
|
||||||
else //approximation with double, best can do
|
else // approximation with double, best we can do
|
||||||
begin
|
begin
|
||||||
FieldType := ftFloat;
|
FieldType := ftFloat;
|
||||||
OFieldType := SQLT_FLT;
|
OFieldType := SQLT_FLT;
|
||||||
@ -848,10 +848,10 @@ begin
|
|||||||
FieldType := ftUnknown;
|
FieldType := ftUnknown;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FieldBuffers[tel-1].buffer := getmem(OFieldSize);
|
FieldBuffers[counter-1].buffer := getmem(OFieldSize);
|
||||||
|
|
||||||
FOciDefine := nil;
|
FOciDefine := nil;
|
||||||
if OciDefineByPos(FOciStmt,FOciDefine,FOciError,tel,fieldbuffers[tel-1].buffer,OFieldSize,OFieldType,@(fieldbuffers[tel-1].ind),nil,nil,OCI_DEFAULT) = OCI_ERROR then
|
if OciDefineByPos(FOciStmt,FOciDefine,FOciError,counter,fieldbuffers[counter-1].buffer,OFieldSize,OFieldType,@(fieldbuffers[counter-1].ind),nil,nil,OCI_DEFAULT) = OCI_ERROR then
|
||||||
HandleError;
|
HandleError;
|
||||||
|
|
||||||
if OCIAttrGet(Param,OCI_DTYPE_PARAM,@OFieldName,@OFNameLength,OCI_ATTR_NAME,FOciError) <> OCI_SUCCESS then
|
if OCIAttrGet(Param,OCI_DTYPE_PARAM,@OFieldName,@OFNameLength,OCI_ATTR_NAME,FOciError) <> OCI_SUCCESS then
|
||||||
@ -860,7 +860,7 @@ begin
|
|||||||
setlength(Fieldname,OFNameLength);
|
setlength(Fieldname,OFNameLength);
|
||||||
move(OFieldName^,Fieldname[1],OFNameLength);
|
move(OFieldName^,Fieldname[1],OFNameLength);
|
||||||
|
|
||||||
TFieldDef.Create(FieldDefs, FieldDefs.MakeNameUnique(FieldName), FieldType, FieldSize, False, tel);
|
TFieldDef.Create(FieldDefs, FieldDefs.MakeNameUnique(FieldName), FieldType, FieldSize, False, counter);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user