[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)



The logic works perfectly, but you have to realize that you're doing
string comparison, not number comparison.

Try something like...

SELECT
ET.DESCR
ET.GL_EXPENSE
LENGTH(ET.GL_EXPENSE) &ET.GL_EXPENSE_LNGTH=number
FROM TABLE ET

... and ...

  evaluate &ET.GL_EXPENSE_LNGTH
    when >= 12
      show 'Length 12+'
      break
    when = 6
      show 'Length 6'
      break

   ... etc

HTH,
Don


On Mon, 28 Feb 2005, Joe Johnson wrote:

> 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
> 

-----------------------------------------------------------------------
Donald Mellen  | Ray Ontko & Co. - Richmond, IN - http://www.ontko.com/
donm@ontko.com |  "In the beginning, there was nothing, which exploded"


_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users