Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL View from view designer
Message
 
 
To
25/05/1998 13:40:57
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00101710
Message ID:
00101729
Views:
27
Kendall,

>Yea, that's what I was thinking too. I did create the view with CREATE SQL VIEW and tried to edit it in the view designer and got the same result.

If it can't create it, it surely can't edit it. *s* You'll have to make edits within the .prg.

>It is annoying though that I can't use the designer to set field props because the designer trashes the joins and output fields when I try to edit the view.

Use DBSetProp() if you are copying properties from the underlying data source for the view column use DBGetProp() for the table and use that for DBSetProp().

Here's a util I use to do this:
* dbcViewProp.prg
* copies properties from the table field definitions to the view fields
lcDBC = set( "database" )
if ( empty( lcDBC ) )
   open database ?
   lcDBC = set( "database" )
   if ( empty( lcDBC ) )
      return .f.
   endif
endif

lcDBC = lcDBC + ".dbc"

local gaTables[1], gaFields[1], gaViews[1], laProperties[6]

laProperties[1] = "Caption"
laProperties[2] = "Comment"
laProperties[3] = "DisplayClass"
laProperties[4] = "DisplayClassLibrary"
laProperties[5] = "Format"
laProperties[6] = "InputMask"
*laProperties[] = ""

select ObjectName, "" ;
   from (lcDBC) ;
   into array gaViews ;
   where objecttype = "View"

lnViews = _tally
for i = 1 to lnViews
   gaViews[i,1] = lower( alltrim( gaViews[i,1] ) )
   gaViews[i,2] = lower( dbgetprop( gaViews[i,1], "view", "tables" ) + " " )
endfor

select DBC.ObjectName, Tables.ObjectName ;
   from (lcDBC) as DBC;
   inner join (lcDBC) as Tables ;
      on dbc.ParentID = tables.ObjectID ;
   into array gaFields ;
   where DBC.objecttype = "Field" and tables.ObjectType = "View"

for i = 1 to _tally
   gaFields[i,1] = lower( alltrim( gaFields[i,1] ) )
   gaFields[i,2] = alltrim( gaFields[i,2] ) + "." + gaFields[i,1]
   lcField = dbgetprop( gaFields[i,2], "Field", "UpdateName" )

   j = at( ".", lcField )
   if ( j = 0 )
      * not a field from a table, likely to be calculated
      loop
   endif
   
   j = at( "!", lcField )
   if ( j > 0 )
      * pull the database name off
      lcField = substr( lcField, j + 1 )
   endif

   lcField = chrtran( lcField, "*", "" )

   for j = 1 to alen( laProperties )
      dbsetprop( gaFields[i,2], "Field", laProperties[j], dbgetprop( lcField, "Field", laProperties[j] ) )
   endfor
endfor

return .t.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform