Add Both Primary and Foreign Keys (The Composite ADDKEYS action)

Search Knowledge Base by Keyword

< Back

ADDKEYS is a composite action which performs both ADDPKEYS and ADDFKEYS. It thereby adds both Primary and Foreign Key constraints to the Staging Database.

You must first configure the Tables and ForeignKeys sheets, using instructions in the articles on ADDPKEYS and ADDFKEYS.

To run ADDKEYS, open The VIP Server Controller from your desktop or start menu. You must open it as an administrator. If The VIP Server Controller is already running, make sure the relevant .vip workflows are Put in Memory. See this article for instructions.

Next, complete the mandatory parameters in the “Run Flow” tab. If working from a Config file created for the current Subset, you should only need to update the parAction argument and enter any additional optional parameters. You will need to update the location of the Subset Report and SQLActionsPath if these have changed. See this article for instructions on working with a Config file.

Specify “ADDKEYS” for parACTION:

parAction=ADDKEYS

Complete any optional parameters. See this Knowledge Base article for a full list of Arguments and example parameters.

Once you have parameterized the ADDKEYS Action, make sure your Configuration Spreadsheet, Subset Report and Log file are all shut. Next, click “Create File” and then click “Start” to run the action.

In the output dialogue, you will see “Flow execution completed on remote server. Please check logs for details.” once the ADDKEYS Action is complete”:

If you receive an error message in your output dialogue or log, please refer to this article to troubleshoot common issues. You can also run your Action on debug mode for a more detailed log. You can also check the Log File and Subset Report at this stage, to check that the Actions have performed correctly.

Next, check your Database to make sure the Primary and Foreign Keys constraints have been added. You can also use VALIDATEKEYS to check them.

If the Primary and/or Foreign Keys are incorrect, you can perform one of the following actions:

  1. DROPKEYS will remove both Primary and Foreign Keys.
  2. DROPPKEYS will remove Primary Keys.
  3. DROPFKEYS will remove Foreign Keys.

Note: You can own add Primary and Foreign Keys that are not already present in the target database. Otherwise the action will fail. If you need to first remove certain Primary Keys, you can use the DROPPKEYS action, the DROPFKEYS action or the composite DROPPKEYS action.

Run ADDKEYS form the Command Line

To run ADDKEYS from the Command Line, first open your re-usable .cmd script in a text editor.

If you have already configured a .cmd script for one Subset Action and wish to edit and re-use that script, you should only need to set “DROP” for “Action”.

Otherwise, configure all mandatory parameters in the .cmd script.

You can also specify optional parameters at this stage.

Make sure your Control Spreadsheet, the Subset Report, and any Log Files are closed.

Run the script to add the Primary and Foreign Keys.

Check the Log File and Subset Report at this stage, to check that the Actions have performed correctly.

Next, check your Database to make sure the Primary and Foreign Keys constraints have been added. You can also use VALIDATEKEYS to check them.

If the Primary and/or Foreign Keys are incorrect, you can perform one of the following actions:

  1. DROPKEYS will remove both Primary and Foreign Keys.
  2. DROPPKEYS will remove Primary Keys.
  3. DROPFKEYS will remove Foreign Keys.

Note: You can own add Primary and Foreign Keys that are not already present in the target database. Otherwise the action will fail. If you need to first remove certain Primary Keys, you can use the DROPPKEYS action, the DROPFKEYS action or the composite DROPKEYS action.