I am using tmysql and trying to seek a value:
oFasmast := oServer:Query( 'Select id, Account from fasmast order by id' )
oFasmast:seek( 20 )
It doesn't return any value nor does the record is positioned to the required record. The record with this id value exists.
I also tried (but no results):
oFasmast:seek( 20, .F., 'id' )
TMysql Seek not working
-
- Posts: 465
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China
- Contact:
Re: TMysql Seek not working
oquery:seek(20,.f.,{||oquery:id})
?id // 20
This is my tmysql.prg www.xtech.com.cn/down/tmysql.prg, www.xtech.com.cn/down/mysql.c
METHOD Seek( xValue,lSoftSeek,cFieldNames,llast) CLASS TMySQLQuery
local nstart,nend,nretry:=0,Xvalue0:=Xvalue,ctype:=VALTYPE(xValue)
default lSoftSeek to .t.
DEFAULT llast TO .f.
if ctype=="C"
if len(xValue)<LEN(cvaltochar(if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)))
xValue:=PADR(xValue,len(cvaltochar(if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)))," ")
end
xValue:=UPPER(xValue)
xValue0:=UPPER(xValue0)
end
::lFound := .f.
::GoTop()
if RIGHT(UPPER(RIGHT(::cquery,8)),4)=="DESC"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue
if !lSoftseek
::GoBottom()
end
return ::lFound
end
if valtype(xValue)=="C"
::GoBottom()
if left(if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames)),len(Xvalue0))==Xvalue0
::lfound:=.t.
return ::lfound
else
::GoTop()
end
end
while .t.
nStart:=1
nEnd:=::lastrec()
while nEnd-nStart>1
::GoTo( nStart+int( (nEnd-nStart)/2))
if ctype<>"C"
Do Case
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue
nend := ::nCurRow
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue
::lFound := .t.
exit
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)>xValue
nStart := ::nCurRow
endcase
else
Do Case
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))<xValue
nend := ::nCurRow
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))==xValue
::lFound := .t.
exit
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))>xValue
nStart := ::nCurRow
endcase
endif
enddo
if ::lFound; exit; end
::GoTo(nStart)
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue ; ::lfound :=.t.; exit; end
if ctype=="C"
if left(if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
end
::GoTo(nEnd)
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue ; ::lfound :=.t.; exit; end
if ctype=="C"
if left(if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
end
exit
enddo
if !::lFound.and.!lSoftseek; ::GoBottom(); end
if ::lfound.and.llast
while nEnd-nStart>1
::GoTo( nStart+int( (nEnd-nStart)/2))
if ctype<>"C"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue
nend := ::nCurRow
else
// if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames))==xValue
nStart := ::nCurRow
end
else
if if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))<xValue
nend := ::nCurRow
else
// if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames))==xValue
nStart := ::nCurRow
end
endif
enddo
::GoTo(nEnd)
if ctype<>"C"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue; ::GoTo(nStart); end
else
if if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))<xValue; ::GoTo(nStart); end
endif
end
else
if ctype=="C"
if left(if(VALTYPE(cfieldnames)=="B",UPPER(cvaltochar(EVAL(cfieldnames))),UPPER(cvaltochar(&cFieldNames))),len(Xvalue0))==Xvalue0
::lfound:=.t.
return ::lFound
end
end
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)>xValue
if !lSoftseek
::GoBottom()
end
return ::lFound
end
while .t.
nStart:=1
nEnd:=::lastrec()
while nEnd-nStart>1
::GoTo( nStart+int( (nEnd-nStart)/2))
if ctype<>"C"
Do Case
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)>xValue
nend := ::nCurRow
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue
::lFound := .t.
exit
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue
nStart := ::nCurRow
endcase
else
Do Case
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))>xValue
nend := ::nCurRow
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))==xValue
::lFound := .t.
exit
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))<xValue
nStart := ::nCurRow
endcase
endif
enddo
if ::lFound; exit; end
::GoTo(nStart)
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue ; ::lfound :=.t.; exit; end
if ctype=="C"
if left(if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
end
::GoTo(nEnd)
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue ; ::lfound :=.t.; exit; end
if ctype=="C"
if left(if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
end
exit
enddo
if !::lFound.and.!lSoftseek; ::GoBottom(); end
if ::lfound.and.llast
while nEnd-nStart>1
::GoTo( nStart+int( (nEnd-nStart)/2))
if ctype<>"C"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)>xValue
nend := ::nCurRow
else
// if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue
nStart := ::nCurRow
end
else
if if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))>xValue
nend := ::nCurRow
else
// if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue
nStart := ::nCurRow
end
endif
enddo
::GoTo(nEnd)
if ctype<>"C"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)>xValue; ::GoTo(nStart); end
else
if if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))>xValue; ::GoTo(nStart); end
end
end
end
Return ::lFound
Regards!
Shuming Wang
?id // 20
This is my tmysql.prg www.xtech.com.cn/down/tmysql.prg, www.xtech.com.cn/down/mysql.c
METHOD Seek( xValue,lSoftSeek,cFieldNames,llast) CLASS TMySQLQuery
local nstart,nend,nretry:=0,Xvalue0:=Xvalue,ctype:=VALTYPE(xValue)
default lSoftSeek to .t.
DEFAULT llast TO .f.
if ctype=="C"
if len(xValue)<LEN(cvaltochar(if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)))
xValue:=PADR(xValue,len(cvaltochar(if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)))," ")
end
xValue:=UPPER(xValue)
xValue0:=UPPER(xValue0)
end
::lFound := .f.
::GoTop()
if RIGHT(UPPER(RIGHT(::cquery,8)),4)=="DESC"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue
if !lSoftseek
::GoBottom()
end
return ::lFound
end
if valtype(xValue)=="C"
::GoBottom()
if left(if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames)),len(Xvalue0))==Xvalue0
::lfound:=.t.
return ::lfound
else
::GoTop()
end
end
while .t.
nStart:=1
nEnd:=::lastrec()
while nEnd-nStart>1
::GoTo( nStart+int( (nEnd-nStart)/2))
if ctype<>"C"
Do Case
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue
nend := ::nCurRow
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue
::lFound := .t.
exit
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)>xValue
nStart := ::nCurRow
endcase
else
Do Case
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))<xValue
nend := ::nCurRow
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))==xValue
::lFound := .t.
exit
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))>xValue
nStart := ::nCurRow
endcase
endif
enddo
if ::lFound; exit; end
::GoTo(nStart)
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue ; ::lfound :=.t.; exit; end
if ctype=="C"
if left(if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
end
::GoTo(nEnd)
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue ; ::lfound :=.t.; exit; end
if ctype=="C"
if left(if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
end
exit
enddo
if !::lFound.and.!lSoftseek; ::GoBottom(); end
if ::lfound.and.llast
while nEnd-nStart>1
::GoTo( nStart+int( (nEnd-nStart)/2))
if ctype<>"C"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue
nend := ::nCurRow
else
// if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames))==xValue
nStart := ::nCurRow
end
else
if if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))<xValue
nend := ::nCurRow
else
// if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames))==xValue
nStart := ::nCurRow
end
endif
enddo
::GoTo(nEnd)
if ctype<>"C"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue; ::GoTo(nStart); end
else
if if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))<xValue; ::GoTo(nStart); end
endif
end
else
if ctype=="C"
if left(if(VALTYPE(cfieldnames)=="B",UPPER(cvaltochar(EVAL(cfieldnames))),UPPER(cvaltochar(&cFieldNames))),len(Xvalue0))==Xvalue0
::lfound:=.t.
return ::lFound
end
end
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)>xValue
if !lSoftseek
::GoBottom()
end
return ::lFound
end
while .t.
nStart:=1
nEnd:=::lastrec()
while nEnd-nStart>1
::GoTo( nStart+int( (nEnd-nStart)/2))
if ctype<>"C"
Do Case
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)>xValue
nend := ::nCurRow
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue
::lFound := .t.
exit
case if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue
nStart := ::nCurRow
endcase
else
Do Case
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))>xValue
nend := ::nCurRow
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))==xValue
::lFound := .t.
exit
case if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))<xValue
nStart := ::nCurRow
endcase
endif
enddo
if ::lFound; exit; end
::GoTo(nStart)
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue ; ::lfound :=.t.; exit; end
if ctype=="C"
if left(if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
end
::GoTo(nEnd)
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue ; ::lfound :=.t.; exit; end
if ctype=="C"
if left(if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
end
exit
enddo
if !::lFound.and.!lSoftseek; ::GoBottom(); end
if ::lfound.and.llast
while nEnd-nStart>1
::GoTo( nStart+int( (nEnd-nStart)/2))
if ctype<>"C"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)>xValue
nend := ::nCurRow
else
// if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue
nStart := ::nCurRow
end
else
if if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))>xValue
nend := ::nCurRow
else
// if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)==xValue
nStart := ::nCurRow
end
endif
enddo
::GoTo(nEnd)
if ctype<>"C"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)>xValue; ::GoTo(nStart); end
else
if if(VALTYPE(cfieldnames)=="B",UPPER(EVAL(cfieldnames)),UPPER(&cFieldNames))>xValue; ::GoTo(nStart); end
end
end
end
Return ::lFound
Regards!
Shuming Wang
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
- richard-service
- Posts: 807
- Joined: Tue Oct 16, 2007 8:57 am
- Location: New Taipei City, Taiwan
- Has thanked: 1 time
- Contact:
Re: TMysql Seek not working
Hi Wang
This tmysql.prg and mysql.c new version?
This tmysql.prg and mysql.c new version?
Best Regards,
Richard
Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
Richard
Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
-
- Posts: 465
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China
- Contact:
Re: TMysql Seek not working
Richard,
Updated just now.
Regards!
Shuming Wang
Updated just now.
Regards!
Shuming Wang
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
- richard-service
- Posts: 807
- Joined: Tue Oct 16, 2007 8:57 am
- Location: New Taipei City, Taiwan
- Has thanked: 1 time
- Contact:
Re: TMysql Seek not working
ShumingWang wrote:Richard,
Updated just now.
Regards!
Shuming Wang
Thank you so much.
Best Regards,
Richard
Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
Richard
Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit