How to check if a given table name is in a connected databas

Posted by davidvilla on 01-Mar-2017 12:06

How to check if a given table name is in a connected database?

I tried to use:

for each dictdb._file no-lock where dictdb._file._file-name = ctablename:
disp dictdb._file._file-name

But, this won't work unless I go to data dictionary and select the working database. Any ideas?

I m using OE11.5 with Unix

Posted by Mike Fechner on 01-Mar-2017 12:34

Why not just CREATE BUFFER hBuffer FOR TABLE "sports2000.Customer" and handle the error accordingly, when the table is not available?

Sent from Nine

Von: Fernando Souza <bounce-fernando@community.progress.com>
Gesendet: 01.03.2017 1:27 nachm.
An: TU.OE.Development@community.progress.com
Betreff: RE: [Technical Users - OE Development] How to check if a given table name is in a connected database?

Update from Progress Community
Fernando Souza

You would need to use the CREATE ALIAS statement to set the alias to each db, one at a time. You can loop through the connected db's using the NUM-DBS function, and use the LDBNAME() function to get the logical db name for each db and create the alias, before you run the code above. You can delete the alias when done with DELETE ALIAS.

If you want to do this dynamically, then you don't need the CREATE ALIAS, and then use CREATE BUFFER to create a buffer on the table for each logical db using LDBNAME() as well.

View online

 

You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

Flag this post as spam/abuse.

All Replies

Posted by Fernando Souza on 01-Mar-2017 12:26

You would need to use the CREATE ALIAS statement to set the alias to each db, one at a time. You can loop through the connected db's using the NUM-DBS function, and use the LDBNAME() function to get the logical db name for each db and create the alias, before you run the code above. You can delete the alias when done with DELETE ALIAS.

If you want to do this dynamically, then you don't need the CREATE ALIAS, and then use CREATE BUFFER to create a buffer on the table for each logical db using LDBNAME() as well.

Posted by George Potemkin on 01-Mar-2017 12:30

Two solutions:

REPEAT i = 1 TO NUM-DBS:
  CREATE ALIAS DICTDB FOR DATABASE VALUE(LDBNAME(i)).
  RUN your_program.
END.

or

hQuery:QUERY-PREPARE(SUBSTITUTE("FOR EACH &1 NO-LOCK":U), ctablename)) NO-ERROR.
IF ERROR-STATUS:NUM-MESSAGES GT 0 THEN
MESSAGE ctablename "is not here" VIEW-AS ALERT-BOX BUTTONS OK.

Posted by Mike Fechner on 01-Mar-2017 12:34

Why not just CREATE BUFFER hBuffer FOR TABLE "sports2000.Customer" and handle the error accordingly, when the table is not available?

Sent from Nine

Von: Fernando Souza <bounce-fernando@community.progress.com>
Gesendet: 01.03.2017 1:27 nachm.
An: TU.OE.Development@community.progress.com
Betreff: RE: [Technical Users - OE Development] How to check if a given table name is in a connected database?

Update from Progress Community
Fernando Souza

You would need to use the CREATE ALIAS statement to set the alias to each db, one at a time. You can loop through the connected db's using the NUM-DBS function, and use the LDBNAME() function to get the logical db name for each db and create the alias, before you run the code above. You can delete the alias when done with DELETE ALIAS.

If you want to do this dynamically, then you don't need the CREATE ALIAS, and then use CREATE BUFFER to create a buffer on the table for each logical db using LDBNAME() as well.

View online

 

You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

Flag this post as spam/abuse.

Posted by gus bjorklund on 01-Mar-2017 12:58

if you are connected to just one database, then there is no need to use the dictdb alias.

just do

for each _file where _file._file-name = ctablename:

disp _file._file-name

end.

> On Mar 1, 2017, at 1:07 PM, davidvilla wrote:

>

> Update from Progress Community

>

> davidvilla

>

> How to check if a given table name is in a connected database?

>

> I tried to use:

>

> for each dictdb._file no-lock where dictdb._file._file-name = ctablename:

> disp dictdb._file._file-name

>

>

> But, this won't work unless I go to data dictionary and select the working database. Any ideas?

>

> I m using OE11.5 with Unix

>

>

> View online

>

>

> You received this notification because you subscribed to the forum. To stop receiving updates from only this thread, go here.

>

> Flag this post as spam/abuse.

>

>

regards,

gus

“less is my favorite editor. too bad it can’t actually edit files.”

Chris Lesniewski-Laas

This thread is closed