In the previous section, all Year values were deleted from the Item_03. This section provides examples of how to replace the value of an attribute for an item.
The following sample code snippets demonstrate writing the value Medium to the Size attribute of Item_03, overwriting all existing values.
To run the sample
Open a clean copy of PutAttributesSample.java.
Remove any comment marks from the invokePutAttributes(service, request); line and add the following lines
after // @TODO: set request parameters here:
String domainName = "MyStore";
String itemName = "Item_03";
ReplaceableAttribute attribute = new ReplaceableAttribute("Size", "Medium", true);
PutAttributes request = (new PutAttributes()).withDomainName(domainName).withItemName(itemName).withAttribute(attribute);
Compile and run the sample.
Amazon SimpleDB writes the value Medium to the Size attribute of Item_03, overwriting all existing values.
To verify whether the attribute is updated, see Getting the Attributes of an Item.
To run the sample
Open AmazonSimpleDBSamples.cs.
Comment out the code you added in the previous section.
Add the following to the Put Attributes Action section:
ReplaceableAttribute replaceableAttribute = new ReplaceableAttribute().WithName("Size").WithValue("Medium").WithReplace(true);
PutAttributes replaceAction = new PutAttributes().WithDomainName("MyStore").WithItemName("Item_03").WithAttribute(replaceableAttribute);
PutAttributesSample.InvokePutAttributes(service, replaceAction);
Run the sample.
Amazon SimpleDB writes the value Medium to the Size attribute of Item_03, overwriting all existing values.
To verify whether the attribute is updated, see Getting the Attributes of an Item.
To run the sample
Open a clean copy of PutAttributesSample.pl.
Remove any comment marks from the invokePutAttributes($service, $request); line and add the following lines
after the // @TODO: set request line:
my $request = Amazon::SimpleDB::Model::PutAttributes->new({
ItemName => "Item_03",
DomainName=> "MyStore",
Attribute => [
{
Name => "Size",
Value => "Medium",
Replace => 1
}
],
});
Run the sample.
Amazon SimpleDB writes the value Medium to the Size attribute of Item_03, overwriting all existing values.
To verify whether the attribute is updated, see Getting the Attributes of an Item.
To run the sample
Open a clean copy of PutAttributesSample.php.
Remove any comment marks from the invokePutAttributes($service, $request); line and add the following lines
after the // @TODO: set request line:
require_once ('Amazon/SimpleDB/Model/ReplaceableAttribute.php');
$attribute = new Amazon_SimpleDB_Model_ReplaceableAttribute();
$attribute->withName('Size')->withValue('Medium')->withReplace(true);
$request = new Amazon_SimpleDB_Model_PutAttributes();
$request->withDomainName('MyStore')->withItemName('Item_03')->withAttribute($attribute);
Run the sample.
Amazon SimpleDB writes the value Medium to the Size attribute of Item_03, overwriting all existing values.
To verify whether the attribute is updated, see Getting the Attributes of an Item.
To run the sample
Open AmazonSimpleDBSamples.vb.
Comment out the code you added in the previous section.
Add the following to the Put Attributes Action section:
Dim replaceableAttribute As New ReplaceableAttribute
replaceableAttribute.WithName("Size").WithValue("Medium").WithReplace(True)
Dim replaceAttributeAction As New PutAttributes()
replaceAttributeAction.WithDomainName("MyStore").WithItemName("Item_03").WithAttribute(replaceableAttribute)
PutAttributesSample.InvokePutAttributes(service, replaceAttributeAction)
Run the sample.
Amazon SimpleDB writes the value Medium to the Size attribute of Item_03, overwriting all existing values.
To verify whether the attribute is updated, see Getting the Attributes of an Item.
To run the sample
Open the scratchpad application with a web browser.
Select PutAttributes from the Explore API list box.
Enter MyStore in the Domain Name field.
Enter Item_03 in the Item Name field.
Enter Size in the Name field.
Enter Medium in the Value field.
Enter true in the Replace field.
Select from the following:
To invoke the request, click Invoke Request.
Amazon SimpleDB writes the value Medium to the Size attribute of Item_03, overwriting all existing values.
To view the signed URL, click Display Signed URL. Then, copy and paste the signed URL into a browser.
Amazon SimpleDB writes the value Medium to the Size attribute of Item_03, overwriting all existing values.
To view the string to sign, click Display String to Sign.