Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem tableupdating remote view
Message
From
08/05/2002 13:10:52
 
 
To
08/05/2002 04:51:39
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00653475
Message ID:
00654095
Views:
24
Success!

I wish to thank to all of you who helped me zero in on the problem. Actually John Ryan was on target about what the problem was, but this has been a team effort and I have learned a lot. I am adding a star to three messages.

The problem came out when I compared the two gendbc programs: I neglected to call the table dbo.plsis.

Thanks again.

Alex
>
>Since your view works when created manually, I suggest you do the following:
>
>- create your view manually
>- run GenDbc against your working view
>- create the view using your code
>- run GenDbc against the non-working view
>- compare the generated view definitions with a tool like BeyondCompare to find out what is different
>
>HTH
>>>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
Reply
Map
View

Click here to load this message in the networking platform