mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 05:39:19 +02:00
fcl-db: dbtestframework, Oracle:
* Fix for Oracle not accepting string literals in INSERT INTO statement for BLOB fields. Use hex encoding instead. Note: probably will have to review BLOB .AsString code in Oracle connector as well git-svn-id: trunk@26902 -
This commit is contained in:
parent
f3b7a7ad2e
commit
acd53636ed
@ -201,6 +201,7 @@ begin
|
|||||||
case SQLServerType of
|
case SQLServerType of
|
||||||
ssFirebird:
|
ssFirebird:
|
||||||
begin
|
begin
|
||||||
|
// Firebird < 3.0 has no support for Boolean data type:
|
||||||
FieldtypeDefinitions[ftBoolean] := '';
|
FieldtypeDefinitions[ftBoolean] := '';
|
||||||
FieldtypeDefinitions[ftMemo] := 'BLOB SUB_TYPE TEXT';
|
FieldtypeDefinitions[ftMemo] := 'BLOB SUB_TYPE TEXT';
|
||||||
end;
|
end;
|
||||||
@ -385,6 +386,18 @@ procedure TSQLDBConnector.CreateFieldDataset;
|
|||||||
var CountID : Integer;
|
var CountID : Integer;
|
||||||
FType : TFieldType;
|
FType : TFieldType;
|
||||||
Sql,sql1: String;
|
Sql,sql1: String;
|
||||||
|
|
||||||
|
function String2Hex(Source: string): string;
|
||||||
|
// Converts ASCII codes into hex
|
||||||
|
// Inverse of hex2string
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
result := '';
|
||||||
|
for i := 1 to length(Source) do
|
||||||
|
result := result + inttohex(ord(Source[i]),2);
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
Ftransaction.StartTransaction;
|
Ftransaction.StartTransaction;
|
||||||
@ -410,6 +423,13 @@ begin
|
|||||||
sql := sql + ',F' + Fieldtypenames[FType];
|
sql := sql + ',F' + Fieldtypenames[FType];
|
||||||
if testValues[FType,CountID] <> '' then
|
if testValues[FType,CountID] <> '' then
|
||||||
case FType of
|
case FType of
|
||||||
|
ftBlob, ftBytes, ftGraphic, ftVarBytes:
|
||||||
|
if SQLServerType in [ssOracle] then
|
||||||
|
// Oracle does not accept string literals in blob insert statements
|
||||||
|
// convert 'DEADBEEF' hex literal to binary:
|
||||||
|
sql1 := sql1 + ', HEXTORAW(' + QuotedStr(String2Hex(testValues[FType,CountID])) + ') '
|
||||||
|
else // other dbs have no problems with the original string values
|
||||||
|
sql1 := sql1 + ',' + QuotedStr(testValues[FType,CountID]);
|
||||||
ftCurrency:
|
ftCurrency:
|
||||||
sql1 := sql1 + ',' + testValues[FType,CountID];
|
sql1 := sql1 + ',' + testValues[FType,CountID];
|
||||||
ftDate:
|
ftDate:
|
||||||
|
Loading…
Reference in New Issue
Block a user