Author |
Message
|
5zan |
Posted: Mon Jul 21, 2008 7:22 am Post subject: Masking possible in ESQL ? |
|
|
Novice
Joined: 08 Jul 2008 Posts: 24
|
i have to mask a number with 5 zero's .
i.e if my number is a 2 digit number , i have to preceed that with 3 zeros ..
for example if 23 is the input , my output should be 00023
if the number is a 3 digit number , for example 123 my output should be 00123
and so on ... is there a function in ESQL which does this ?
Can this be done without any loops ?  |
|
Back to top |
|
 |
sridhsri |
Posted: Mon Jul 21, 2008 7:29 am Post subject: |
|
|
Master
Joined: 19 Jun 2008 Posts: 297
|
Normally, such a thing should be done in the MRM - using a padding character.
Having said that, you could initialize a string with '00000' and convert your integer to another string '123' then using the overlay esql method to give you '00123'. But I would prefer modeling this in MRM as a padding char. |
|
Back to top |
|
 |
5zan |
Posted: Mon Jul 21, 2008 7:49 am Post subject: |
|
|
Novice
Joined: 08 Jul 2008 Posts: 24
|
yes sridhsri , but here its a simple ESQL that i need .
I just need a function which can do that or any logic ~  |
|
Back to top |
|
 |
broker_new |
Posted: Mon Jul 21, 2008 12:49 pm Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
|
Back to top |
|
 |
broker_new |
Posted: Mon Jul 21, 2008 12:52 pm Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
The ESQL is as follows
DECLARE source INTEGER 123;
DECLARE target CHARACTER;
DECLARE pattern CHARACTER '00000';
SET target = CAST(source AS CHARACTER FORMAT pattern); |
|
Back to top |
|
 |
5zan |
Posted: Tue Jul 22, 2008 12:14 am Post subject: |
|
|
Novice
Joined: 08 Jul 2008 Posts: 24
|
thanx broker_new , dat was it !
thanx sridhsri ! |
|
Back to top |
|
 |
|