ADO RDD xHarbour
Re: ADO RDD xHarbour
Lucas,
Please remember:
hb_adoSetLocateFor is needed as LOCATE calls in adordd:
ADO_SETLOCATE( nWA, aScopeInfo )
ADO_LOCATE( nWA, lContinue )
Unfortunately aScopeInfo doesnt supply the cFor condition only bFor condition thus we need to set it up before with hb_adoSetLocateFor.
Let me check what we can do.
Please remember:
hb_adoSetLocateFor is needed as LOCATE calls in adordd:
ADO_SETLOCATE( nWA, aScopeInfo )
ADO_LOCATE( nWA, lContinue )
Unfortunately aScopeInfo doesnt supply the cFor condition only bFor condition thus we need to set it up before with hb_adoSetLocateFor.
Let me check what we can do.
Regards
Antonio H Ferreira
Antonio H Ferreira
- lucasdebeltran
- Posts: 1303
- Joined: Tue Jul 21, 2009 8:12 am
- Contact:
Re: ADO RDD xHarbour
Antonio,
Thnak you for your attention.
At least, it should support LOCATE FOR Upper(FIELD->City) = Upper(cCity).
Thnak you for your attention.
At least, it should support LOCATE FOR Upper(FIELD->City) = Upper(cCity).
Muchas gracias. Many thanks.
Un saludo, Best regards,
Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]
Implementando MSVC 2010, FWH64 y ADO.
Abandonando uso xHarbour y SQLRDD.
Un saludo, Best regards,
Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]
Implementando MSVC 2010, FWH64 y ADO.
Abandonando uso xHarbour y SQLRDD.
Re: ADO RDD xHarbour
Lucas,
I ve just recheck it and I dont see any other alternative.
You have to consider :
LOCATE FOR Upper(FIELD->City) = Upper(cCity).
This s passed to ADO_SETLOCATE in aScopeInfo as a code block.
We need hb_adoSetLocateFor to have it as a string.
But another problem is the hb_adoSetLocateFor( <(for)> ) (adordd.ch) needs to receive it as a string:
" Upper(FIELD->City) = Upper(cCity)"
This cant be evaluated because the variables are out of scope at ado framework.
This we must sent as for other rdds like ADS with the value of that var and not the var itself thus you will have to do:
"Upper(FIELD->City) ="+"'"+ Upper(cCity)+"'"
Then the string would be:
Upper(FIELD->City) ='LONDON'
The same will happen in index expressions with vars.
Sorry there isnt any other way.
For us no problem because the app worked already with ADS and it was already doing that.
Nevertheless this should not be a problem because its a very fast change in the app code and does not break any logic of it that's why I proposed the foloowing way of change it:
IF RDDSNAME() = "ADORDD"
//NEW EXPRESSIONS FOR ADO
ELSE
//AS ALREADY WRITTEN CODE
ENDIF
I ve just recheck it and I dont see any other alternative.
You have to consider :
LOCATE FOR Upper(FIELD->City) = Upper(cCity).
This s passed to ADO_SETLOCATE in aScopeInfo as a code block.
We need hb_adoSetLocateFor to have it as a string.
But another problem is the hb_adoSetLocateFor( <(for)> ) (adordd.ch) needs to receive it as a string:
" Upper(FIELD->City) = Upper(cCity)"
This cant be evaluated because the variables are out of scope at ado framework.
This we must sent as for other rdds like ADS with the value of that var and not the var itself thus you will have to do:
"Upper(FIELD->City) ="+"'"+ Upper(cCity)+"'"
Then the string would be:
Upper(FIELD->City) ='LONDON'
The same will happen in index expressions with vars.
Sorry there isnt any other way.
For us no problem because the app worked already with ADS and it was already doing that.
Nevertheless this should not be a problem because its a very fast change in the app code and does not break any logic of it that's why I proposed the foloowing way of change it:
IF RDDSNAME() = "ADORDD"
//NEW EXPRESSIONS FOR ADO
ELSE
//AS ALREADY WRITTEN CODE
ENDIF
Regards
Antonio H Ferreira
Antonio H Ferreira
Re: ADO RDD xHarbour
Solved !Antonio, Mr Rao,
Im having a problem with Numeric fields Len and Dec.
Regards
Antonio H Ferreira
Antonio H Ferreira
Re: ADO RDD xHarbour
Lucas,
Locate works now exactly the same as for dbfcdx and others. No need to alter anything in the code.
I choose to eval(bBlock) in do while performance its almost the same as with find.
Ill post new version today.
Locate works now exactly the same as for dbfcdx and others. No need to alter anything in the code.
I choose to eval(bBlock) in do while performance its almost the same as with find.
Ill post new version today.
Regards
Antonio H Ferreira
Antonio H Ferreira
- lucasdebeltran
- Posts: 1303
- Joined: Tue Jul 21, 2009 8:12 am
- Contact:
Re: ADO RDD xHarbour
Antonio,
Did you really fixed LOCATE FOR... command?.
That´s a great news!.
Also, there is a mistake on this line:
FUNCTION ADO_OPEN( nWA, aOpenInfo )
oRecordSet:Fields( aWAData[WA_FIELDRECNO] ):Properties("Optimize") := 1
Thank you.
Did you really fixed LOCATE FOR... command?.
That´s a great news!.
Also, there is a mistake on this line:
FUNCTION ADO_OPEN( nWA, aOpenInfo )
oRecordSet:Fields( aWAData[WA_FIELDRECNO] ):Properties("Optimize") := 1
Thank you.
Muchas gracias. Many thanks.
Un saludo, Best regards,
Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]
Implementando MSVC 2010, FWH64 y ADO.
Abandonando uso xHarbour y SQLRDD.
Un saludo, Best regards,
Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]
Implementando MSVC 2010, FWH64 y ADO.
Abandonando uso xHarbour y SQLRDD.
Re: ADO RDD xHarbour
Lucas,
Im still solving some problem with LOCATE .
What is the mistake ? Compile ? With xHarbour ok.
Im still solving some problem with LOCATE .
Code: Select all
oRecordSet:Fields( aWAData[WA_FIELDRECNO] ):Properties("Optimize") := 1
Regards
Antonio H Ferreira
Antonio H Ferreira
- lucasdebeltran
- Posts: 1303
- Joined: Tue Jul 21, 2009 8:12 am
- Contact:
Re: ADO RDD xHarbour
Antonio,
It says:
adordd\adordd.prg(278) Error E0022 Invalid lvalue ':'
It says:
adordd\adordd.prg(278) Error E0022 Invalid lvalue ':'
Muchas gracias. Many thanks.
Un saludo, Best regards,
Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]
Implementando MSVC 2010, FWH64 y ADO.
Abandonando uso xHarbour y SQLRDD.
Un saludo, Best regards,
Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]
Implementando MSVC 2010, FWH64 y ADO.
Abandonando uso xHarbour y SQLRDD.
Re: ADO RDD xHarbour
Lucas,
I have no idea why that error. Here its ok. Is that a compile error?
I posted new adordd.prg and .ch with LOCATE ready. https://github.com/AHFERREIRA/adordd.git
Now you dont need to alter anything
I have some funny problem here but I dont know if it is caused by new LOCATE.
Please check it yourself.
I have no idea why that error. Here its ok. Is that a compile error?
I posted new adordd.prg and .ch with LOCATE ready. https://github.com/AHFERREIRA/adordd.git
Now you dont need to alter anything
I have some funny problem here but I dont know if it is caused by new LOCATE.
Please check it yourself.
Regards
Antonio H Ferreira
Antonio H Ferreira
- lucasdebeltran
- Posts: 1303
- Joined: Tue Jul 21, 2009 8:12 am
- Contact:
Re: ADO RDD xHarbour
Antonio,
Thank you.
What sort of new problems did you find?.
Thank you.
What sort of new problems did you find?.
Muchas gracias. Many thanks.
Un saludo, Best regards,
Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]
Implementando MSVC 2010, FWH64 y ADO.
Abandonando uso xHarbour y SQLRDD.
Un saludo, Best regards,
Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]
Implementando MSVC 2010, FWH64 y ADO.
Abandonando uso xHarbour y SQLRDD.
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: ADO RDD xHarbour
I am moving our disucssions to this thread to keep them at one main place.
You said:
Most date fields in various SQL servers store acutally date-time values, not pure truncated date values. Please keep in mind that I said "most" not "all".
If for some reasons, the value stored in the field is 28/04/2015 00:00:00.001 then this field value is greater than pure date 28/04/2015. Years back I struggled till I found that xHarbour was adding one extra milli second. ( I do not know if this is ok now)
We need to be extra-cautious while dealing with dates in sql databases. For the purpose of ADORDD, please return truncated date ( with valtype 'D') when the FieldType is "D" and full value with valtype 'T' when the field type is 'T'.
I suggest you return FW_TTOD( <fieldvalue> ) when the FieldType is 'D' and FW_DTOT( <fieldvalue> ) when the field value is 'T'. We use this in our XBrowse, TDataRow and TRecSet so that users are insulated from this behavior.
We need to keep this in mind when preparing SQL statements comparing Dates.
For example, SELECT * WHERE INVDT BETWEEN '2015-04-01' AND '2015-04-30' may totally exclude all transactions that took place on 30th Apr 2015. Because this is actually translated as INVDT >= '2015-04-01 00:00:00' and INVDT <= '2015-04-30 00:00:00'. Naturally this query ignores transactions from '2015-04-30 00:00:00.001' till '2015-04-30 23:59:59.999'
This is just an example to show how deceptive can be date comparisons. In addition MS Sql server has a very awkward habit of storing '2014-04-01' internally as '2014-04-01 12:00:00' in the field.
So, the safer construct is SELECT * WHERE INVDT >= '2015-04-01' AND INVDT < '2015-05-01'. I still see many amatuers committing this mistake which turns out to be a blunder in real life situations.
I hope if you keep this points in mind, everything will work as expected.
You said:
First recommended caution is to keep always Century on.(ownd:numera)->dataultmov is 28/04/15
dDataM is 28/04/15
if (ownd:numera)->dataultmov > dDataM
msginfo("Data do ult doc "+dtoc((ownd:numera)->dataultmov)+CRLF+;
"Data deste doc "+dtoc(dDataM) )
endif
The code inside the IF should never be executed but it is and the msginfo shows both with the same date 28.04.15.
What might be the reason?
Most date fields in various SQL servers store acutally date-time values, not pure truncated date values. Please keep in mind that I said "most" not "all".
If for some reasons, the value stored in the field is 28/04/2015 00:00:00.001 then this field value is greater than pure date 28/04/2015. Years back I struggled till I found that xHarbour was adding one extra milli second. ( I do not know if this is ok now)
We need to be extra-cautious while dealing with dates in sql databases. For the purpose of ADORDD, please return truncated date ( with valtype 'D') when the FieldType is "D" and full value with valtype 'T' when the field type is 'T'.
I suggest you return FW_TTOD( <fieldvalue> ) when the FieldType is 'D' and FW_DTOT( <fieldvalue> ) when the field value is 'T'. We use this in our XBrowse, TDataRow and TRecSet so that users are insulated from this behavior.
We need to keep this in mind when preparing SQL statements comparing Dates.
For example, SELECT * WHERE INVDT BETWEEN '2015-04-01' AND '2015-04-30' may totally exclude all transactions that took place on 30th Apr 2015. Because this is actually translated as INVDT >= '2015-04-01 00:00:00' and INVDT <= '2015-04-30 00:00:00'. Naturally this query ignores transactions from '2015-04-30 00:00:00.001' till '2015-04-30 23:59:59.999'
This is just an example to show how deceptive can be date comparisons. In addition MS Sql server has a very awkward habit of storing '2014-04-01' internally as '2014-04-01 12:00:00' in the field.
So, the safer construct is SELECT * WHERE INVDT >= '2015-04-01' AND INVDT < '2015-05-01'. I still see many amatuers committing this mistake which turns out to be a blunder in real life situations.
I hope if you keep this points in mind, everything will work as expected.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: ADO RDD xHarbour
You said in the other thread.
Please see for reference:
https://msdn.microsoft.com/en-us/librar ... s.10).aspx
"https://msdn.microsoft.com/en-us/librar ... s.10).aspx"
Extracts:
It appears multi-record locking does not seem possible in ADO. Anyway you need to keep experimenting more on this, simultaneously working as two users on the same table.
All updates within one transaction block either they get written or abandoned but never written partially. Normally used for multi-table updataions with the same connection.
Talking about transactions, they work for a single connection. If we open recordsets with connection string each of them will get a separate connection.
Glad to know it is working well with both client and server-side.I´ve tested it and it works perfectly with adUseclient and adUserServer cursors.
Please see for reference:
https://msdn.microsoft.com/en-us/librar ... s.10).aspx
"https://msdn.microsoft.com/en-us/librar ... s.10).aspx"
Extracts:
andadLockPessimistic 2 This value indicates pessimistic locking, record by record. The provider does what is necessary to ensure successful editing of the records, usually by locking records at the data source immediately after editing.
This lock type is supported by the Microsoft® OLE DB Provider for AS/400 and VSAM and the Microsoft OLE DB Provider for DB2. However, the OLE DB Provider for AS/400 and VSAM internally maps this lock type to adLockBatchOptimistic.
You said:The adLockPessimistic setting is not supported if the CursorLocation property is set to adUseClient. If an unsupported value is set, then no error will result; the closest supported LockType will be used instead.
Good Idea.So we never call :Update() in ADO_PUTVALUE and ADO_APPEND and the :Update is then called only ADO_UNLOCK. Right?
Yes.The app Im converting gets all the new records an locks and then goes through the Locklist array of each table processing each replace.
Since we move the record we lost the physical lock right?
It appears multi-record locking does not seem possible in ADO. Anyway you need to keep experimenting more on this, simultaneously working as two users on the same table.
Transactions and locking are two different things altogether.Starting a transaction can eliminate this ?
All updates within one transaction block either they get written or abandoned but never written partially. Normally used for multi-table updataions with the same connection.
Talking about transactions, they work for a single connection. If we open recordsets with connection string each of them will get a separate connection.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: ADO RDD xHarbour
I dont have these functions. Can you post them here?I suggest you return FW_TTOD( <fieldvalue> ) when the FieldType is 'D' and FW_DTOT( <fieldvalue> ) when the field value is 'T'. We use this in our XBrowse, TDataRow and TRecSet so that users are insulated from this behavior.
To avoid apps code change then we could do it:So, the safer construct is SELECT * WHERE INVDT >= '2015-04-01' AND INVDT < '2015-05-01'. I still see many amatuers committing this mistake which turns out to be a blunder in real life situations.
SELECT * WHERE INVDT BETWEEN '2015-04-01'+'00:00:00:000' AND '2015-04-30'+'23:59:59.999'
adding the time part to the date at adordd.
Resuming we always add at adordd the time part of the date like that. Right?
Thanks so much for your help and expertise.
Regards
Antonio H Ferreira
Antonio H Ferreira
Re: ADO RDD xHarbour
It works in the sense of the locking (with 2 users the 2nd cannot edit) but changing order focus we build a new recordset with the order by clause and closing the current one throws an error.Glad to know it is working well with both client and server-side.
Also if we get the locks and move to other records we loose it.
I think the only alternative is to have another field or a table to do it but we still didn't find how.
Do you have any idea?
Also using adUseclient seems not to work ok with our browses. adUseServer ok.
But adUseServer doesnt work with Browse() in ACCESS.
Dont know why.
Regards
Antonio H Ferreira
Antonio H Ferreira
Re: ADO RDD xHarbour
Please check ADO_LOCATE.lucasdebeltran wrote:Antonio,
Thank you.
What sort of new problems did you find?.
If we call successive locates although it goes through the records correctly in the do while it does not evaluate the block to .t. after the first time.
Please try:
Code: Select all
do while n < 20
locate for whateverfield = whatevervalue // existing in the table
if found()
msginfo("found()")
else
msginfo("not found()")
endif
n++
enddo
Can you see it?
We are looking for a explanation.
Antonio, Mr Rao, do you have some clue?
Regards
Antonio H Ferreira
Antonio H Ferreira