Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check my logic please
Message
 
 
À
21/02/2002 13:32:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00623306
Message ID:
00623524
Vues:
9
I don't understand it. Could you describe in words, what this code is supposed to do?

The simplest way to avoid validation from firing twice would be to use the idea, I described... However, it would mean, what call or rule should be changed...

>I'm using VFP 5.0a
>
>My views all have the field validation rules copied from the underlying tables.
>
>I'm trying to find a way to prevent the validation rule from executing twice, 1st when the view is edited and 2nd when TABLEUPDATE() is issued.
>
>Can you think of anything wrong with this logic?
>
>This is just the logic, not the coding, so ignore syntax.
>
>FORM
>    property aViews(1)
>
>    INIT()
>        for each cursor in dataenvironment
>            if cursor is a view
>                ** store object reference for each view
>                add row(n) to this.aViews
>                this.aViews(n) = CreateObject('View_Validation',alias())
>            endif
>        endfor
>
>    DESTROY()
>        ** release all object references
>        this.aViews = .null
>
>ENDFORM
>
>
>
>DEFINE CLASS View_Validation as line
>    aVars(1) = ''    && holds list of public variables to release in DESTROY()
>
>    INIT()
>        lparameters tcAlias
>
>        ** create public variable to store Primary Keys edited in view
>        cViewVar = 'gcView' + tcAlias
>        public &cViewVar(1)
>
>        ** store public variable name so DESTROY() can release
>        this.aVars(1) = cViewVar
>
>        for each cTable in cursorgetprop('Tables')
>            cTableVar = 'gcTable' + cTable
>
>            ** store variable name of view associated with Table
>            **     so validation() can find it
>            public &cTableVar
>            &cTableVar = cViewVar
>
>            ** store public variable name so DESTROY() can release
>            add row(n) to this.aVars
>            this.aVars(n) = cTableVar
>        endfor
>
>    DESTROY()
>        for each cVar in this.aVars
>            release &cVar
>        endfor
>ENDDEFINE
>
>
>
>FIELD VALIDATION RULE
>    cTableVar = 'gcTable' + alias()     && public variable associated with Table
>    cViewVar = 'gcView' + alias()       && public variable associated with View
>
>    Do Case
>        case type(cViewVar) = 'C'
>            ** Editing View
>            ** store list of Primary Keys edited
>            if ascan(cViewVar,<Primary Key Value>) = 0
>                add row(n) to &cViewVar
>                &cViewVar(n) = <Primary Key Value>
>            endif
>        case type(cTableVar) = 'C'
>            ** Editing Underlying Table
>            ** get name of variable containing list of Primary Keys edited
>            cViewVar = &cTableVar
>
>            if ascan(cViewVar,<Primary Key Value>) <> 0
>                ** already edited in view
>                return .t.
>            endif
>    EndCase
>
>    <rest of field validation>
>    .....
>
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform