Dear Rao Sir ,
Expecting .F. value when oRs:Seek( Alltrim ( chr( nKey) ) , .T. ) method fails to seek the desired record. But the oRs:Seek method always return .T.
Please guide me on this. Thanks in advance...!
Thanks
Shridhar
MariaDB Rowset Seek Method returns always .T.
MariaDB Rowset Seek Method returns always .T.
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
Re: MariaDB Rowset Seek Method returns always .T.
Hi,
I Think it's happening because you are using softseek(.T.), IF you do oRs:Seek( Alltrim ( chr( nKey) ) ) this does not happen.
I Think it's happening because you are using softseek(.T.), IF you do oRs:Seek( Alltrim ( chr( nKey) ) ) this does not happen.
Re: MariaDB Rowset Seek Method returns always .T.
Hi Vilian F. Arraes ,
I am using DBF Seek Approach where SoftSeek also returns .F. value when record not found.
Need to know more about MariaDB Rowset behavior compare to DBF Record.
Thanks
Shridhar
I am using DBF Seek Approach where SoftSeek also returns .F. value when record not found.
Need to know more about MariaDB Rowset behavior compare to DBF Record.
Thanks
Shridhar
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: MariaDB Rowset Seek Method returns always .T.
OT: AllTrim() for CHR(nKey) may not be necessary because CHR(nKey) is a single character and where nKey = 32, AllTrim() produces undesirable result of "" instead of the required " ".
Present behavior of RowSet Seek method:
Syntax:
oRs:Seek( uSeek, [lSoftSeek = .f.], [lWildSeek = .f.] ) --> lFound
oRs:Seek( uSeek ) or oRs:Seek( uSeek, .f. ):
Locates the first record from top where fieldvalue = uSeek (case insensitive). If found, moves record pointer to the matching record, sets oRs:lFound to .t. and returns .t..
If a match is not found, does not move the record pointer, sets oRs:lFound to .f. and returns .f..
In the case of descending order, the search is reversed.
SoftSeek:
oRs:Seek( uSeek, .t. )
Locates the first record from top where fieldvalue >= uSeek (case insensitive). If found, moves record pointer to the matching record, sets oRs:lFound to .t. and returns .t..
If an exact match or next higher value is not found, does not move the record pointer, oRs:lFound is set to .f. and returns .f.
For better clarity, this example can be used.
Comparison with DBSEEK()
1) DbSeek() moves record pointer to eof() when a match is not found and in case of softseek, next higher value also is not found. oRs:Seek() does not move record pointer in such cases.
2) In the case of softseek, DbSeek() returns .f., when an exact match is not found even though the next higher value is found. oRs:Seek() returns .t. if exact match or next higher value is found and returns .f. only when the next higher value is also not found.
Present behavior of RowSet Seek method:
Syntax:
oRs:Seek( uSeek, [lSoftSeek = .f.], [lWildSeek = .f.] ) --> lFound
- Works only when the rowset is sorted on any column(s).
Seek is performed on the sorted column.
In the case of character values, the search is caseinsensitive.
oRs:Seek( uSeek ) or oRs:Seek( uSeek, .f. ):
Locates the first record from top where fieldvalue = uSeek (case insensitive). If found, moves record pointer to the matching record, sets oRs:lFound to .t. and returns .t..
If a match is not found, does not move the record pointer, sets oRs:lFound to .f. and returns .f..
In the case of descending order, the search is reversed.
SoftSeek:
oRs:Seek( uSeek, .t. )
Locates the first record from top where fieldvalue >= uSeek (case insensitive). If found, moves record pointer to the matching record, sets oRs:lFound to .t. and returns .t..
If an exact match or next higher value is not found, does not move the record pointer, oRs:lFound is set to .f. and returns .f.
For better clarity, this example can be used.
Code: Select all
function TestSeek()
local oCn := FW_DemoDB()
local oRs
oRs := oCn:RowSet( "states" )
oRs:Sort := "CODE" // Same as oRs:SetOrder( "CODE" ) / oRs:OrdSetFocus( "CODE" )
oRs:GoTop() // Same as oRs:MoveFirst()
// Now the values of the field "CODE" are arranged in this order:
//
// AK,AL,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,
// MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,RI,
// SC,SD,TN,TX,UT,VA,VT,WA,WI,WV,WY
//
// HardSeek
? oRs:Code // -> AK
? oRs:Seek( "C" ), oRs:Code // .T., CA
? oRs:Seek( "E" ), oRs:Code // .F., CA
? oRs:Seek( "X" ), oRs:Code // .F., CA
oRs:GoTop()
// SoftSeek
? oRs:Code // -> AK
? oRs:Seek( "C", .t. ), oRs:Code // .T., CA
? oRs:Seek( "E", .t. ), oRs:Code // .T., FL
? oRs:Seek( "X", .t. ), oRs:Code // .F., FL
oRs:Close()
oCn:Close()
return nil
1) DbSeek() moves record pointer to eof() when a match is not found and in case of softseek, next higher value also is not found. oRs:Seek() does not move record pointer in such cases.
2) In the case of softseek, DbSeek() returns .f., when an exact match is not found even though the next higher value is found. oRs:Seek() returns .t. if exact match or next higher value is found and returns .f. only when the next higher value is also not found.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: MariaDB Rowset Seek Method returns always .T.
Dear Rao Sir ,
Thanks a lot for the detailed explanation. Now I have to change the code accordingly.
Thanks
Shridhar
Thanks a lot for the detailed explanation. Now I have to change the code accordingly.
Thanks
Shridhar
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
Re: MariaDB Rowset Seek Method returns always .T.
Hello (sorry for my english)
Can I Seek for two fields?
For example: I've a Table with LAST and FIRST; How?
My select say ... ORDER BY LAST, FIRST
Can I Seek for two fields?
For example: I've a Table with LAST and FIRST; How?
My select say ... ORDER BY LAST, FIRST
Resistencia - "Ciudad de las Esculturas"
Chaco - Argentina
Chaco - Argentina
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: MariaDB Rowset Seek Method returns always .T.
No please.
Instead you may use
The search condition should be in dbf syntax.
Instead you may use
Code: Select all
oRs:Locate( "last = 'ge' .and. first = 'aa'" ) //--> lfound
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: MariaDB Rowset Seek Method returns always .T.
Many thanks Mr. Rao
Resistencia - "Ciudad de las Esculturas"
Chaco - Argentina
Chaco - Argentina