mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 06:46:05 +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
|
||||
ssFirebird:
|
||||
begin
|
||||
// Firebird < 3.0 has no support for Boolean data type:
|
||||
FieldtypeDefinitions[ftBoolean] := '';
|
||||
FieldtypeDefinitions[ftMemo] := 'BLOB SUB_TYPE TEXT';
|
||||
end;
|
||||
@ -385,6 +386,18 @@ procedure TSQLDBConnector.CreateFieldDataset;
|
||||
var CountID : Integer;
|
||||
FType : TFieldType;
|
||||
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
|
||||
try
|
||||
Ftransaction.StartTransaction;
|
||||
@ -410,6 +423,13 @@ begin
|
||||
sql := sql + ',F' + Fieldtypenames[FType];
|
||||
if testValues[FType,CountID] <> '' then
|
||||
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:
|
||||
sql1 := sql1 + ',' + testValues[FType,CountID];
|
||||
ftDate:
|
||||
|
Loading…
Reference in New Issue
Block a user