Compile function Delete_Record_From_SQL(Table, Key, LogError) /*****************************************************************************\ Deletes the given record from the MSSQL database. Since every table differs from the next, it's not really possible to use the same code base for all tables. Therefore, common functionality has been moved into separate stored procedures. Supported tables are ones that have a stored procedure that handles the copy request. These are called the Handlers. A Handler is identified by the following naming convention: DELETE_XYZ_RECORD_TO_SQL XYZ is a placeholder for a table name. For example, the ASM_PART table has a handler called DELETE_ASM_PART_RECORD_TO_SQL. If a table does not have a handler, then it is not supported by this procedure. History ------- 09/15/2010 KRF Original Programmer \*****************************************************************************/ $insert Microsoft_Ado_Equates If Assigned(LogError) else LogError = 0 Declare subroutine SRP_Com Declare function SRP_Com Ans = "" // Make sure table is uppercase Convert @LOWER_CASE to @UPPER_CASE in Table // The expected name of the handler Handler = "DELETE_":Table:"_RECORD_FROM_SQL" // Find the stored procedure that handles this table Open "SYSOBJ" to hSysObj then Read ObjCode from hSysObj, "$":Handler:"*LSL2" then // Connect to the ODBC/ADO If SRP_Com(Connection, "CREATE", "ADODB.Connection") then // Connect to the database via ODBC * SRP_Com(Connection, "SET", "Mode", adModeShareDenyNone) * SRP_Com(Connection, "SET", "CursorLocation", adUseClient) * If SRP_Com(Connection, "CALL", "Open", "LSL2SQL", "srpadmin", "0okm9ijn") EQ "" then ConnectionString = 'Provider=SQLOLEDB.1;Password="0okm9ijn";Persist Security Info=True;User ID=srpadmin;Initial Catalog=LSL2SQL;Data Source=10.95.128.28\PROD1,53959' If SRP_Com(Connection, "CALL", "Open", ConnectionString) EQ "" then // Read the record and call the handler If Key NE "" then Ans = Function(@Handler(Connection, Key)) end end else Ans = SRP_Com(Connection, "ERROR") end SRP_Com(Connection, "CALL", "Close") SRP_Com(Connection, "RELEASE") end end end If LogError AND Len(Ans) then Open "SQL_ERROR" to hSqlError then Read Errors from hSqlError, Date() then Errors := @FM:Table:@VM:Key:@VM:Ans Write Errors to hSqlError, Date() end else Errors = Table:@VM:Key:@VM:Ans Write Errors to hSqlError, Date() end end end Return Ans