Wednesday, September 26, 2012

Delete all relational connections in Informatica - Windows Batch Script



Sometimes when your Repository grows too huge to manage in Development environment, you may want to cleanup some of the relational connections or all from the repository.
When you want to do so, you find the following batch script handy:

##############################################################################
        set REPOSITORY_NAME=Dev_Rep
        set GATEWAY_HOST_NAME=host-01
        set PORT=6001
        set USER_NAME=sathishm
        set PASSWORD=xyz
        set AUTHENTICATION=LDAP

        pmrep connect -r %REPOSITORY_NAME% -h %GATEWAY_HOST_NAME% -o %PORT% -n %USER_NAME% -s %AUTHENTICATION% -x %PASSWORD%
        pmrep listconnections > rel_connections.txt

        findstr relational rel_connections.txt > rel_connections.csv

        echo REM "Delete connections script" > del_conn.bat
        for /f "tokens=1-2 delims=," %%a in (rel_connections.csv) do (
        echo pmrep deleteconnection -n %%a -f >> del_conn.bat
        )

        del_conn.bat


##############################################################################

Similarly, you can delete all folders in the repository at one shot:

##############################################################################
        set REPOSITORY_NAME=REP_NAME
        set GATEWAY_HOST_NAME=HOST_NAME
        set USER_NAME=XXXXXXX
        set PASSWORD=XXXXXXX
        set AUTHENTICATION=LDAP
        pmrep connect -r %REPOSITORY_NAME% -h %GATEWAY_HOST_NAME% -o %PORT% -n %USER_NAME% -s %AUTHENTICATION% -x %PASSWORD%
        pmrep listobjects -o folder> folders_list.txt
        findstr /v ".listobj ompleted" folders_list.txt>list.txt
        echo REM "Delete connections script" > folder_list.bat
        for /f "tokens=1 skip=8" %%a in (list.txt) do (echo pmrep deletefolder -n %%a >> folder_list.bat)
        folder_list.bat
##############################################################################
 Before executing the scripts

1. Add Informatica command line utilities path to PATH environment variable
e.g. PATH=%PATH%;C:\Informatica\PowerCenter8.6.1\CMD_Utilities\PC\server\bin
Environment variables can be set at My Computer à Properties à Advanced à Environment Variables à Add a variable and assign above value
2. Edit the script and put your environment values in it
e.g. Change REPOSITORY_NAME, GATEWAY_HOSTNAME etc..

Happy coding!!

Until next post,
Sathish Manthani