Replacement Libraries
What is Replacement Library Support
Replacement libraries can be very beneficial when you have multiple libraries that contain the same tables with similar sets of data. A primary example would be test data versus production data. Sometimes, different users have their own libraries, all containing the same files (tables). When a SQL is run, WOW checks to see if there has been a replacement library specified for the library the SQL is about to be run against. If so, the original library in the SQL is switched with a new replacement library.
For Example:
Let’s say there is a replacement library defined to replace LIBRARY1 with TESTLIBRARY1. In addition, we have an SQL statement set to query LIBRARY1 (SELECT * FROM LIBRARY1.TABLE1). With the replacement library defined, the final SQL that is run will actually be:
SELECT * FROM TESTLIBRARY1.TABLE1
Underneath the covers, WOW switches out replacement libraries before executing the SQL.
WOW based - these replacement libraries take affect for any SQL that is run within the current running WOW instance.
To configure, add a servlet initialization parameter called PJ_REPLACEMENT_LIBRARIES (similar to all the other WOW initialization parameters). Servlets that can be accessed by the public are defined in the web application's web.xml file. In this file, you can also define initialization parameters for the servlet.
These are parameters that may be used by the servlet when it is initialized. The format for each key value pair is <library to be replaced> = <replacement library>, etc.
For Example:
<init-param id="WOW_Replacement_Libraries">
<param-name>PJ_REPLACEMENT_LIBRARIES</param-name>
<param-value>LIBRARY1=REPLACEMENTLIBRARY32, LIBRARY3=REPLACEMENTLIBRARY2</param-value>
</init-param>
Application Based
Application based - these replacement libraries take affect for any SQL that is run within the current application.
To configure, add a "Config" property group to the application's properties. Edit the application. Add the Config property group in the properties text area. The format for the library replacement sting value is the same as the other library replacement support implementations <library to replace>=<replacement library>, etc.
For Example:
Config { replacement libraries: LIBRARY1=TESTLIBRARY4,LIBRARY2=REPLACEMENTLIBRARY31; }
Microsoft SQL SERVER uses the term database instead of library. In the example below, we are overriding the library from QCA_STG_PRD to QCA_PRD at the WOW application level.
Connection based - these replacement libraries take affect for any SQL that is run on the connection on which it has been set up.
Connection based replacement libraries are set up in the Connection Properties of the connection for which you wish to have libraries switched. It is set up as a simple property, similar to the Application based replacement libraries as seen above. To configure, add the "ConnectionOverrides" property group to the connection's properties. To do so, edit or create a new connection and add the ConnectionOverrides property to the properties text area. The format for the library replacement sting value is the same as the other library replacement support implementations <library to replace>=<replacement library>, etc.
For Example:
ConnectionOverrides { replacement libraries: LIBRARY1=TEST_LIBRARY4,LIBRARY2=REPLACEMENTLIBRARY31; }
User based - these replacement libraries take affect for any SQL that is run by current signed in user (for any application the user signs into).
User based replacement libraries take a little more work to configure but can be very useful when dealing with multiple users who have different libraries with similar tables. There are just a couple steps needed to configure user replacement libraries.
The SQLOperation used to sign-on the application should contain a column that is to be used for replacement libraries. The format for these column values should be the same format as other library replacement support implementations <library to replace>=<replacement library>, etc.
The field descriptor for the "replacement libraries" column from the sign-on needs to have a usage ID set to denote that it is a replacement library field. The usage ID to denote a replacement library field is -165.
For Example:
Let's say that we have a users file containing the user ID, password, and replacement libraries column. In this file there are two records with the following values:
Record 1
User Id: USER1
Password: PASSWORD
Replacement Libraries: LIBRARY1=LIBRARY4
Record 2
User Id: USER2
Password: PASSWORD
Replacement Libraries: LIBRARY1=LIBRARY3, LIBRARY6=REPLACEMENTLIBRARY2
The field descriptor for "replacement libraries" in this file is set with a usage id of -165.
When USER1 signs in and runs any SQL against LIBRARY1, the actual SQL is run against LIBRARY4. On the other hand, if USER2 signs into the same application, any SQL they run against LIBRARY1 will be actually against LIBRARY3
URL based - these replacement libraries take affect on any SQL that is run for the current user's environment only. Once the browser window is closed, the replacement libraries are no longer used.
To configure, add a request parameter on the URL call to the application when initially starting the application. This will set and remember the specified replacement libraries for the duration of the use of the application within the current browser session. The format for the library replacement string value is the same as the other library replacement support implementations <library to replace>=<replacement library>, etc. The parameter name for the URL call is '_pj_replace_libs' see below for an example.
For Example:
The following URL would open application with the ID of 1 and use the specified replacement libraries when running SQLs within that application for any user:
TAGS: dynamic library