Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem tableupdating remote view
Message
From
08/05/2002 01:20:41
 
 
To
07/05/2002 23:30:32
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00653475
Message ID:
00653856
Views:
21
>I'd be inclined to add a dbo. in front of the View's Tables property and the UpdateName property for PSIS.NPLA, also to fix the FetchSize property (the default of 100 may cause errors if there are > 100 records) but I agree there is no obvious error...
>
>I recommend you recreate the view from scratch.
>
>Regards
>
>JR

OK, Here is a clue. v_plsis was created by the following program. If I delete the view and create it with the view designer the tableupdate() works.

Now the question is, what is wrong with the code used to create the views.

I got this code from Barbara Peisch's site and modified it.

What do you think? Thanks.

Alex
* 1. Create the connection and set its propeties.  This works fine.

* 2. Create views with the selects I have in a table
* Typical mRemoteSel is [SELECT * from dbo.plsis] or [SELECT * from dbo.plsis plsis]
lc = [CREATE SQL VIEW "]+ALLTRIM(TablDict.cViewName) ;
     + [" REMOTE CONNECTION "coneccion" AS ] ;
     + ALLTRIM(TablDict.mRemoteSel)
&lc

* Populate aFlds with the information about the updateable fields from the view
...
AFIELDS('aFlds',lcViewName)	&& Populate the array with the field definitions
* Remove fields that are not updateable
SetViewProperties(lcViewName,lcMainTable,.F.)


PROCEDURE SetViewPropeties
LPARAMETERS pViewName, pSourceTable, pPKUpdateable

DBSetProp(pViewName, 'View', 'UpdateType', 1)
DBSetProp(pViewName, 'View', 'WhereType', 1)	&& Key only
DBSetProp(pViewName, 'View', 'FetchMemo', .T.)
DBSetProp(pViewName, 'View', 'SendUpdates', .T.)
DBSetProp(pViewName, 'View', 'UseMemoSize', 255)
DBSetProp(pViewName, 'View', 'FetchSize', 100)
DBSetProp(pViewName, 'View', 'MaxRecords', -1)
DBSetProp(pViewName, 'View', 'Tables', pSourceTable)
DBSetProp(pViewName, 'View', 'Prepared', .F.)
DBSetProp(pViewName, 'View', 'CompareMemo', .T.)
DBSetProp(pViewName, 'View', 'FetchAsNeeded', .F.)
DBSetProp(pViewName, 'View', 'FetchSize', 100)
DBSetProp(pViewName, 'View', 'Comment', "")
DBSetProp(pViewName, 'View', 'BatchUpdateCount', 1)
DBSetProp(pViewName, 'View', 'ShareConnection', .F.)
for li = 1 to alen(aFlds,1)
  if li = 1
    dbsetprop(pViewName+'.'+aFlds[li,1], 'Field', 'KeyField', .T.)
  else
    dbsetprop(pViewName+'.'+aFlds[li,1], 'Field', 'KeyField', .F.)
  endif
  if li <> 1 or (pPKUpdateable)
    dbsetprop(pViewName+'.'+aFlds[li,1], 'Field', 'Updatable', .T.)
    dbsetprop(pViewName+'.'+aFlds[li,1], 'Field', 'UpdateName', pSourceTable+'.'+aFlds[li,1])
    DO CASE
      CASE aFlds[li,2]$'NF'
        dbsetprop(pViewName+'.'+aFlds[li,1], 'Field', 'DataType', ;
                  aFlds[li,2]+'('+ltrim(str(aFlds[li,3]))+','+ltrim(str(aFlds[li,4]))+')')
      CASE aFlds[li,2]='C'
        dbsetprop(pViewName+'.'+aFlds[li,1], 'Field', 'DataType', ;
        aFlds[li,2]+'('+ltrim(str(aFlds[li,3]))+')')
      CASE aFlds[li,2]='B'
        dbsetprop(pViewName+'.'+aFlds[li,1], 'Field', 'DataType', ;
                  aFlds[li,2]+'('+ltrim(str(aFlds[li,4]))+')')
      CASE aFlds[li,2]$'DTIMGL'
        dbsetprop(pViewName+'.'+aFlds[li,1], 'Field', 'DataType',aFlds[li,2])
      OTHERWISE
        dbsetprop(pViewName+'.'+aFlds[li,1], 'Field', 'DataType', ;
                  aFlds[li,2]+'('+ltrim(str(aFlds[li,3]))+','+ltrim(str(aFlds[li,4]))+')')
    ENDCASE				
  else
    dbsetprop(pViewName+'.'+aFlds[li,1], 'Field', 'Updatable', .F.)
  endif
endfor
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform