Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trigger failure
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Trigger failure
Miscellaneous
Thread ID:
00828142
Message ID:
00828142
Views:
49
I'm using VFP 8 on Win2k and have a database error upon attempting a SQL INSERT, as in the following code. The snippet of code comes from a form in which users may add new vendors to a vendor list.

After first finding out if the vendor already exists (the view doesn't have an index) the first INSERT adds a record to a local view, while the second one attempts to do so for the parent.

The first INSERT succeeds, but upon execution of the second INSERT statement, the update trigger for the vendor field- there's a rule to prevent the field from being EMPTY()- the trigger fails, and my user-defined failure message appears.

In stepping through the code, I can see that all of the values to be inserted do indeed exist. In addition, if I attempt a similar action at the command line- doing an INSERT into the table- there is no failure. I'd be very grateful if anyone could tell me why. Thanks!

Henry

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

LOCATE FOR vendor = ThisForm.txtVendor.Value
IF FOUND()
= MessageBox("This vendor already exists.", 48, "On file!")
ELSE
INSERT INTO (lcAlias) ;
(vendor, address, city, state, zipcode, phone, products) ;
VALUES (ALLTRIM(ThisForm.txtVendor.Value), ;
ALLTRIM(ThisForm.txtAddress.Value), ;
ALLTRIM(ThisForm.txtCity.Value), ;
ALLTRIM(ThisForm.txtState.Value), ;
ALLTRIM(ThisForm.txtZip.Value), ;
ALLTRIM(ThisForm.txtPhone.Value), ;
ALLTRIM(ThisForm.txtProducts.Value))

llUpdatedView = TABLEUPDATE(1, .T., (lcAlias))

** SELECT pickit
INSERT INTO pickit (vendor, address, city, state, zipcode, phone, products) ;
VALUES (ALLTRIM(ThisForm.txtVendor.Value), ;
ALLTRIM(ThisForm.txtAddress.Value), ;
ALLTRIM(ThisForm.txtCity.Value), ;
ALLTRIM(ThisForm.txtState.Value), ;
ALLTRIM(ThisForm.txtZip.Value), ;
ALLTRIM(ThisForm.txtPhone.Value), ;
ALLTRIM(ThisForm.txtProducts.Value))

llUpdatedParent = TABLEUPDATE(1, .T., "pickit")

IF (llUpdatedView AND llUpdatedParent)
MESSAGEBOX("Record added successfully.", 64 + 0, "Ok!")
ELSE
MESSAGEBOX("Record was not added.", 16 + 0, "Failed!")
ENDIF

ENDIF
Next
Reply
Map
View

Click here to load this message in the networking platform