[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
[sqr-users] Problem with arrays?
- Subject: [sqr-users] Problem with arrays?
- From: Matt Rogish <rogishmn@muohio.edu>
- Date: Wed, 27 Oct 2004 19:31:26 -0400
- Delivery-date: Wed, 27 Oct 2004 18:33:51 -0500
- List-id: "This list is for discussion about the SQR database reportinglanguage from Hyperion Solutions." <sqr-users.sqrug.org>
Please copy me on any replies as I receive a digest -- it's hard to pick
out replies to my topic in the digest!
I have an array I declared like this:
Create-Array Name=print_positions Size=100 Field=Code:Char
Field=Desc:Char Field=Date:Char Field=Position:Number Field=Value:Number
I intend to have an array that looks like this:
ABC, This is the description, 01/01, 1, 0
...
ABC, This is the description, 12/01, 12, 0
ABC, This is the description, Total, 13, 0
DEF, Description of the thing, 01/01, 1, 0
...
DEF/Description strings are stored in a database table, the 01/01
correspond to Month/Year (in MM/YY format). The 'total' date is a special
one which will store the summation of all the 1-12. I intend to iterate
over each row in the table, do a loop that goes up to 12 to generate the
months, and insert the rows (in this example I want twelve months from a
given $start_date). After each loop, I then add the 'Total' by hand.
That code is below (some newlines removed for brevity):
begin-procedure fill_array( $start_date )
let #total_codes = 0
let #total_print_positions = 0
begin-select
atvscnt_code
atvscnt_desc
let #counter = 0
let $code = &atvscnt_code
let $desc = &atvscnt_desc
while( #counter < 12 )
let $month = datetostr( dateadd( strtodate( $start_date,
'DD-MON-YYYY' ), 'MONTH', #counter ), 'MM/YY' )
let #position = #counter
put $code $desc $month #position 0 Into print_positions(
#total_print_positions ) code desc date position value
show $code ' ' $desc ' ' $month ' ' #position ' in '
#total_print_positions
add 1 to #counter
add 1 to #total_print_positions
end-while
add 1 to #position
put $code $desc 'Total' #position 0 into print_positions(
#total_print_positions ) code desc date position value
show $code ' ' $desc ' Total ' #position ' in ' #total_print_positions
add 1 to #total_print_positions
FROM atvscnt
ORDER BY atvscnt_code
end-select
The output of the 'show' code (using real-world values in the table and
starting with 01-JUL-2004) is:
CRS Correspondence 07/04 9.000000 in 0.000000
...
CRS Correspondence Total 21.000000 in 12.000000
...
PRC Personal Contact 06/05 20.000000 in 63.000000
PRC Personal Contact Total 21.000000 in 64.000000
Now the problem seems to be that the array population is not taking 'hold'
in that while loop. For example if I then immediately iterate over the array:
...
end-select
let #counter = 0
while( #counter < #total_print_positions )
get $coded $descd $dated #positiond #valued from print_positions(
#counter ) code desc date position value
show $coded ' ' $descd ' ' $dated ' ' #positiond ' ' #valued ' in
' #counter
add 1 to #counter
end-while
I end up with:
PRC Personal Contact 06/05 20.000000 0.000000 in 0.000000
...
0.000000 0.000000 in 11.000000
CRS Correspondence Total 21.000000 0.000000 in 12.000000
0.000000 0.000000 in 13.000000
...
0.000000 0.000000 in 63.000000
PRC Personal Contact Total 21.000000 0.000000 in 64.000000
The truly strange thing is that the "PRC" 06/05 was the NEXT TO LAST item
entered in the above loop yet it shows up first!!
Has anyone seen anything like this before? I've done loops like this before
without any problems. This is very, very frustrating!!
Thanks,
--
Matt
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users