open-insight/LSL2/STPROC/SQL_DELETE.txt
2024-03-25 14:46:21 -07:00

38 lines
1.1 KiB
Plaintext

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