clarification respect a recordset

clarification respect a recordset

Postby artu01 » Sat Aug 31, 2019 1:53 am

Guys:

I am migrating my progs from dbf to sql for this I use exclusively ado but I have a doubt about how a recordset works
The oBrw: delete, oRs: delete and delete from table are instructions that do the same delete records and a Recordset (oRs) is a copy of the table that is brought from the server to the client, then starting from that premise why when the instruction oRs delete or obrw: delete are invoked both delete the record of the client and of the server, isn't it just that it should be done to the client? I would like to be clarified, please
Thank you


Arturo
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
artu01
 
Posts: 397
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: clarification respect a recordset

Postby nageswaragunupudi » Sat Aug 31, 2019 4:57 am

It is true that ADO reads the data from the server and holds it in the client's memory.

We normally open recordsets using adLockOptimistic.

All calls to the methods Update(), Delete() and AddNew( aCols, aVals ) make the changes to the underlying database immediately and are visible to other users on the network.

We can also open the recordset using adLockBatchOptimistic mode.
Code: Select all  Expand view

oRs := FW_OpenRecordSet( oCn, cSql, adLockBatchOptimistic )
 


In this case, all changes including methods Update(), Delete(), AddNew(...) are all applied to the copy of data in the client's memory only. No changes are written to the server. These changes are also not visible to the other users on the network.

Calling the method CancelBatch() cancels all changes and restores the data in the client's memory to the original state.

Calling the method UpdateBatch() flushes all changes to the physical database on the server at once. From then on the changes are visible to the other users on the network. When some of the records are already modified by other users, they can not be written and the programmer has to handle these conflicts.

When we open recordset in batch mode, it is not necessary to keep the connection open. We can reopen the connection while saving the changes with UpdateBatch() call.

All web-software open recordsets in batch mode only.

Handling recordsets opened in batch mode requires greater expertise of ADO. It is not as easy as it may appear. For normal use in our programs, it is simple and easy to use the adLockOptimistic.

You may also consider using FWH mariadb library instead of ADO. FWH library is more powerful than ADO and (1) can do more than what is possible with even ADO (2) lot more easier to write code and (3) no need to install mysql ODBC connectors on each client.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: clarification respect a recordset

Postby Horizon » Sat Aug 31, 2019 7:50 pm

Hi Mr. Rao,

Using mariadb I want to use pessimistic mode. I want to limit other users when one user read a record. Is it possible? (When one user read one record, record should be locked. at the same time other users can only read the record. not update)

if possible can you please give an example using maria15.prg.

Thank you.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1289
Joined: Fri May 23, 2008 1:33 pm

Re: clarification respect a recordset

Postby Rick Lipkin » Sat Aug 31, 2019 10:12 pm

As Rao mentions .. many of the methods he has created handy wrappers .. to dig a bit deeper .. have a look and this fivewin wiki

https://wiki.fivetechsoft.com/doku.php? ... ted_stuffs

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2633
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: clarification respect a recordset

Postby artu01 » Sat Aug 31, 2019 11:24 pm

Thank for repky master rao!
your response always clear and precise
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
artu01
 
Posts: 397
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: clarification respect a recordset

Postby Horizon » Mon Sep 02, 2019 6:42 pm

Horizon wrote:Hi Mr. Rao,

Using mariadb I want to use pessimistic mode. I want to limit other users when one user read a record. Is it possible? (When one user read one record, record should be locked. at the same time other users can only read the record. not update)

if possible can you please give an example using maria15.prg.

Thank you.


:(
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1289
Joined: Fri May 23, 2008 1:33 pm

Re: clarification respect a recordset

Postby nageswaragunupudi » Tue Sep 03, 2019 8:37 am

Whatsnew.txt : FWH1806
-----------------------------

- Enhancement to method EditBaseRecord(...)
Added optional new 5th param, lLock (default .f.)
Revised syntax:
EditBaseRecord( [cFieldList], [lNew], [bEdit], [oBrw], [lLock] )
If lLock is set to true, the row is locked for edit and lock is released
after edit.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: clarification respect a recordset

Postby Horizon » Wed Sep 25, 2019 12:32 pm

nageswaragunupudi wrote:Whatsnew.txt : FWH1806
-----------------------------

- Enhancement to method EditBaseRecord(...)
Added optional new 5th param, lLock (default .f.)
Revised syntax:
EditBaseRecord( [cFieldList], [lNew], [bEdit], [oBrw], [lLock] )
If lLock is set to true, the row is locked for edit and lock is released
after edit.


Hi Mr. Rao,

I use FWH 19.03.

I have updated the lLock parameter as you described in maria15.prg from fwh\samples directory.

Code: Select all  Expand view
  @ 20, 20 BTNBMP PROMPT "ADD"  SIZE 100,30 PIXEL FLAT OF oDlg ;
      ACTION oRs:EditBaseRecord( nil, .t., { |oRec| MyEditDlg( oRec ) }, oBrw, .T. )


I have compiled and run from two different computer. When I edit one row in first computer, it does not locked the record. Other computer can also edit the record.


Is this the way it should be?

Thanks.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1289
Joined: Fri May 23, 2008 1:33 pm

Re: clarification respect a recordset

Postby nageswaragunupudi » Wed Sep 25, 2019 12:57 pm

We will test and come back to you on this.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: clarification respect a recordset

Postby Horizon » Fri Sep 27, 2019 7:05 am

nageswaragunupudi wrote:We will test and come back to you on this.


Hi Mr. Rao,


Also can a procedure be run if the record is not locked?

Code: Select all  Expand view
EditBaseRecord( [cFieldList], [lNew], [bEdit], [oBrw], [lLock], [bNotLock] )


Thanks.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1289
Joined: Fri May 23, 2008 1:33 pm

Re: clarification respect a recordset

Postby Horizon » Mon Sep 30, 2019 6:05 am

:shock:
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1289
Joined: Fri May 23, 2008 1:33 pm

Re: clarification respect a recordset

Postby Horizon » Fri Oct 04, 2019 5:21 pm

up
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1289
Joined: Fri May 23, 2008 1:33 pm

Re: clarification respect a recordset

Postby Horizon » Fri Oct 11, 2019 12:04 pm

Hi Mr. Rao,

Could you please help me about Lock parameter?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1289
Joined: Fri May 23, 2008 1:33 pm

Re: clarification respect a recordset

Postby Horizon » Wed Oct 16, 2019 7:59 am

Has been fixed in new Fwh? :roll:
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1289
Joined: Fri May 23, 2008 1:33 pm

Re: clarification respect a recordset

Postby nageswaragunupudi » Sat Nov 23, 2019 7:22 pm

Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 30 guests