Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Remote View Data Duplication
Message
From
11/12/2023 10:03:04
Kato Ba
Bytex Technologies Limited
Kaduna, Nigeria
 
 
To
11/12/2023 03:12:53
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01687405
Message ID:
01687421
Views:
37
>>>>Hi,
>>>>
>>>>For all I know, there is an SQL Update strategy named "Delete and Insert".
>>>>
>>>>Do the old records get deleted?
>>>>If no, is something stopping them to bet deleted, like a Trigger or whatever can block server side?
>>>>
>>>>I have not used Views for ages - and I recommend CursorAdapter instead of View - but at least the CA has something like UpdateStrategy. And since the CA somehow is mirrored in the DBSetProp, check this.
>>>>
>>>>Lutz
>>>>
>>>>Hi Lutz,
>>>>
>>>>I tried the SQL Update strategy named "Delete and Insert" and the old records don't get deleted. I also don't have any sort of trigger on the table. I am not able to wrap my head around what is happening.
>>>>
>>>>I have never used a CursorAdapter before. What do you think could be blocking the old records from being deleted?
>>>>
>>>>Alex
>>>
>>>Hi Alex.
>>>
>>>Just a side note: Please click to Hamburger menu top right of this window and check "Enable auto quote", it helps a lot reading.
>>>
>>>Test UpdateType via cursorgetprop after the view is used.
>>>
>>>I guess you do the obvious:
>>>- Use YourView
>>>- REPLACE something
>>>- TABLEUPDATE()
>>>?
>>>And you do not touch the cguid field.
>>>
>>>If you check GETFLDSTATE(-1) after the REPLACE, is there something indicating a new record?
>>>
>>>Again, try to set up a Cursoradapter. The good on it is, that it offers BEFORE* events, where you can stop and look at the commands that are send to the server. This is not possible with a view.
>>>
>>>The other thing I see is, try if you can protocol the commands on SQL Server side, possibly you see what is send to the server.
>>>
>>>So far I see nothing bad on your set up. My best guess is GETFLDSTATE and see what's going on server side.
>>>
>>>You say that the record is appended. Is cguid not marked as primary in the SQL Server?
>>
>>
>>Hi Lutz
>>
>>>Just a side note: Please click to Hamburger menu top right of this window and check "Enable auto quote", it helps a lot reading.
>>
>>Thank you so much for pointing me to this, never knew!
>>
>>>If you check GETFLDSTATE(-1) after the REPLACE, is there something indicating a new record?
>>
>>Yes, I got these value "344444444444444444" without the quotes
>>3 for the cGuid column and 4 for the rest of the other columns
>>
>>>Again, try to set up a Cursoradapter. The good on it is, that it offers BEFORE* events, where you can stop and look at the commands that are send to the server. This is not possible with a view.
>>
>>I will check this out in the coming days...
>>
>>>The other thing I see is, try if you can protocol the commands on SQL Server side, possibly you see what is send to the server.
>>
>>Several insert statements were sent to SQL Server. I confirmed this from SQL Server XEvent Profiler while running my application.
>>
>>>You say that the record is appended. Is cguid not marked as primary in the SQL Server?
>>
>>Yes, records are appended as against an update. cGuid is the primary key in SQL Server.
>>
>>BTW, I inserted these records to the underlying remote view cursor as a result of some processing my application is performing. Could this be the reason why these records are duplicated? My understanding is that the records will be updated for those records whose primary key already exists, an insert will be done for those that don't and those records marked for deletion will be deleted when I issue TableUpdate.
>>
>>Please, is this assertion correct?
>>
>>TIA
>>
>>Alex
>
>Hi Alex,
>
>There are all answers you need.
>The 3 in the first char of GETFLDSTATE(-1) say this is a new appended record. So TABLEUPDATE() will send an INSERT and not an UPDATE.
>
>If you need to UPDATE, you must alter an existing record in the view.
>
>What TABLEUPDATE() will send depends on that what you see with GETFLDSTATE(-1)
>- Nothing (all is 1)
>- Append (first is 3)
>- Delete (first is 2)
>- Update (first is 1, at least one other is not 1), while the exact command depends on DBSetProp(ThisView,"View","UpdateType",1)
>
>A deleted record is changed with DELETE, an inserted one with APPEND or INSERT or the like.
>
>So somehow you need to gather the record from the server and change this record instead of creating a new one.

Hi Lutz,

Thank you for pointing me in the right direction! I have solved my problem. Thank you for your time.

Alex
Previous
Reply
Map
View

Click here to load this message in the networking platform