Table Dml
Function: table_dml
Type: API Endpoint (POST)
Purpose:
Executes data manipulation operations (insert, update, delete) on a specified table in the customer database based on the provided input data.
URL:
POST /api/new_mdm/table_dml
Request Headers:
- Customer_Key (str, required): A base64 encoded string containing lscode and firmcode for the customer. This must be decoded for database access.
Request Body:
- input_data (TableDMLRequest, required): Contains the table name and lists of data for insert, update, and delete operations.
Response:
- Returns a JSON object with a success message if the operations are successful.
Exceptions:
- Handles exceptions related to invalid customer key format, missing idx for update/delete operations, and database errors, providing appropriate error messages.
Steps:
-
Customer Key Decoding:
Decodes the Customer_Key to extract the lscode and firmcode. Raises an error if the format is invalid. -
Input Validation:
Validates the presence of table_name and that the data for insert, update, and delete operations are in list format. -
Database Connection:
Establishes a connection to the database using custCursorConnection. -
Data Manipulation:
Executes insert, update, and delete operations on the specified table using the input data. -
Transaction Handling:
Commits the transaction if all operations are successful, or rolls back in case of an error. -
Logging:
Logs the API call with details of the operation. -
Response Construction:
Returns a success message or error details based on the outcome of the operations.
Headers
Request body
Response
Successful Response
Changes
No recorded changes to this endpoint across all 1 revision of this API.