Compile function SQL_Delete(Connection, TableName, Keys)

/*****************************************************************************\
	Deletes a record from an SQL table.
	
	History
	-------
	09/15/2010    KRF   Original Programmer
\*****************************************************************************/

$insert Microsoft_Ado_Equates

If Assigned(Connection) else Connection = 0
If Assigned(TableName) else TableName = ""
If Assigned(Keys) else Keys = ""

Declare subroutine SRP_Com
Declare function SRP_Com
Ans = ""

// Create the where clause expression from the array of keys
KeyExpression = Keys
Swap @VM with " = " in KeyExpression
Swap @FM with " AND " in KeyExpression

// Script to delete the record        
Script = "Delete from ":TableName:" where ":KeyExpression

// Run the script
RecordSetResult = SRP_Com(Connection, "CALL", "Execute", Script)
If RecordSetResult NE 0 then
    SRP_Com(RecordSetResult, "RELEASE")
end else
    Ans = "Error deleting from ":TableName:" where ":KeyExpression:@TM:@TM:SRP_Com(Connection, "ERROR")
end

Return Ans
