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