Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recreate views using SELECT * due to changed structure
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Database:
Firebird
Divers
Thread ID:
01411088
Message ID:
01411099
Vues:
35
What seems to be a problem?

>
>I have a few tables that will have it's structure updated by the user. For that reason the RVs to the tables are created using SELECT * as I don't know what fields will be in there. I have some old code which is working in this direction but I don't know if this is the most efficient or safe way to do this.
>
>Any suggestions are welcome.
>
>
		WAIT WINDOW "Recreating View with updated fieldnames" NOWAIT
>
>		vp_iPID    = 0
>		vp_AllRecs = 0
>		lcViewName = IIF(goApp.UseLocalData(), "l", "r") + THIS.aCursors[1]
>		llRetVal   = .T.
>		lcViewCode = DBGETPROP(lcViewName, "VIEW", "SQL")
>
>
>		THIS.SetDefaultDatabase()
>
>		&lcViewCode
>
>
>		* View Properties
>		DBSETPROP(lcViewName, 'View', 'UpdateType'      , 1)
>		DBSETPROP(lcViewName, 'View', 'WhereType'       , 1)
>		DBSETPROP(lcViewName, 'View', 'FetchMemo'       , .T.)
>		DBSETPROP(lcViewName, 'View', 'SendUpdates'     , .T.)
>		DBSETPROP(lcViewName, 'View', 'UseMemoSize'     , 255)
>		DBSETPROP(lcViewName, 'View', 'FetchSize'       , 100)
>		DBSETPROP(lcViewName, 'View', 'MaxRecords'      , -1)
>		DBSETPROP(lcViewName, 'View', 'Tables'          , SUBSTR(lcViewName, 4))
>		DBSETPROP(lcViewName, 'View', 'Comment'         , [])
>		DBSETPROP(lcViewName, 'View', 'BatchUpdateCount', 1)
>		DBSETPROP(lcViewName, 'View', 'ShareConnection' , .F.)
>		DBSETPROP(lcViewName, 'View', 'Prepared'        , .F.)
>		DBSETPROP(lcViewName, 'View', 'CompareMemo'     , .T.)
>		DBSETPROP(lcViewName, 'View', 'FetchAsNeeded'   , .F.)
>		DBSETPROP(lcViewName, 'View', 'RuleExpression'  , [])
>		DBSETPROP(lcViewName, 'View', 'RuleText'        , [])
>		DBSETPROP(lcViewName, 'View', 'ParameterList'   , [vp_ipid, 'N'])
>
>
>		lnOldArea       = SELECT(0)
>		lcConnectName   = DBGETPROP(lcViewName, 'View', 'ConnectName')
>
>
>		* View Field Properties
>		SELECT 0
>		USE (lcViewName)
>
>		lnFields = AFIELDS(laFields)
>
>		FOR lnCnt = 1 TO lnFields
>			SELECT (lcViewName)
>
>			lcField = lcViewName + "." + laFields[lnCnt, 1]
>
>			DBSETPROP(lcField, 'Field', 'KeyField'           , UPPER(laFields[lnCnt, 1]) = "IID")
>			DBSETPROP(lcField, 'Field', 'Updatable'          , .T.)
>			DBSETPROP(lcField, 'Field', 'UpdateName'         , SUBSTR(lcViewName, 4) + "." + laFields[lnCnt, 1])
>		ENDFOR
>
>		USE IN (lcViewName)
>
>		SELECT (lnOldArea)
>
>		WAIT WINDOW "Finished Recreating View with updated fieldnames" NOWAIT
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform