Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check duplicate in table buffered mode?
Message
From
19/10/1997 22:56:32
Shihchau Tai
Apic Systems Pte Ltd
Singapore, Singapore
 
 
To
19/10/1997 13:27:32
Juan Kh
Dataprop Technologies
Sungai Petani, Malaysia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00055264
Message ID:
00055445
Views:
30
>Hi John,
>
>The main reason I seek from both ends is, if the first encounter is the current record I'm in (lnRecNo = RECNO()), I need to seek further down to see if there is really a copy of myself down there. I can do this in Access by using ObjectVariable.FindNext, but I don't know how to do that in VFP. The mechanism in my code is just a trick, there is no absolute way of solving this problem.
>
>
>In order to make the routine generic, you need to at least pass two parameters to it, one is the Alias and the other is the IndexedField you like to search on. Since the new records appended in a buffered table is not visible in other DataSession (prior to the issuance of TABLEUPDATE()), you need to make sure you are in the same DataSession with the calling function.
>
>Using the YourTable again in another area with different alias with not allow you to see the records you have just appended (where RECNO() < 0).
>
>Regards,
>juan
>

Just for info, I actually check before I insert/append. I have an if-else statement for the two cases to check whether it is in table buffering mode or not. For the second case, I just seek for the value and if found, return the status. However I did remeber the recno and move the pointer back after the search. It seems to work fine.

FUNCTION chk_dupl
PARAMETERS expr, table_name, tag

LOCAL nWorkarea, lsuccess, nParm

lsuccess = .F.

nParm = PARAMETERS()
IF nParm=1 OR nParm=2
RETURN lsuccess
ENDIF

IF CURSORGETPROP('BUFFERING',table_name)<4
nWorkarea = SELECT()

SELECT 0
USE &table_name ALIAS search_tableA AGAIN
SET ORDER TO &tag

lsuccess = SEEK(expr, 'search_tableA')

SELECT search_tableA
USE
SELECT (nWorkarea)
ELSE
IF EOF()
GO BOTTOM
ENDIF
lnRecNo = RECNO()
SET ORDER TO &tag ASCENDING &&SEEK FROM TOP
IF SEEK(expr, table_name)
lsuccess = .T.
ENDIF

GO (lnRecNo)
ENDIF
RETURN lsuccess

ENDFUNC


Tai
Previous
Reply
Map
View

Click here to load this message in the networking platform