Monday, June 1, 2015

UAT vs PRD

If you’re tired of switching your schemas in code from UAT to PRD, you can use ‘USER’, which will return the schema.

-- create amper variable named environ
COLUMN environ NEW_VALUE environ 

SELECT SUBSTR(USER,-3) AS environ  -- get last 3 characters of schema
FROM DUAL;



SELECT *
  FROM xyz_ods_&environ..client_store /* use two dots
                                         1 for concatenation after variable and
                                         the normal 1 between table_name.owner */
;



SELECT *   
  FROM xyz_sbx_str_&environ..master_map 
;

No comments:

Post a Comment