Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do you ROLLBACK a view
Message
De
06/03/1998 11:22:29
Edward Crawford
City Facilities Management
Glasgow, Royaume Uni
 
 
À
06/03/1998 06:07:35
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00082524
Message ID:
00083019
Vues:
34
>>>Snip..
>>>>Hi Barbara:
>>>>
>>>>That's what I needed to know. I don't get errors know, but the base still is not being updated. Do I have to do something to comit the change to the base table?
>>>>
>>>>Ed
>>>Hi Ed,
>>>Could you please write your revised code ?
>>>Cetin
>>
>>Hi Cetin:
>>
>>Here it is:
>>
>>TableA (2.6 table)
>>ViewA (Updateable view made up of fields from TableA)
>>
>>llSuccess = .T.
>>CURSORSETPROP("buffering", 5, "ViewA")
>>
>> 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., "ViewA")
>Hi Ed,
>Am I missing something here ? (Assumed function really returned the tableupdate result instead of .t. always)
>- Call uptadetableA -> Add a record to TableA with "test","test2" + blank record to TableB+TableC
>- Call uptadetableB -> Add a record to TableB with "test","test2" + blank record to TableA+TableC
>- Call uptadetableC -> Add a record to TableC with "test","test2" + blank record to TableA+TableB
>Doing one "append blank" to view + replacing all necessary fields then tableupdate() would update base tables A,B,C provided all necessary keyfields and updatable fields are set. And why use tableupdate(0) instead of tableupdate(2) (buffering -> 5) ?
>So try with this code :
>
>* In viewA
>* TableA - Field1,Field2
>* TableB - Field3,Field4
>* TableC - Field5,Field6
>
>CURSORSETPROP("buffering", 5, "ViewA")
>
>BEGIN TRANSACTION
>insert into ViewA ;
> (Field1,Field2,Field3,Field4,Field5,Field6) ;
> values ;
> ("TestA","Test2A","TestB","Test2B","TestC","Test2C")
>
>IF tableupdate(2,.t.,"ViewA")
> END TRANSACTION
>ELSE
> ROLLBACK
>ENDIF
>
>
>Cetin

Hi Cetin:

THe sample code I gave was just that, a sample. I just wanted to show the general idea of what I was ultimately going to do. I just wanted to show that I was initialized a variable to T, starting a transaction, making several method calls which return either T or F depending on the TABLEUPDATE() result. I only showed method UpdateTableA to show that I am updating a table, view or something. Updating the view is just one method that is called. UpdateTableB and UpdateTableC would do totally diferent things, but they would still return a boolean depending on the outcome. Sorry if I confused you. What I am trying to do right now is get the 2.6 base table to update, then I will actually write the transaction. I am typing the following at the command line:

OPEN DATABASE Data
SELECT 0
USE TableA
SELECT 0
USE Data!ViewA
CURSORSETPROP("buffering", 5, "ViewA")
SELECT ViewA
INSERT INTO ViewA(Dnis) VALUES("Test")
TABLEUPDATE(2,.T., "ViewA")

The record is in ViewA, but not in base table. TABLEUPDATE() returns F, AERROR() shows Error 1547, "Cannot insert an empty row from a view
into its base table".
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform