LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Count Characters in a Field

    Employee
    Posted 01-19-2015 03:48

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Leaner

    Hi,

    I've looked through here and the docs and either my search patterns are bad, or it is not possible to do so: How can I count how many characters are in a field?

    Background: Santander Bank has a sort code which starts 09. In some of our DBs, the developers (bless 'em) did not use the correct data type which is causing the first zero to disappear at input. This is causing all kinds of mischief and Santander is not the only bank with sort codes that start with a zero. The only way I see this being fixed is by counting how many characters that field contains as sort codes are six digits.

    i.e.
    if count.('sortCode') < 6 then
    I've tried using 'left' to evaluate the string, but there are too many variables to assure I will catch all the bad sort codes.

    Ta.


  • 2.  RE: Count Characters in a Field

    Employee
    Posted 01-19-2015 03:55

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: andycooper

    Hi Pablo,

    You can use the len command to perform this step but you may need to convert the field to string first: -

    emit * where sortCode.str().len() <6

    You can also use the pad function if you want to make fields a consistant length.

    Thanks

    Andy


  • 3.  RE: Count Characters in a Field

    Employee
    Posted 01-19-2015 04:09

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Leaner

    Originally posted by: andycooper
    					

    Hi Pablo,

    You can use the len command to perform this step but you may need to convert the field to string first: -

    emit * where sortCode.str().len() <6

    You can also use the pad function if you want to make fields a consistant length.

    Thanks

    Andy
    Cheers Andy.


  • 4.  RE: Count Characters in a Field

    Employee
    Posted 01-19-2015 10:53

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ejones

    Did you look at the strlen() function?