Is record in index ??
Is record in index ??
How can I efficiently determine if a specific record exists in an index using XSharp? Are there any built-in functions or methods available for this purpose?
Re: Is record in index ??
Hi Daniel,
What do you mean by "index"?
What do you mean by "index"?
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Re: Is record in index ??
BTW,
here is my solution which seems to work
METHOD IsRecordInOrder(nRecno,nOrder) // class MyDBServer inherit DBServer
LOCAL lOk AS LOGIC
LOCAL uTop AS USUAL
LOCAL uBottom AS USUAL
LOCAL uValue AS USUAL
LOCAL nOldRec AS DWORD
LOCAL nOldOrder AS DWORD
Default(@nRecno,0)
Default(@nOrder,0)
IF nRecno > 0
nOldRec := SELF:Recno
SELF:goto(nRecno)
ENDIF
IF nOrder > 0
nOldOrder := SELF:orderinfo(DBOI_NUMBER)
SELF:setorder(nOrder)
ENDIF
BEGIN SEQUENCE
// Index-Bedingung
IF SELF:orderinfo(DBOI_ISCOND)
IF !Evaluate(SELF:orderinfo(DBOI_CONDITION))
BREAK
ENDIF
ENDIF
// Scope
uTop := SELF:orderinfo(DBOI_SCOPETOP)
uBottom := SELF:orderinfo(DBOI_SCOPEBOTTOM)
IF !Empty(uTop) .OR. !Empty(uBottom)
uValue := SELF:Orderkeyval
IF SELF:Orderdescend()
IF !Empty(uTop)
IF uValue > uTop
BREAK
ENDIF
ENDIF
IF !Empty(uBottom)
IF uValue < uBottom
BREAK
ENDIF
ENDIF
ELSE
IF !Empty(uTop)
IF uValue < uTop
BREAK
ENDIF
ENDIF
IF !Empty(uBottom)
IF uValue > uBottom
BREAK
ENDIF
ENDIF
ENDIF
ENDIF
lOk := TRUE
END SEQUENCE
IF nOrder > 0
SELF:setorder(nOldOrder)
ENDIF
IF nRecno > 0
SELF:goto(nOldRec)
ENDIF
RETURN lOk
here is my solution which seems to work
METHOD IsRecordInOrder(nRecno,nOrder) // class MyDBServer inherit DBServer
LOCAL lOk AS LOGIC
LOCAL uTop AS USUAL
LOCAL uBottom AS USUAL
LOCAL uValue AS USUAL
LOCAL nOldRec AS DWORD
LOCAL nOldOrder AS DWORD
Default(@nRecno,0)
Default(@nOrder,0)
IF nRecno > 0
nOldRec := SELF:Recno
SELF:goto(nRecno)
ENDIF
IF nOrder > 0
nOldOrder := SELF:orderinfo(DBOI_NUMBER)
SELF:setorder(nOrder)
ENDIF
BEGIN SEQUENCE
// Index-Bedingung
IF SELF:orderinfo(DBOI_ISCOND)
IF !Evaluate(SELF:orderinfo(DBOI_CONDITION))
BREAK
ENDIF
ENDIF
// Scope
uTop := SELF:orderinfo(DBOI_SCOPETOP)
uBottom := SELF:orderinfo(DBOI_SCOPEBOTTOM)
IF !Empty(uTop) .OR. !Empty(uBottom)
uValue := SELF:Orderkeyval
IF SELF:Orderdescend()
IF !Empty(uTop)
IF uValue > uTop
BREAK
ENDIF
ENDIF
IF !Empty(uBottom)
IF uValue < uBottom
BREAK
ENDIF
ENDIF
ELSE
IF !Empty(uTop)
IF uValue < uTop
BREAK
ENDIF
ENDIF
IF !Empty(uBottom)
IF uValue > uBottom
BREAK
ENDIF
ENDIF
ENDIF
ENDIF
lOk := TRUE
END SEQUENCE
IF nOrder > 0
SELF:setorder(nOldOrder)
ENDIF
IF nRecno > 0
SELF:goto(nOldRec)
ENDIF
RETURN lOk
Re: Is record in index ??
Probably i miss the obvious - but why not doing a "Seek" in the order?
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Re: Is record in index ??
Karl,
because the indexkey might not be unique
Karl
because the indexkey might not be unique
Karl
Re: Is record in index ??
Ah, I was missing the obvious, was working on some help advanced topics and was thinking about the record type in c# and index in an array
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu