Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine between Insert or Replace?

Status
Not open for further replies.

Redsz

Programmer
Jul 30, 2002
158
0
0
CA
Is their a way to determine between an insert statment and a replace statment in a table validation rule? Using VFP8 SP1!

EG:

IF INSERT STATEMENT
* do nothing
else
* do something
endif

Thx for your reply!
 
While you might be able to "guess" most of the time, I'm sure it wouldn't be absolutely reliable.
Code:
IF RECNO() = RECCOUNT() && it's probably an Insert
*                       Note: This could also be true in an
*                             APPEND BLANK, REPLACE situation
*
ELSE && it's probably a Replace / Update SET
*
ENDIF
Rick
 
I have made several post's regarding the issue and i really have a hard time explaing the problem but i will try again.

Table test has a logical field lsend (default .t.) and an autoincrementing field nid. The table has a validation rule of setsend() in a db stored procedure.

Code:
FUNCTION setsend()
    * Don't do it if lSend is getting replaced
    IF TYPE("lsend") = "L"
	    IF CURVAL("lSend") = lsend
	        replace lSend WITH .T.
	    ENDIF
	ENDIF 
ENDFUNC

With data buffering enabled i am getting a data type mismatch error whenever i issue an insert statement. The only way around this is to use append blank followed by a replace. There is some type of a conflict that is happening between the autoincrement field and the rule.

My final thought was if an insert statment was being issued then ignore the rule as the field lsend is defaulted to .t..

Thx for your reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top