Insert Interceptor
-
24 апреля 2012 г. 7:34
Hi,
Is there a way to intercept an insert statement from an uploadchanges synchronisation action from the client, in sql within the server db?
I know this can be done in code using the business interceptors, but would like to do this at the sql level. I have noticed that this can be done for select modifying the entity_selectchanges stored procedure, but cannot seem to do this for the insert. For example we have an entity_insert procedure, and I tried changing one of the input parameters manually in the procedure, but the old value still got populated to the database.
Ther reason for this is that in our application, various static data (e.g. ordertype) will be get updated to the server db, and thus be out of sync with the client IPad. In this instance the IPad will then submit an insert for an order with an incorrect orderid. As it stands the framework will simply reject this, whereas I want to be able to intercept this and substitute the old orederid for a correct one, hence the need to intercept the insert statement.
I also want to do this at the database/tsql level, as once we have deployed it is always much easier to get a db change than a software one granted.
Any help would be greatly appreciated
Все ответы
-
25 апреля 2012 г. 12:34Модераторwhat version of sql server are you using? if it is 2008, its going to use the bulk insert statement by default instead of the entity_insert stored proc.
-
25 апреля 2012 г. 12:38
Hi June,
Yes are using 2008, and I have indeed noticed (running sql profiler), that entity_bulkinsert does indeed get called.
I actually 'hacked; entity_bulkinsert and indeed did work.
I take it from your comments that bulkinsert will always get called and so safe to hack this and leave entity_insert alone?
Thanks
-
25 апреля 2012 г. 12:45Модератор
afaik, if it's sql 2008, by the default that's what its going to use. i cant remember though if the conflict resolution would use the bulk sp or the other one. you might want to test by simulating a conflict. sync fx resolves conflicts by row and am not sure if it will use the bulk instead of an individual row update sp.
- Помечено в качестве ответа xcfrt 25 апреля 2012 г. 16:05
-
25 апреля 2012 г. 16:05excellent information, thanks June