Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update a table in a database with a view
Message
De
05/06/2007 06:45:20
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
05/06/2007 06:03:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01230467
Message ID:
01230490
Vues:
21
>Now my code is like this, but still no effect. Isn't that strange?
>
>**************************************************************************
>
>CREATE SQL VIEW view5 AS SELECT &m_selectvelden FROM ALLTRIM(m_dbf2) WHERE SUBSTR(postcode, 1, 2) = ThisForm.cmbpostcode.DisplayValue
>
>USE view5
>=DBSETPROP('view5.uniekid','Field','KeyField',.T.)
>=DBSETPROP('view5.uniekid','Field','UpDatable',.F.)
>
>SELECT velden
>GO TOP
>DO WHILE NOT EOF()
> m_objectnm1 = 'view5.' + ALLTRIM(LOWER(veldnaam))
> m_veldnaam = ALLTRIM(LOWER(veldnaam))
> SELECT view5
> =DBSETPROP(ALLTRIM(m_objectnm1), 'Field', 'UpDatable', .T.)
> =DBSETPROP(ALLTRIM(m_objectnm1), 'Field', 'KeyField', .F.)
> =DBSETPROP(ALLTRIM(m_objectnm1), 'Field', 'UpdateName', ALLTRIM(m_dbf2) + '.' + ALLTRIM(m_veldnaam))
> SELECT velden
> SKIP
>ENDDO
>
>=DBSETPROP('view5', 'View', 'Tables', ALLTRIM(m_dbf2))
>=DBSETPROP('view5', 'View', 'WhereType', 1)
>=DBSETPROP('view5', 'View', 'SendUpdates', .T.)
>
>SELECT view5
>
>** Inhere I change some data..............
>BROW
>
>TABLEUPDATE(.T.)
>
>** Then closing te view...
>IF INDBC(ALLTRIM(m_alias), 'TABLE')
> SELECT ALLTRIM(m_alias)
> USE
> FREE TABLE ALLTRIM(m_dbf)
>ELSE
> SELECT ALLTRIM(m_alias)
> USE
>ENDIF
>
>CLOSE DATABASES ALL
>USE ALLTRIM(m_dbf) EXCL
>PACK
>
>ThisForm.Release
>
>RELEASE ALL
>CLOSE ALL
>CLEAR EVENTS

Ron,
1) I don't see UpdateName entry for "uniekid". Though for a key field your intention might be set it to not updatable, include its updatename. Otherwise it doesn't update (maybe a bug I don't know, it's the case with SPT and I think same would apply to views as well).

2) "CREATE SQL VIEW view5 AS SELECT &m_selectvelden FROM ALLTRIM(m_dbf2) WHERE SUBSTR(postcode, 1, 2) = ThisForm.cmbpostcode.DisplayValue"

The definition of view is weird and makes me think that you're creating an updatable view on the fly. A view is stored in a dbc (yet another table) and if I'm right in my suspicion then you'd end with an ever growing dbc. Hopefully I'm wrong, otherwise think of alternatives like making parts of it parametric instead of hardcoding like that.

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform