Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Do not understand view behavior
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Do not understand view behavior
Miscellaneous
Thread ID:
00753207
Message ID:
00753207
Views:
68
I have used database containers and free tables for most of my development. But now I have a project that needs views. I don't get there behavior I think. This is the error I get:"Cannot insert an empty row from a view into its base table(s)." I also get "uniqueness is violated" when I do table update. My view is described below and I have checked "send sql updates" and update using "sql update".
* my view
SELECT *;
 FROM  property!propnum INNER JOIN property!pocontact ;
   ON  Propnum.contactid = Pocontact.memoid;
 WHERE SUBSTRC(Propnum.groupid,1,2) = "CF"
My big issue is ADDING records. As you can see I have at least one modified field exists. I get the error when I do a TableUpdate when clicking the save button. I use save button to check for valid entries in 4 fields before doing the table update. If the validation returns false I ask the user id they want to fix the record, if not I issue a revert (which does not work either) and the record is still saved in the base tables.
My understanding is that the tables used in the view are updated when the tableupdate is done, but the record is updated in the base tableS whether the table update is done or not! So how can I do a revert is the update is not successful? Does the sql insert automatically update the view and its base tables? There is no book or FAQ that explains this completely.
I hope someone can explain this behavior, because I just can't get it.

This is the add button click code:
WITH ThisForm
  LOCAL nNew_Property_Number,nGrpIdVal,lcFocus
  nNew_Property_Number = nextnum('propnum') && stored proc for next id
  .aRemovePN(1) = nNew_Property_Number

  IF .pgPropTypes.ActivePage = 2
     nGrpIdVal = 'PC'+ALLTRIM(STR(nNew_Property_Number))
     INSERT INTO (.p_CurDbf) (nproperty,groupid) VALUES nNew_Property_Number,nGrpIdVal)
     lcFocus = ".txtOrgCode"
  ELSE
     INSERT INTO (.p_CurDbf) (nproperty) VALUES (nNew_Property_Number)
     lcFocus = ".txtGroupId"
  ENDIF 
  .Refresh  
  &lcFocus..SetFocus
ENDWITH
Extreme Programming = Plan -> Design -> Code -> Test
Next
Reply
Map
View

Click here to load this message in the networking platform