TDV Adapter for XML

Build 24.0.9060

DELETE Execution

When a DELETE statement is executed, the adapter executes the DELETE method of the schema, where you can build the HTTP delete request.

To see this method in a complete example, refer to Customizing Schemas.

Execute Deletes to XML

In the DELETE method, the _input item, one of the Items in API Script, will contain the primary key of the record to delete. For example, consider the following statement:

DELETE FROM Persons WHERE Id = '7'

Below is the corresponding delete request in the OData API:

DELETE myapi.com/Persons(7)

In the corresponding DELETE method below, the required column, the primary key, is first validated and then used to modify the URI in an HTTP DELETE request:

<api:script method="DELETE">
  <api:set attr="method" value="DELETE"/>
  <api:validate attr="_input.Id" desc="An Id is required to delete." />
  <api:set attr="uri" value="[uri]([_input.Id])" />
  <api:call op="xmlproviderGet"/>
</api:script>
  

You can check that an input was provided and alert the user otherwise with the api:validate keyword. After validating that the primary key attribute exists, you can specify the primary key in the request URI. Use the api:set keyword to set the URI value.

The api:call keyword invokes the operation that will make the HTTP request. Before invoking the operation, set the method attribute to the HTTP method you want within the scope of the api:script keyword.

Access Components of DELETE Statements

In the DELETE script, the _query item contains the following attributes:

queryThe SQL statement, as in the following statement:
DELETE FROM Account WHERE Id = @myId
tableThe table in the SQL statement. For example, Account in the preceding query.
criteriaThe WHERE clause of the statement. For example, the following WHERE clause in the example:
Id = @myId

Keyword Reference

See the API Script Reference for more information on the keywords used in this section:

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060