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

Populate array

122 views
Skip to first unread message

Steve

unread,
Oct 11, 2007, 4:57:30 PM10/11/07
to
Been away from PB (9.0.03) for awhile and I'm wondering if there is a
quicker way to populate a structure.

for i = 1 to ll_rowcount
luo_customerProfiles[i].effectiveDate =
lds_accountProfileTemp.getItemDateTime(i, 'efectiveDate')
next

I know I can get all the elements from the datastore quickly into an array
using dot notation:

datetime ll_effective[]
ll_effective = lds_accountProfileTemp.object.effectiveDate.Primary


I just can't figure our how to tie it all together:
-- This doesn't work:
luo_customerProfile[].effectiveDate = ll_effective[]

Hope this pseudo code is enough info; I didn't write the code. Need some
speed increase without a redesign. This structure can have a lot of
elements, and there are a lot more columns than just effectiveDate.

Thanks for any help.

- Steve


Jeremy Lakeman

unread,
Oct 11, 2007, 7:32:24 PM10/11/07
to

If the structure has the same column order and number of fields you
can use this syntax:
luo_customerProfiles=lds_accountProfileTemp.object.data

bede

unread,
Oct 15, 2007, 8:09:48 AM10/15/07
to
Just loop it?

For i=upperbound(ll_effective[]) To 1 Step -1
luo_customerProfile[i].effectiveDate = ll_effective[i]
Next

In article <470e8e3a$1@forums-1-dub>, no...@nothere.com says...
> luo_customerProfile[].effectiveDate = ll_effective[]
>

Steve

unread,
Oct 15, 2007, 2:02:19 PM10/15/07
to
Thanks for the reply. That's how the code is doing it now, just too slow.
I was hoping for a faster way than looping. The code is basically a user
object array with several elements that are getting populated with values
from a datastore by looping:

ll_rowcount = lds_datastore.retrieve()


for i = 1 to ll_rowcount

luo_customerProfiles[i].effectiveDate = lds_datastore.getitem(i,
'effectiveDate')
luo_customerProfiles[i].terminationDate = lds_datastore.getitem(i,
'terminationDate')
etc....
next

I was hoping there might be a way to somehow populate all effectiveDates and
terminationDates without looping. Something like:

luo_customerProfiles[].effectiveDate =
lds_datastore.object.effectiveDate.Primary
luo_customerProfiles[].terminationDate =
lds_datastore.object.terminationDate.Primary

I don't think I can do this, so I'm probably looking at a complete rewrite.
Which is fine, it need its.

Thanks again,

Steve

Philip Salgannik

unread,
Oct 15, 2007, 3:01:28 PM10/15/07
to
You can do this with dot notation of blocks of data from your datastore into
arrays of structures/nvos provided that they match field by field the column
list definition of your dataobject...
"Steve" <no...@nothere.com> wrote in message news:4713ab2b@forums-1-dub...

Paul Horan[TeamSybase]

unread,
Oct 15, 2007, 3:13:51 PM10/15/07
to
You were close:

luo_customerProfile.object.effectiveDate.Primary = ll_effective

Paul Horan[TeamSybase]

"Steve" <no...@nothere.com> wrote in message news:470e8e3a$1@forums-1-dub...

Chris Pollach

unread,
Oct 15, 2007, 3:15:32 PM10/15/07
to
Steve;

I have often seen improved performance when I have applications like
this by compiling these to "Machine code" not P-Code which is the default.
Also, might I suggest:

1) Allocate your array in contiguous memory.
Example:
uo_data[] io_data
ll_rows = DS.RowCount()
io_data[ll_rows]= Create uo_data
2) Now loop through your load in descending order ( this is much more memory
effective).

OR

Use another DataStore instead of the UO array and use the "Dot" notation to
load the new DS with the current buffer data!

Food for thought.

Regards ... Chris


"Steve" <no...@nothere.com> wrote in message news:4713ab2b@forums-1-dub...

bede

unread,
Oct 16, 2007, 7:44:16 AM10/16/07
to
there *is* a difference between:
1. looping all rows in the datawindow and taking each value from the dw
2. assigning all values of the dw into a local array and looping that array

datetime ll_effective[]

// All column data into array
ll_effective = lds_accountProfileTemp.object.effectiveDate.Primary

// Transfer to uo array elements


For i=upperbound(ll_effective[]) To 1 Step -1
luo_customerProfile[i].effectiveDate = ll_effective[i]
Next

=> i would still expect approach 2 to be faster.. depending on volume of data

but the best way is -as Philip indicated- to make a structure for the dw column definition
(matching datatype & order) and fill an array of that with data, if that suits your
intentions. see example below.

HTH,

Ben

example:

global type str_dwdata from structure
string identification
...
datetime effectiveDate
datetime terminationDate
end type

...

str_dwdata lstr_data[]

// Copy all data into structure
lstr_data = lds_accountProfileTemp.object.data


In article <4713ab2b@forums-1-dub>, no...@nothere.com says...

Steve

unread,
Oct 16, 2007, 9:25:18 AM10/16/07
to
Thanks everyone for your excellent suggestions.

- Steve


0 new messages