It’s always great to receive a ‘Yes and’ idea that improves a tool for the better. Our thanks to Mr. Ronald Maillard of Northern Virgina who kindly sent in the following enhanced SQL statement that helps a user remove a project from the Cobra database – should removal by normal means be unavailable.
The original SQL statement we published for this purpose required that one dial into the SQL code and replace a string for each table to be purged. It’s a little fiddly and if you’re not familiar with SQL statements it can be a little off-putting. However, Ronald’s version opens a prompt dialog for each record to be updated, which is a lower risk option for the SQL ‘not-so-comfortable’ among us.
The SQL is opened in Cobra’s SQL Command Utility but requires no messing around with the SQL statements to make it work. You simply click on the Execute button, and enter the project name you wish to delete in the resulting Prompt dialog.
This script is deleting the project from 21 different tables in the Cobra database, so its nice to only need to enter the project name that you wish to delete once. We tested this and it worked well.
In just a few seconds, I had removed the project from the database without getting my hands dirty with any SQL code.
As usual, you will have to refresh the list by selecting the double blue arrows, or you can restart Cobra, to see the deleted project name disappear from the project table.
Thank for sharing this Ronald, I’m sure it will be appreciated by many Cobra folks.
Copy this script to your clipboard and then paste it into a notepad file. Or click here to download the SQL script file.
———————————————————————
/*
* Cobra Script
*
* Purpose:
* The following statements purges data
*/
SET vpcProgram=PADR( UPPER(inputbox(“Program Name” ) ), goApp.oFields.GetFieldLen( “PROGRAM.PROGRAM” ) );
DELETE FROM accounts WHERE PROGRAM = ?vpcProgram;
DELETE FROM appmaptg WHERE PROGRAM = ?vpcProgram;
DELETE FROM basedetl WHERE PROGRAM = ?vpcProgram;
DELETE FROM basehist WHERE PROGRAM = ?vpcProgram;
DELETE FROM baseline WHERE PROGRAM = ?vpcProgram;
DELETE FROM BASELOG WHERE PROGRAM = ?vpcProgram;
DELETE FROM calcflds WHERE PROGRAM = ?vpcProgram;
DELETE FROM cawp WHERE PROGRAM = ?vpcProgram;
DELETE FROM classes WHERE PROGRAM = ?vpcProgram;
DELETE FROM classeslink WHERE PROGRAM = ?vpcProgram;
DELETE FROM codefield WHERE DIR_ID = ?vpcProgram;
DELETE FROM costelem WHERE PROGRAM = ?vpcProgram;
DELETE FROM costrep WHERE PROGRAM = ?vpcProgram;
DELETE FROM costrepclass WHERE PROGRAM = ?vpcProgram;
DELETE FROM link WHERE PROGRAM = ?vpcProgram;
DELETE FROM milestn WHERE PROGRAM = ?vpcProgram;
DELETE FROM NARRTEXT WHERE PROGRAM = ?vpcProgram;
DELETE FROM program WHERE PROGRAM = ?vpcProgram;
DELETE FROM SETTING WHERE DIR_ID = ?vpcProgram;
DELETE FROM tphase WHERE PROGRAM = ?vpcProgram;
DELETE FROM WST_DIR WHERE DIR_ID = ?vpcProgram;
———————————————————————
To read more Deltek articles click here