Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can I gen view def programmatically, one view at a time?
Message
De
01/07/2002 17:37:11
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00674114
Message ID:
00674152
Vues:
33
David F,

Thanks. This looks pretty cool. I may be able to make use of it. Also, if you see the replies from Sergey, it looks like Gendbcx, gentable and genview will do exactly what I need.




>David,
>
>Look at DBGetProp().
>
>Here's some code I wrote a long time ago to migrate table field level properties up to view fields. It should give you a few ideas.
>
>
* dbcViewProp.prg 08-May-98
>
>* load all view field properties from the underlying table field properties
>
>* Copyright 1998 DF Software Development, Inc.
>* http://www.geocities.com/ResearchTriangle/9834/
>* Unrestricted public use
>
>* Standard disclaimer: Backup your DBC files before running this program
>* I'm not liable for any damages. While this utility works great on my
>* views it may fail on the views you have created.
>
>local lcDBC, laFields[1], laViews[1], laProperties[6], i, j
>
>lcDBC = set( "database" )
>if ( empty( lcDBC ) )
>   * no database open so prompt for one
>   open database ?
>   lcDBC = set( "database" )
>   if ( empty( lcDBC ) )
>      return .f.
>   endif
>endif
>
>lcDBC = lcDBC + ".dbc"
>
>* list of field properties to copy over to the view
>* the list of properties is in the help for DBGetProp
>
>laProperties[1] = "Caption"
>laProperties[2] = "Comment"
>laProperties[3] = "DisplayClass"
>laProperties[4] = "DisplayClassLibrary"
>laProperties[5] = "Format"
>laProperties[6] = "InputMask"
>*laProperties[] = ""
>
>* find all the views in the database
>
>select ObjectName, "" ;
>   from (lcDBC) ;
>   into array laViews ;
>   where objecttype = "View"
>
>* self join to find all of the view fields
>
>select DBC.ObjectName, Tables.ObjectName ;
>   from (lcDBC) as DBC;
>   inner join (lcDBC) as Tables ;
>      on dbc.ParentID = tables.ObjectID ;
>   into array laFields ;
>   where DBC.objecttype = "Field" and tables.ObjectType = "View"
>
>wait window "Updating view fields" nowait
>
>for i = 1 to _tally
>   laFields[i,1] = lower( alltrim( laFields[i,1] ) )
>   laFields[i,2] = alltrim( laFields[i,2] ) + "." + laFields[i,1]
>   lcField = dbgetprop( laFields[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, "*", "" )
>
>   * set the properties
>
>   for j = 1 to alen( laProperties )
>      dbsetprop( laFields[i,2], "Field", laProperties[j], ;
>            dbgetprop( lcField, "Field", laProperties[j] ) )
>   endfor
>endfor
>
>wait clear
>use in (lcDBC)
>return .t.
>
>
>>I know that I can get my database/table/view definitions programmatically by running gendbc. But what I am looking for is a way to generate the programmatic definitions one-at-a-time, so I don't have to run gendbc on the whole database, everytime I add/change a view.
>>
>>I envision a function like:
>>ViewToCode(cDatabase,cViewName,cOutputfile,lappendtooutput)
>>
>>Does a tool/function like this exist?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform