I want to get a list of all tables for a specific schema. It is clear in the documentation how to set the component and activate it, but doesn't explain how to actually get to the information.
Once I have a list of tables, I will need to retrieve the columns for a specific table. Again I get on how to add a restriction, but once active, how I get to the column information?
I am developing an adhoc query tool. Thanks.
How do you use TOraMetaData to get a list of tables?
-
1222tmiller
- Posts: 4
- Joined: Mon 14 Apr 2008 21:52
What about
and
Regards
Jens
Code: Select all
SELECT * FROM ALL_TABLES WHERE OWNER = :OWNER'Code: Select all
SELECT * FROM ALL_TAB_COLUMNS WHERE TABLE_OWNER = :OWNER AND TABLE_NAME = :TABLE_NAMEJens
-
1222tmiller
- Posts: 4
- Joined: Mon 14 Apr 2008 21:52
Sure I can do it that way, but then what is the MetaData component for?jfudickar wrote:What about
andCode: Select all
SELECT * FROM ALL_TABLES WHERE OWNER = :OWNER'
RegardsCode: Select all
SELECT * FROM ALL_TAB_COLUMNS WHERE TABLE_OWNER = :OWNER AND TABLE_NAME = :TABLE_NAME
Jens
-
AndreyZ
To obtain the list of tables and the list of columns using the TOraMetaData component, you can use the following code:
Code: Select all
procedure TForm1.BitBtn1Click(Sender: TObject);
var
strTables, strColumns: TStringList;
begin
strTables := nil;
strColumns := nil;
try
// obtaining the list of tables
OraMetaData1.MetaDataKind := 'Tables';
OraMetaData1.Restrictions.Values['TABLE_SCHEMA'] := '"schemaname"';
OraMetaData1.Open;
strTables := TStringList.Create;
while not OraMetaData1.Eof do begin
strTables.Add(OraMetaData1.FieldByName('TABLE_NAME').AsString);
OraMetaData1.Next;
end;
OraMetaData1.Close;
// obtaining the list of columns
OraMetaData1.MetaDataKind := 'Columns';
OraMetaData1.Restrictions.Values['TABLE_SCHEMA'] := '"schemaname"';
OraMetaData1.Restrictions.Values['TABLE_NAME'] := '"tablename"';
OraMetaData1.Open;
strColumns := TStringList.Create;
while not OraMetaData1.Eof do begin
strColumns.Add(OraMetaData1.FieldByName('COLUMN_NAME').AsString);
OraMetaData1.Next;
end;
finally
if Assigned(strColumns) then
FreeAndNil(strColumns);
if Assigned(strTables) then
FreeAndNil(strTables);
end;
end;