Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trigger failure
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00828142
Message ID:
00828980
Views:
13
The problem would not really be with your INSERT SQL. What we need is your trigger or record validation code that you have in the DBC or an external procedure file. Is this an INSERT TRIGGER or record validation rule in your table[s]?

>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
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform