BuildDelete
(ODBC Manager Library)
Description: | Builds SQL Delete statements based on arrays of field names and values. Made to be called as a subroutine only. |
Returns: | Text (the SQL statement) |
Usage: | Script Only. |
Related to: | AddConnection | BuildInsert | BuildSelect | BuildUpdate | ConvertToDbDate | ConvertToDbTime | ConvertToDbTimeStamp | ConvertToVTSDate | ConvertToVTSTime | ConvertToVTSTimeStamp | CopyRecords | DBDropList | DBGridList | ErrMessage | ExecuteQuery | ExecuteQueryCached | FlushCache | FormatBatchQuery | GetConnList | ResultFormat | StatsWin | TableSynch | Transaction | TransactionCached |
Format: | \ODBCManager.BuildDelete( TableName, WhereFields, WhereOperators, WhereValues, WhereSQLDataTypes, WhereAND, dbType) |
Parameters: |
TableName | ||||||||||||
Required. Any text expression for the table name to delete records from. | ||||||||||||
WhereFields | ||||||||||||
Required. May be a simple value or a one-dimensional array. Provides the field names for the WHERE selection clause | ||||||||||||
WhereOperators | ||||||||||||
Required. May be a simple value or a one-dimensional array. Provides the operators for the WHERE selection clause | ||||||||||||
WhereValues | ||||||||||||
Required. Any SQL data type. May be a simple value or a one-dimensional array. Values for the WHERE selection clause | ||||||||||||
WhereSQLDataTypes | ||||||||||||
Required. Values indicating the data type of the insert values. Should be a simple value or an array matching the WhereFields parameter. Refer to Data Type Codes used in the ODBC Manager for a list of the value codes. | ||||||||||||
WhereAND | ||||||||||||
Required. Any expression that evaluates to a Boolean true or false. If set to true (non-zero) then the components of the WHERE clauses are to be ANDed together. If false (0) an OR is used between the sub clauses. |
||||||||||||
dbType | ||||||||||||
Required numeric value, indicating the type of this DB connection.
|
Comments:
This module is a member of the ODBCManager Library, and must therefore be prefaced by \ODBCManager, as shown in "Format" above.
If the WhereFields parameter is invalid, the SQL statement returned will be "DELETE FROM [Tablename]". The ExecuteQuery function includes a check that will prevent a delete statement without a where clause from running.
Example:
Query = \ODBCManager.BuildDelete("TestTable", "RecordName", "=", "rec2", Code\ODBCManager\#SQL_VARCHAR, 1, \ODBCManager\#dbType_MSAccess); Err = Invalid; Result = Invalid; Attrib = Invalid; ErrorMsg = Invalid; SQLState = Invalid; ErrorCode = Invalid; \ODBCManager.ExecuteQuery(&Err, Query, Conn1DSN, Invalid, Invalid, &Result, &Attrib, &ErrorMsg, &SQLState, &ErrorCode, 0, Trans2, 0, \ODBCManager\#dbType_MSAccess);