Previously, the Color attribute for Item_03 was assigned three values (Blue, Yellow, and Pink). This section provides examples of how to delete the value of an attribute for the sample item.
The following sample code snippets demonstrate deletion of the value Blue from the Color attribute of Item_03. The other color values will remain (i.e., Yellow, Pink).
To run the sample
Open a clean copy of DeleteAttributesSample.java.
Remove any comment marks from the invokeDeleteAttributes(service, request); line and add the following lines
after // @TODO: set request parameters here:
String domainName = "MyStore";
String itemName = "Item_03";
Attribute attribute = new Attribute("Color", "Blue");
DeleteAttributes request = (new DeleteAttributes()).withDomainName(domainName).withItemName(itemName).withAttribute(attribute);
Compile and run the sample.
Amazon SimpleDB deletes the Blue value from the Color attribute of Item_03.
To verify whether the value is deleted, see Getting the Attributes of an Item.
To run the sample
Open AmazonSimpleDBSamples.cs.
Comment out the code you added in the previous section.
Replace the Delete Attributes Action section with the following:
Amazon.SimpleDB.Model.Attribute deleteValueAttribute = new Amazon.SimpleDB.Model.Attribute().WithName("Color").WithValue("Blue");
DeleteAttributes deleteValueAction = new DeleteAttributes().WithDomainName("MyStore").WithItemName("Item_03").WithAttribute(deleteValueAttribute);
DeleteAttributesSample.InvokeDeleteAttributes(service, deleteValueAction);
Run the sample.
Amazon SimpleDB deletes the Blue value from the Color attribute of Item_03
To verify whether the value is deleted, see Getting the Attributes of an Item.
To run the sample
Open a clean copy of DeleteAttributesSample.pl.
Remove any comment marks from the invokeDeleteAttributes($service, $request); line and add the following lines
after the // @TODO: set request line:
my $request = Amazon::SimpleDB::Model::DeleteAttributes->new({
ItemName => "Item_03",
DomainName=> "MyStore",
Attribute => [
{
Name => "Color",
Value => "Blue"
}
],
});
Run the sample.
Amazon SimpleDB deletes the Blue value from the Color attribute of Item_03.
To verify whether the value is deleted, see Getting the Attributes of an Item.
To run the sample
Open a clean copy of DeleteAttributesSample.php.
Remove any comment marks from the invokeDeleteAttributes($service, $request); line and add the following lines
after the // @TODO: set request line:
require_once ('Amazon/SimpleDB/Model/Attribute.php');
$attribute = new Amazon_SimpleDB_Model_Attribute();
$attribute->withName('Color')->withValue('Blue');
$request = new Amazon_SimpleDB_Model_DeleteAttributes();
$request->withDomainName('MyStore')->withItemName('Item_03')->withAttribute($attribute);
Run the sample.
Amazon SimpleDB deletes the Blue value from the Color attribute of Item_03.
To verify whether the value is deleted, see Getting the Attributes of an Item.
To run the sample
Open AmazonSimpleDBSamples.vb.
Comment out the code you added in the previous section.
Replace the Delete Attributes Action section with the following:
Dim deleteValueAttribute As New Amazon.SimpleDB.Model.Attribute
deleteValueAttribute.WithName("Color").WithValue("Blue")
Dim deleteValueAction As New DeleteAttributes()
deleteValueAction.WithDomainName("MyStore").WithItemName("Item_03").WithAttribute(deleteValueAttribute)
DeleteAttributesSample.InvokeDeleteAttributes(service, deleteValueAction)
Run the sample.
Amazon SimpleDB deletes the Blue value from the Color attribute of Item_03.
To verify whether the value is deleted, see Getting the Attributes of an Item.
To run the sample
Open the scratchpad application with a web browser.
Select DeleteAttributes from the Explore API list box.
Enter MyStore in the Domain Name field.
Enter Color in the Name field and Blue in the Value field.
Select from the following:
To invoke the request, click Invoke Request.
Amazon SimpleDB deletes the Blue value from the Color attribute of Item_03.
To view the signed URL, click Display Signed URL. Then, copy and paste the signed URL into a browser.
Amazon SimpleDB deletes the Blue value from the Color attribute of Item_03.
To view the string to sign, click Display String to Sign.