Format integer to "00" in store procedure
Posted in 2008
Topics: General Discussion
How can I convert or format an variable that will contain a number (let's say 4) as "04" in informix store procedured Here are more examples: initial value desired value 1 01 6 06 9 09 13 13 Thanks
NG SOO CHEE schrieb: > How can I convert or format an variable that will contain a number (let's say > 4) as "04" in informix store procedured > > Here are more examples: > > initial value desired value > 1 01 > 6 06 > 9 09 > 13 13 > > Thanks > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > Hi, you did not give much detail, did you? So these are my assupmtions: Inside your SP you'll have 2 variables, _val_as_int and _val_as_string. _val_as_int is SMALLINT or INT. _val_as_string is CHAR(2). You must test if _val_as_int is < 100, then use _val_as_string = LPAD(_val_as_int, 2, '0'). dic_k -- Richard Kofler SOLID STATE EDV Dienstleistungen GmbH Vienna/Austria/Europe
Hi ther Mr NG SOO CHEE, I have heard that the manuals are a wonderful resource for such things, however, If you use lpad(string,length,pad-character) it should give you what you require. E.g. lpad(field,2,'0') Regards Mark -----Original Message----- From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of NG SOO CHEE Sent: 01 December 2008 10:03 AM To: ids@iiug.org Subject: Format integer to "00" in store procedure [14152] How can I convert or format an variable that will contain a number (let's say 4) as "04" in informix store procedured Here are more examples: initial value desired value 1 01 6 06 9 09 13 13 Thanks **************************************************************************** *** Forum Note: Use "Reply" to post a response in the discussion forum. ================== Please read our Email Disclaimer : http://www.thefuelgroup.com/disclaimer.html