[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: [sqr-users] problems with using length(field)
- Subject: Re: [sqr-users] problems with using length(field)
- From: don.barclay@srs.gov
- Date: Mon, 28 Feb 2005 17:29:05 -0500
- Delivery-date: Mon, 28 Feb 2005 17:30:05 -0500
- In-reply-to: <BAY2-F4171A6B7B653CCBA57B7F7AE580@phx.gbl>
- List-id: "This list is for discussion about the SQR database reportinglanguage from Hyperion Solutions." <sqr-users.sqrug.org>
Joe,
You are trying to use text strings to compare numbers. The text string
'6' is greater than '12' since 6 comes after 1 using ascii codes. Also, a
blank field is actually a space (of length one).
Try the following:
SELECT
ET.DESCR
ET.GL_EXPENSE &ET.GL_EXPENSE
let $GL_EXPENSE = ltrim(rtrim(&ET.GL_EXPENSE,' '),' ') ! strip out
spaces at beginning and end
let #GL_EXPENSE_LENGTH = length($GL_EXPENSE)
evaluate #GL_EXPENSE_LENGTH
when >= 12
show 'Length 12+'
break
when = 6
show 'Length 6'
break
when = 0
show 'Length 0'
break
end-evaluate
FROM TABLE ET
> I have a requirment to process data according to the length of one
field.
>
> I am getting the length this way:
>
> SELECT
> ET.DESCR
> ET.GL_EXPENSE
> LENGTH(ET.GL_EXPENSE) &ET.GL_EXPENSE_LNGTH
> FROM TABLE ET
>
> The result of &ET.GL_EXPENSE_LNGTH is then pared down to:
>
> let $GL_Expense_Lngth = &ET.GL_EXPENSE_LNGTH
> let $GL_Expense_Lngth = rtrim($GL_Expense_Lngth, '0')
> let $GL_Expense_Lngth = rtrim($GL_Expense_Lngth, '.')
>
> which changes "6.0000000000000000000000" to "6"
>
> I have show statements to verify that $GL_Expense_Lngth is identifying
the
> correct length.
>
> However, when I try to apply some of the programming logic according to
> length, the logic fails. The code:
> evaluate $GL_Expense_Lngth
> when = '12'
> when > '12'
> show 'Length 12+'
> break
> when = '6'
> show 'Length 6'
> break
> when = '0'
> show 'Length 0'
> break
> end-evaluate
>
> There are two problems:
>
> 1) when the field is blank, it's being shows as $GL_Expense_Lngth=1
>
> 2) when the field is 6, it's applying the logic for $GL_Expense_Lngth =>
12
>
> Any help would be appreciated.
>
> Thanks,
>
> Joe Johnson
>
> ~ JEJ ;{) ~
>
>
>
> _______________________________________________
> sqr-users mailing list
> sqr-users@sqrug.org
> http://www.sqrug.org/mailman/listinfo/sqr-users
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users