DynamoDb delete non-existent item does not fail, why? - amazon-web-services

I am deleting a non-existing record from the dynamodb table using dynamoDbMapper.delete(object) which uses default DynamoDBDeleteExpression
I was expecting some sort of exception to arise since the record is absent from the DB but it does nothing. It does not even have a return type which could tell if the delete was successful or failure. Is there a way to add a delete expression or something which will make my delete throw an exception if the item is absent from the db?

It is by design:
Unless you specify conditions, the DeleteItem is an idempotent operation; running it multiple times on the same item or attribute does not result in an error response.
FROM: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteItem.html

Related

Odoo 8 Integrity Error The operation cannot be completed

First of all I'm new in Oddo. I get error when try to open product from last several purchases:
Integrity Error
The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it
- creation/update: a mandatory field is not correctly set
[object with reference: Product Template - product.template]
Previously created products are editable, but the new one I create are not.
Any suggestions? :)

Ignore duplicate records in SSIS' OLE DB destination

I'm using a OLE DB Destination to populate a table with value from a webservice.
The package will be scheduled to run in the early AM for the prior day's activity. However, if this fails, the package can be executed manually.
My concern is if the operator chooses a date range that over-laps existing data, the whole package will fail (verified).
I would like it:
INSERT the missing values (works as expected if no duplicates)
ignore the duplicates; not cause the package to fail; raise an exception that can be captured by the windows application log (logged as a warning)
collect the number of successfully-inserted records and number of duplicates
If it matters, I'm using Data access mode = Table or view - fast load and
Suggestions on how to achieve this are appreciated.
Here's how I would do it:
Point your SSIS Destination to a staging table that will be empty
when the package is run.
Insert all rows into the staging table.
Run a stored procedure that uses SQL to import records from the
staging table to the final destination table, WHERE the records don't
already exist in the destination table.
Collect the desired meta-data and do whatever you want with it.
Empty the staging table for the next use.
(Those last 3 steps would all be done in the same stored procedure).
That's not a feature.
If you don't want error (duplicates), then you need to defend against it - much as you'd do in your favorite language. Instead of relying on error handling, you test for the existence of the error inducing thing (Lookup Transform to identify existence of row in destination) and then filter the duplicates out (Redirect No Match Output).
The technical solution you absolutely should not implement
Change the access mode from the "Table or View Name - Fast Load" to "Table or View Name". This changes the method of insert from a bulk/set-based operation to singleton inserts. By inserting one row at a time, this will allow the SSIS package to evaluate the success/fail of each row's save. You then need to go into the advanced editor, your screenshot, and change the Error disposition from Fail Component to Ignore Failure
This solution should not used as it yields poor performance, generates unnecessary work load and has the potential to mask other save errors beyond just "duplicates" - referential integrity violations for example

Zend Framework: This row has been marked read-only

This is the first time I've come across this issue. When saving one of my models I get the error message: "This row has been marked read-only". Not sure why I'm getting this error and how to solve it. The stack trace didn't help me. How can I resolve this issue so I can save the record?
Having a row marked as read only can be the result from any of the following operations:
The Zend_Db_Select query joined with another table
setIntegrityCheck(false) was set on the select object
One or more columns is the result of an evaluated expression
If any of the above conditions are true, then the resulting row object will be marked as read only, because Zend_Db cannot guarantee that all columns in the result reference the original parent table of the select object. Therefore any attempt to call update(), save(), or delete(), on the row object will fail.
Some of this information is spread throughout the Zend_Db_Table reference, where if you search for integrity you can see a number of instances where rows will be marked read only.

How to test if table was updated in Zend Framework?

When user opens a form to modify a record, but instead of changing information, he just clicks the Update button. Which causes the update() function to return 0. However, I consider this case a valid update task. How would I test it, so I can assign a success message?
Is update() returns -1 when SQL query failed or also 0?
Method: Zend_Db_Table_Abstract::update()
Any ideas?
Thanks
Zend_Db can only return what the MySQL adapter can return. Which would be the number of rows updated. However it does throw an exception in the event that a query errors out. So your best bet would be to wrap your update statement in a try/catch. If it catches an exception, then display an error in your application. If it does not, then consider the query executed correctly, even if no data was updated.

Entity Framework OptimisticConcurrencyException thrown by an sql trigger

I know there are many topics about this exception but I don't have any solutions yet. My exception is thrown in an sql trigger called by an insert into a table. If I remove the trigger the problem goes away.
The table the trigger writes is just for monitoring so I'm okay if it doesn't always contain the very last record. Can I switch isolation levels in the trigger for example or tell sql server that this command is just "not so important" to drop the calling procedure all together?
The complete stack trace:
An error occurred while saving entities that do not expose foreign key
properties for their relationships. The EntityEntries property will
return null because a single entity cannot be identified as the source
of the exception. Handling of exceptions while saving can be made
easier by exposing foreign key properties in your entity types. See
the InnerException for details.
System.Data.Entity.Infrastructure.DbUpdateException: An error occurred
while saving entities that do not expose foreign key properties for
their relationships. The EntityEntries property will return null
because a single entity cannot be identified as the source of the
exception. Handling of exceptions while saving can be made easier by
exposing foreign key properties in your entity types. See the
InnerException for details.
System.Data.Entity.Core.OptimisticConcurrencyException: Store update,
insert, or delete statement affected an unexpected number of rows (0).
Entities may have been modified or deleted since entities were loaded.
See http://go.microsoft.com/fwlink/?LinkId=472540 for information on
understanding and handling optimistic concurrency exceptions.
Basically I have a context.SaveChanges() on EF side that is called from several async tasks all doing the same: inserts a row in a table called worksteps which has an insert trigger on it that writes the last records into an other table. One of every 100 inserts throws this exception so it's very hard to reproduce.

Resources