How to check if a given table name is in a connected database? - Forum - OpenEdge Development - Progress Community

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

 Forum

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

This question is answered

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

Verified Answer
  • 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.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

All Replies
  • 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.

  • 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.
  • 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.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • 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