Session.GetTableNames

Folks,

Can someone help me out with this.  It's annoying me.

I need to copy data from one database to another.  I've got a list of tables from my SQL server on one side (source) and a list tables on my AS/400 on the other side (target).

The problem is, the SQL server gives me the owner name - dbo.Tablename.  The AS/400 doesn't have the prepended owner name.  I need to know HOW do I list the tables without their owner shown?  This also happens with Oracle.  Currently, I've hardcoded it to delete the owner name, but this won't work on systems which have owner's called anything but dbo.

Any help would be appreciated!

Stu
LVL 6
Stuart_JohnsonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AloneConnect With a Mentor Commented:
const
  OwnerDelimiter = '.';
var
  P, I: Integer;
begin
  Session.GetTableNames(AliasName, '*', false, false, TableList);
  for I := 0 to TableList.Count - 1 do
  begin
    P := AnsiPos(OwnerDelimiter, TableList[I]);
    if P <> 0 then TableList[I] := Copy(TableList[I], P + 1, MaxInt);
  end;
end;

WBR...
0
 
lottolCommented:
try to use next method of default object Session

procedure GetTableNames(const DatabaseName, Pattern: string; Extensions, SystemTables: Boolean; List: TStrings);

0
 
Stuart_JohnsonAuthor Commented:
Hi lottol,

I am already using that procedure:

Session.GetTableNames(AliasName, '*', false, false, TableList);

It returns EVERYTHING including system tables (which, as you can see, I told it to omitt).  I'd love to be able to remove the system tables from the list (for instance, in SQL Server, dtProperties, sysalternatives, sysconstraints etc).

Do you know how I can remove the prepended owner and/or the system tables?

Thanks for the help,

Stu
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Stuart_JohnsonAuthor Commented:
Alone,

That is how I'm sort of doing it now.  I was hoping that there may have been a "nicer" way of doing it.  If there's not then I guess this will have to do.

Stu
0
 
AloneCommented:
IMHO, BDE has no other, "nicer" way. :-((

WBR...
0
 
Stuart_JohnsonAuthor Commented:
Hi Alone,

Thanks for that.  It's a real shame that it doesn't.  I'll accept your comment as an answer.

Do you  happen to know if there is a way to omit system tables from the list?  I know you can pass a boolean to the GetTableNames function, but it doesn't seem to make any difference.  You'll still get the points for this question regardless, but if you know off the top of your head, I'd appreciate it if you could share it with me :)

Thanks,

Stu
0
 
lottolCommented:
Just tested it with ADO

ADOConnection1.GetTableNames(ListBox1.items, false);

It works.
0
 
Stuart_JohnsonAuthor Commented:
Hi Alone,

Mmm.  Unfortunately I'm not able to use ADO (although future versions of our app may go that way).  Thanks for the information anyway.

Stu
0
 
lottolCommented:
Hmm...
I'm lottol, not Alone
0
All Courses

From novice to tech pro — start learning today.