Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you ROLLBACK a view
Message
From
05/03/1998 03:27:14
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
04/03/1998 17:49:56
Edward Crawford
City Facilities Management
Glasgow, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00082524
Message ID:
00082634
Views:
33
>>>I have 2.6 tables that I need to be able to place in a tranaction and be able to roll back. You can't rollback a table that is not a member of a database container, but Jim Booth pointed out to me that I could use an Updateable view. What is the procedure for rolling back an updateable view? Here is roughly what I am doing, but it doesn't seem to work:
>>>
>>>TableA (2.6 table)
>>>ViewA (Updateable view made up of fields from TableA)
>>>
>>>CURSORSETPROP("buffering", 5, "TableA")
>>>
>>>BEGIN TRANSACTION
>>> IF !UpdateTableA()
>>> llSuccess = .F.
>>> ENDIF
>>> IF !UpdateTableB()
>>> llSuccess = .F.
>>> ENDIF
>>> IF !UpdateTableC()
>>> llSuccess = .F.
>>> ENDIF
>>> IF llSuccess = .T.
>>> ENDTRANSACTION
>>> ELSE
>>> ROLLBACK
>>> ENDIF
>>>
>>>********************
>>>Method UpdateTableA (UdateTableB and UpdateTableC the same)
>>>
>>>SELECT ViewA
>>>APPEND BLANK
>>>REPLACE ViewA.Field1 WITH "Test",
>>> ViewA.Field2 WITH "Test2"
>>>
>>>TABLEUPDATE(0,.T., "TableA")
>>Ed, I think you'd better set the view updateable and update it. This would update base tables provided that you set the correct update options.
>
>Cetin
>
>In the Update Criteria Tab, the correct table is selected, I have all of the fields set to updatable, the send SQL Updates box is checked, and the Key and Updatable Fields radio button is selected.
>I do this:
> SELECT ViewA
> APPEND BLANK
> REPLACE ViewA.Test WITH "Test"
>
>When I look at TableA, it has not been updated. When I look at ViewA the View displays the added field and entry. But when I click on something in the browse window for ViewA. I get the error "Cannot insert an empty row from a view into its base table". I must be missing something basic here. Have any ideas?
>
>Ed
Ed, I think I couldn't express what I mean.
*CURSORSETPROP("buffering", 5, "TableA")
CURSORSETPROP("buffering", 5, "ViewA")  && 3 would cause an implicit tableupdate(0) when row loses focus
*TABLEUPDATE(0,.T., "TableA")
TABLEUPDATE(0,.T., "ViewA")             && tableupdate
It was the viewA that should be updated not tableA. TableA would be updated for it's the base table. No buffering on it here.
Another point I suggest :
*  SELECT ViewA
*  APPEND BLANK
*  REPLACE ViewA.Test WITH "Test"
insert into viewA (test) values ("Test")
The following code is one test code and insert data to an fp 2.x table. Works well.
close all
open datab cetin  && view is in dbc, base tables of view are fp 2.x
use "cetdeneme1"  && view
cursorsetprop("Buffering",5,"cetdeneme1")
for ix = 1 to 20
  insert into cetdeneme1 ;
       (fiat,evr_no) values ;
       ((reccount()+1)*100,reccount()+1)
endfor

begin transaction
if tableupdate(2,.t.,"cetdeneme1")
  end transaction
else
  rollback
endif
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform