The easiest way to avoid using dynamic SQL would be to create synonyms.
CREATE OR REPLACE SYNONYM MyTableRemote FOR MyTable@database _link
Your stored procedures will simply reference the synonym MyTableRemote . Then you can have a separate method in which the name of the database link would be a parameter and all synonyms for the link to the database link would be changed.
PROCEDURE replace_synonyms( p_db_link IN VARCHAR2 ) AS BEGIN -- Adjust the query to identify all the synonyms that you want to recreate FOR syn IN (SELECT * FROM user_synonyms WHERE db_link IS NOT NULL) LOOP EXECUTE IMMEDIATE 'CREATE OR REPLACE SYNONYM ' || syn.synonym_name || ' FOR ' || syn.table_owner || '.' || syn.table_name || '@' || p_db_link; END LOOP; END;
source share