Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create entity in vbscript

10 views
Skip to first unread message

Amy

unread,
Mar 25, 2009, 2:22:31 PM3/25/09
to
In PD 12 I have a need to create a bunch of history tables.
Each history table has the same six columns. The plan is to
create the table then run a vbscipt to populate it with
column/attributes.

In PD 11 I did something like:
if not EntityAttributeExists(oTargetEntity.attributes,
sName, sDomain, sComment, bMandatory) then
'Try to find the data item.
Set dataItem = getDataItemObj(sName, sDomain, sComment)
if not (dataItem is nothing) then
'Reuse this data item.
Set newAttribute =
oTargetEntity.Attributes.CreateNewAt(oTargetEntity.attributes.count)
newAttribute.DataItem = dataItem
This works fine in PD 11 but in PD 12 it error on the
newAttribute.DataItem = dataItem line.

EntityAttribute
Cannot set value '' for attribute Data Item Information of
Entity Attribute 'EmployeeHistory.Attribute_194': Data Item
Information cannot be set to this value (Exception occurred.
(0x80020009))
At line 1256, character 8

Any Help would be great.
Amy

Matt Creason

unread,
Mar 27, 2009, 4:27:41 PM3/27/09
to
Hi Amy,

This could be because the getDataItemObj is returning an object,
therefore dataItem is not getting set to a valid object.data item you
are setting is not an actual object.

Or, you now have to turn validation mode off, assign the dataitem, turn
validation mode on.

Set cObj = pObj.Attributes.CreateNew()
Set nObj = cObj.DataItem
aFnd = False
ScanAttribute mdl, nm, aObj, aFnd
If aFnd Then
validationmode= false
set cObj.dataitem = aObj
validationmode= true
nObj.delete
nObj = cObj.DataItem
End If

What criteria are you using to determine whether to reuse or build new.

HTH,
-Matt C.
Matt Creason

randy.buchholz

unread,
Mar 27, 2009, 4:26:27 PM3/27/09
to
Someone posted a script to do that a while ago. Try a search for "Audit" I
believe that will get you there.

<Amy> wrote in message news:49ca7667.244...@sybase.com...

Amy

unread,
Apr 3, 2009, 12:20:57 PM4/3/09
to
Hi Matt,

THANKS.

The validationmode= false and validationmode= true did the
trick.
To answer your question on what criteria I am using to
create or reuse. If the exact dataitem already exists then
reuse it (99% of the time this is the case), if not create
one. That way one dataitem is shared amongst all of the
History tables. If I need to increase the size of the data
item, say from a varchar(50) to varchar(128) then I can just
do it in one spot. This is why the method that Randy was
suggesting was not correct for my situation.

Thanks again, Amy

> > tes.count) newAttribute.DataItem = dataItem

0 new messages