Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A NICE message when Primary Key is violated
Message
 
 
To
07/05/2001 02:26:35
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00503380
Message ID:
00504281
Views:
17
>Hi nadya,
>
>>I thing you're wrong. We use TableBuffering, yet we can't issue APPEND BLANK, if one blank record is already in a table. The error message appears immediatelly, before TableUpdate.
>
>When using either table or recordbuffering you can append a blank record as long as you do not move from this record. Try this:
>
>USE MyTableWithBlankRecord
>cursorsetprop("Buffering",3)
>APPEND BLANK
>
>It won't error you. Only Until you're trying to leave the record with LOCATE, APPEND BLANK, SKIP, etc or you want to commit the record with TABLEUPDATE() it will generate the errormessage
>
>Walter,

Hi Walter,

I solved the problem. Our class has Add_Post_Hook method. In this method I do the following:
********************************************************************
*  Description.......: TableMaint.Add_Post_Hook
*  Calling Samples...:
*  Parameter List....:
*  Created by........:
*  Modified by.......: Nadya Nosonovsky 06/20/2000 12:44:40 PM
********************************************************************
local lcOrder, lcNewCode, lcGrdSource, lnFieldLen
lcOrder=order()
if !empty(filter())
     wait window nowait 'The filter is now turning off in order to add...'
     set filter to && Turn off the filter
endif
if !empty(m.lcOrder) and !empty(for(tagno(m.lcOrder))) && Filtered index        
        wait window nowait 'The filtered index is now turning off in order to add...'
     set order to && Filtered indexes cause problems in add mode
     thisform.navstand.lstOrders.enable() && Update lstOrders
endif
lcGrdSource=thisform.grdTable.RecordSource
if type('['+m.lcGrdSource+".code"+']')="C"
   select max(code) from (m.lcGrdSource) into array laArr 
   lnFieldLen=len(laArr[1])-1   
   lcNewCode=iif(m.lnFieldLen>0,left(laArr[1],m.lnFieldLen),"")+chr(asc(right(laArr[1],1))+1)  
   replace code with m.lcNewCode
endif
IOW, I pre-populate the code with the next code in sequence. It works.

Thanks to everyone for ideas.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform