TMysql Seek not working

TMysql Seek not working

Postby compaqt » Thu Dec 06, 2012 7:14 pm

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' )
Gagan Raj
GTalk: csplsurat@gmail.com
WhatsApp: +91 9879000301
compaqt
 
Posts: 34
Joined: Wed Jun 17, 2009 5:52 pm

Re: TMysql Seek not working

Postby ShumingWang » Fri Dec 07, 2012 1:40 am

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
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 460
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: TMysql Seek not working

Postby richard-service » Fri Dec 07, 2012 1:10 pm

Hi Wang

This tmysql.prg and mysql.c new version?
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v5.7 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 767
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: TMysql Seek not working

Postby ShumingWang » Sat Dec 08, 2012 3:10 am

Richard,
Updated just now.

Regards!
Shuming Wang
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 460
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: TMysql Seek not working

Postby richard-service » Sun Dec 09, 2012 5:26 am

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 v5.7 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 767
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 26 guests