Discussion:
Adding fields using oodml
(too old to reply)
Mark
2008-10-18 15:48:25 UTC
Permalink
I have an app that updates the contents of fields in other folders from the main app folder. If the structure of the table in the main folder changes, I would like to programmatically add a new field to the other folders before updating field values.

Is there a way to programatically add a field to a rowset that is active using oodml, then update the value of the new field?

I seem to have trouble using the following, since type and length are read only property:

c = new Field()
c.fieldName := cFieldName
c.type := form.rowset.fields[cFieldName].type
c.length := form.rowset.fields[cFieldName].length
oObject.qCODE.rowset.fields.add(c)

Many thanks for any ideas on this,
Mark
Ken Mayer [dBVIPS]
2008-10-19 04:27:49 UTC
Permalink
Post by Mark
I have an app that updates the contents of fields in other folders from the main app folder. If the structure of the table in the main folder changes, I would like to programmatically add a new field to the other folders before updating field values.
Is there a way to programatically add a field to a rowset that is active using oodml, then update the value of the new field?
c = new Field()
c.fieldName := cFieldName
c.type := form.rowset.fields[cFieldName].type
c.length := form.rowset.fields[cFieldName].length
oObject.qCODE.rowset.fields.add(c)
This adds a *TEMPORARY* field, it is not permanent and will not remain
in the table. To programmatically add a field to a table, you have to
use either local SQL (ALTER TABLE), or perhaps examine code in the dUFLP
(ModiStru.cc). In any case, I wouldn't do this to an active rowset -- I
would de-activate it first ...

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Mark
2008-10-19 21:28:30 UTC
Permalink
Thanks Ken. ModiStru.cc worked great.

Mark
Post by Ken Mayer [dBVIPS]
Post by Mark
I have an app that updates the contents of fields in other folders from the main app folder. If the structure of the table in the main folder changes, I would like to programmatically add a new field to the other folders before updating field values.
Is there a way to programatically add a field to a rowset that is active using oodml, then update the value of the new field?
c = new Field()
c.fieldName := cFieldName
c.type := form.rowset.fields[cFieldName].type
c.length := form.rowset.fields[cFieldName].length
oObject.qCODE.rowset.fields.add(c)
This adds a *TEMPORARY* field, it is not permanent and will not remain
in the table. To programmatically add a field to a table, you have to
use either local SQL (ALTER TABLE), or perhaps examine code in the dUFLP
(ModiStru.cc). In any case, I wouldn't do this to an active rowset -- I
would de-activate it first ...
Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/
*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Loading...