on 03-18-2015 1:43 PM
i need to create indexes on a table X<n>_Table; So for example, if the EMPLOYEE table has 3 indexes, the index names will be:
X1_EMPLOYEE
X2_EMPLOYEE
X3_EMPLOYEE
I have modified the index template on the detail page "PDM Generation Options" as "X_%TABLE%; It works but it generates index names as
X_EMPLOYEE1
X_EMPLOYEE2
X_EMPLOYEE3
not the way i want ( I want the incremental number next to X) ?
How do i change the index template so PD generates it the way I want?
thanks
Krishna
Hi Krishna,
I would recommed you to use Extended Model Definition to do such kind of customization.
I avoid customizating the XDB becuase of the administration effort it requeires to maintain it updated in case of applying PD updates. I however recognize that sometimes customizing the XBD is the only option to achive something we need.
But it is not for your case. Add the index metaclass and use the Initialize event handler (for the sample below seems to be better) to call the code that names indexes according to your need.
Sample code:
dim terminacao, intervalo, sequencial
dim pos, lpos
if inStr(lcase(obj.Code),"_" & obj.parent.code) > 0 then
pos = inStr(lcase(obj.Code),"X")
lpos = pos + 1
if cInt(Mid(obj.Code,lpos,1)) > 0 then
sequencial = cInt(Mid(obj.code,lpos,1))
elseif cInt(Mid(obj.Code,lpos,1)) > 0 then
sequencial = cInt(Mid(obj.code,lpos,1))
end if
else
dim idx, nSeqIdx
nSeqIdx = 0
for each idx in obj.Parent.Indexes
if inStr(idx.Code,"_" & obj.parent.code) > 0 then
pos = inStr(lcase(idx.Code),"X")
lpos = pos + 2
output Mid(idx.Code,lpos,1)
if cInt(Mid(idx.Code,lpos,1)) > 0 then
if nSeqIdx <= cInt(Mid(idx.Code,lpos,1)) then
nSeqIdx = cInt(Mid(idx.Code,lpos,1))
end if
elseif cInt(Mid(idx.Code,lpos,2)) > 0 then
if nSeqIdx <= cInt(Mid(idx.Code,lpos,2)) then
nSeqIdx = cInt(Mid(idx.Code,lpos,2))
end if
end if
end if
next
if nSeqIdx <= 0 then
sequencial = 1
else
sequencial = nSeqIdx + 1
end if
end if
obj.SetNameAndCode "X" & cStr(sequencial) & "_" & obj.parent.code, "X" & cStr(sequencial) & "_" & obj.parent.code, true
Hope this helps
Regards,
-Paulo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.