Select working database

rohitbhoir

New Member
Is there a way to select any working database using a query, and not via the data dictionary? (the database is already connected)
 

sphipp

Member
If you create an alias DICTDB for the database then that selects the working database.

You have to access the database tables in another program, though, as CREATE ALIAS doesn't apply to the current program.

Code:
CREATE ALIAS DICTDB FOR DATABASE mydb. /* For mydb database */

You can use a variable to store the database you want to select.

Code:
DEF VAR mydb AS CHAR INITIAL "sports2000" NO-UNDO.
CREATE ALIAS DICTDB FOR DATABASE VALUE (mydb).
 

TomBascom

Curmudgeon
DICTDB is the alias for the default working database.

You can either reassign that alias or you can fully qualify the elements of your query with database names:

Code:
for each dbname.tblname no-lock where dbname.tblname.fieldname = something:

  /* do something */

end.
 
Top