Page 1 of 1
Getting metadata from db
Posted: Wed 30 Jun 2010 07:58
by Thomas.Schweikert
hi,
i just wanted to use the DBX4 metadata classes.
the following code - working with InterBase / Firebird -
for every table generates an exception
(translated from german error message)
"Can't access TDBXTypes.BLOB value type as TDBXTypes.WideString
Code: Select all
...
var
dbxColums: TDBXColumnsTableStorage;
begin
dbxColums := metaProvider.GetCollection(TDBXMetaDataCommands.GetColumns + ' ' +
sTableName) as TDBXColumnsTableStorage;
while dbxColums.Next do <--- exception
begin
...
end;
using the original driver from codegear there's no exception.
RAD Studio 2009 Enterprise
Oracle 8
Thomas
PS: with new build v4.50.21 error is still there
Posted: Tue 06 Jul 2010 08:17
by Thomas.Schweikert
Hi,
if i set
UseUnicode=False
then the error occurs.
Thomas
Posted: Tue 06 Jul 2010 11:13
by bork
Hello
To resolve this issue I need the DDL script for creating the table metadata of which you what to get.
Posted: Tue 06 Jul 2010 16:16
by Thomas.Schweikert
hi,
the error occurs with every table i want to read metadatas from.
just create a simple dummy table
CREATE TABLE TEST.METADATA
(
ID NUMBER(10,0),
SOME_DATA VARCHAR2(15),
PRIMARY KEY (
ID
) ENABLE VALIDATE
)
with dbexpress connection settings
[TEST_Oracle]
BlobSize=-1
DataBase=ORA
DriverName=DevartOracle
ErrorResourceFile=
LocaleCode=0000
Password=test
Oracle TransIsolation=ReadCommited
RoleName=Normal
User_Name=TEST
LongStrings=True
EnableBCD=True
InternalName=
UseQuoteChar=False
FetchAll=False
CharLength=0
Charset=
;;UseUnicode=False
with activ error occurs.
Thomas
Posted: Wed 07 Jul 2010 13:00
by bork
Thank you for the information. We have reproduced your issue. We will notify you as soon as we have any result.
Posted: Tue 17 Aug 2010 13:27
by bork
Hello
The DBXOracleMetaDataReader RAD Studio unit has an error. To fix it you can copy this unit from "D:\Program Files\Embarcadero\RAD Studio\7.0\source\database\DBXOracleMetaDataReader.pas" to the folder, where your application is located. And fix the TDBXOracleCustomMetaDataReader.TDBXOracleColumnsCursor.Next function:
From:
Code: Select all
function TDBXOracleCustomMetaDataReader.TDBXOracleColumnsCursor.Next: Boolean;
begin
if inherited Next then
begin
if FDefaultValue = nil then
FDefaultValue := TDBXWritableValue(TDBXValue.CreateValue(TDBXValueType(inherited GetWritableValue(TDBXColumnsIndex.DefaultValue).ValueType.Clone())));
FDefaultValue.SetWideString(Trim(inherited GetWritableValue(TDBXColumnsIndex.DefaultValue).AsString));
Exit(True);
end;
if FDefaultValue nil then
FDefaultValue.SetNull;
Result := False;
end;
To:
Code: Select all
function TDBXOracleCustomMetaDataReader.TDBXOracleColumnsCursor.Next: Boolean;
begin
if inherited Next then
begin
if FDefaultValue = nil then
FDefaultValue := TDBXWritableValue(TDBXValue.CreateValue(TDBXValueType(inherited GetWritableValue(TDBXColumnsIndex.DefaultValue).ValueType.Clone())));
// FDefaultValue.SetWideString(Trim(inherited GetWritableValue(TDBXColumnsIndex.DefaultValue).AsString));
FDefaultValue.SetValue(GetWritableValue(TDBXColumnsIndex.DefaultValue));
Exit(True);
end;
if FDefaultValue nil then
FDefaultValue.SetNull;
Result := False;
end;
After these changes dbExpress driver will return correct meta data for UseUnicode=True and for UseUnicode=Fasle.
Unfortunately, we cannot fix the DBXOracleMetaDataReader RAD Studio unit, therefore we are going to develop our own units for getting meta data.