mercredi 20 juillet 2022

How to handle retrieving data from a different table based on environment?

I am intentionally keeping this question agnostic to any specific language as I am looking for a solution in the realm of design.

I am working on a program that selects data from an external table using a dblink. Depending on what environment I am working in, the dblink changes. For example, if I am in the production environment, the dblink will also be for production. When in a lower environment the dblink will be for development.

To accommodate this we concatenate a SQL query together, placing the appropriate table name and dblink in which is determined by checking which environment we are currently in. See the psuedocode below:

If ENV = "PRD"
 dblink = "table@production";
Else
 dblink = "table@development";

SQL = "SELECT * FROM " + dblink + "WHERE...";

I just feel there may be a better way of doing this whether inside the program or through database setup. Any information or resources on this would be appreciated.

Aucun commentaire:

Enregistrer un commentaire