by AHF » Wed Mar 18, 2015 11:17 am
Antonio,
There are some issues that we must workaround in order to have full compatibility between ADO and normal RDD with no changes in the code if at all possible.
These are the issues:
1) INDEX – In SQL these should be independent of the code itself. The programmer should only think about
the data he needs, the rest its up to DB admin.
By ordlistadd or createindex it would add to some array in the adordd the name of the indexes attached to
that workarea.
By ordsetfocus() the code simply asks for new recordset replacing the one in the same work area using
SELECT …. ORDER BY….
The ORDER BY is extracted and parsed from the original index expression in an array of all dbfs used in
the app in the form of:
{ {"TABLENAME",{"INDEXNAME","INDEXEXPRESSION"},{"INDEXNAME",”INDEXEXPRESSION"} }} if
called by ordlistaad.
If called by createindex the expression would be save in that array to the corresponding table name.
Thus it doesnt matter to the programmer if the indexes do not physically exists in the database.
The DB admin creates them enabling faster access for the app as the DB grows.
We already use this kind of approach in queries in ADS with goods results.
Using the SEEK we test if is supported otherwise FIND
2) RELATION – We must work with as many records sets as the relations and basically works the same as
indexes with an array for all the relations in the current work area.
If it has indexes FORCE REATION will use SEEK otherwise FIND and also verifies that the SQL expression
corresponds to the expected INDEX RELATION expression if it doesn’t rises an exception as other rdd child
not "indexed".
3) RECNO – Work with bookmarks if there isn’t any column AUTO INC named RECNO.
Of course bookmarks have some compatibility limitations but I think its not big issue at least for our
application.
If it becomes a problem we must alter structure of the table and add RECNO field AUTO INC.
4) LOCKS – we need to save all record locked like any other rdd to be used by dbrlocklist() that are either
Bookmarks or column RECNO.
In our case this is very important because in our transactions we lock and append all needed records and
when updating we go through an array of locked records returned by dbrlocklist() using dbgoto().
So it doenst matter so much the lock itself to prevent others from updating but the array of recnos locked.
5) CONCURRENT UPDATES – This is a big issue and the simplest and safe way its to treat everything as a
transaction and here we have to place in the code in every update BEGINS TRANS and COMMIT TRANS. I
think it’s the only way to prevent concurrent updates.
In the errorsys ABORT TRANS in case of an error.
Perhaps we could in the first LOCK issue BEGINS TRANS and COMMIT TRANS in the first UNLOCK.
The second LOCK checks if it is in a TRANSACTION (I dont know how to check it) if it doenst starts one.
On the other hand if one issues an unlock during a transaction because the fields information needed
didn’t checked right and did not proceed with it issuing a COMMIT TRANS after the unlock isn’t a problem
because there isn’t nothing to commit and the TRANSACTION is finished assuming that all info verification
is done before ny writing to the table.
With an open transaction concurrent updates will be in principle safe.
Databases not supporting transactions I really don’t have any alternative.
Doing this we could increase the level of abstraction to the database and it might function with any database no matter if supports or not INDEXES,RELATIONS, ROW LOCKS, whatever.
If it is too slow DB Admin creates the needed indexes and the adorrdd issuing the SELECTS speed will increase drastically.
I would forget CATALOGS and leave it to the DB Admin.
My questions are:
What are these arrays of information already in the adordd?
What is your opinion ? Do you think this is feasible ? Do you think it’s the better approach or do you have any other ideas?
By the way there are some FWAdo functions that I cant find anyware and could help doing the job.
Looking foward to all comments,
Regards
Antonio H Ferreira