Orchestrator Function: SQL Table Delete Records by Where Field(s)

by Simon Sparks · 4 February 2026

To use this function add it to the class library file named OrchestratorPluginSQLService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: OrchestratorPluginSQLService.ts

Description: Orchestrator Function to Delete Records by Where Field(s) in an SQL Table

Private Function: SQLTableDeleteRecordByWhereField

publicSQLTableDeleteRecordByWhereField(objSQLTable:SQLTable,objPropertiesWhereField:Properties):number{

letobjSQLDatabase:SQLDatabase=objSQLTable.databaseasSQLDatabase;

letstrSQLQuery:string=`DELETE FROM${objSQLTable.database.name}.${objSQLTable.name}`

letarrKey:string[]=objPropertiesWhereField.keys;

if (arrKey.length>0){
strSQLQuery=`${strSQLQuery} WHERE`;

arrKey.forEach((strValue:string,intIndex:number):void=>{

strSQLQuery=`${strSQLQuery}${strValue}='${objPropertiesWhereField.get(strValue)}'`;

if (intIndex<arrKey.length-1){
strSQLQuery=`${strSQLQuery} AND`;
}
});
}

strSQLQuery=`${strSQLQuery};`

letintQueryResult:number=this.SQLDatabaseExecuteCustomQuery(objSQLDatabase,strSQLQuery);

returnintQueryResult;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like