MarkButler
Programmer
I have a problem where I insert a number of records into a table using an updateable view. Once I issue the tableupdate(.t.) I get an error stating that I have a non-unique candidate key. Following is the basic code.
---------------------------
<code>SELECT 0
USE parameterizedview NODATA
CURSORSETPROP('Buffering',5)
*
SELECT 0
CREATE CURSOR textrecs (primarykey C(10), candidatekey C(10))
APPEND FROM textfile.txt TYPE DELIMITED
SCAN
SCATTER MEMVAR
SELECT parameterizedview
m.primarykey=textrecs.primarykey && parameter for view
=REQUERY()
IF RECCOUNT()=0
INSERT INTO parameterizedview FROM MEMVAR
ELSE
GATHER MEMVAR
ENDIF
SELECT textrecs
ENDSCAN
*
SELECT parameterizedview
=TABLEUPDATE(.T.) <b>&& this is where I get the error</b>
*
CLOSE ALL
RETURN</code>
--------------------------
I look at the input and there is no violation, actually I remove the candidate key, run the code and then make the key a candidate and all is well. In reality the parameterized view and underlying DBF are empty, so in essence this is a load of the data.
Anyone got any ideas? TIA
Mark
---------------------------
<code>SELECT 0
USE parameterizedview NODATA
CURSORSETPROP('Buffering',5)
*
SELECT 0
CREATE CURSOR textrecs (primarykey C(10), candidatekey C(10))
APPEND FROM textfile.txt TYPE DELIMITED
SCAN
SCATTER MEMVAR
SELECT parameterizedview
m.primarykey=textrecs.primarykey && parameter for view
=REQUERY()
IF RECCOUNT()=0
INSERT INTO parameterizedview FROM MEMVAR
ELSE
GATHER MEMVAR
ENDIF
SELECT textrecs
ENDSCAN
*
SELECT parameterizedview
=TABLEUPDATE(.T.) <b>&& this is where I get the error</b>
*
CLOSE ALL
RETURN</code>
--------------------------
I look at the input and there is no violation, actually I remove the candidate key, run the code and then make the key a candidate and all is well. In reality the parameterized view and underlying DBF are empty, so in essence this is a load of the data.
Anyone got any ideas? TIA
Mark