sql - Create leading zero in Oracle -


i using adempiere has database oracle

i have window called stock code table called m_stockcode

the fields code , description.

currently, code data type number , description varchar2

i want input sparepart code 01, , body repair code 02.

as input data in adempiere , save it, show sparepart code 1 (without leading zero)

i've tried putting lpad function it's still failed.

how can put 01 both in adempiere interface , in database?

any suggestion appreciated :)

a number cannot have leading zero, string can.

  1. if want store codes leading zero in database table, must use varchar2 , not number.

  2. if want display number leading zero, use to_char convert number string.

for example,

sql> select to_char(1, '00') dual;  to_ ---  01 

you use lpad, remember, data type of result string , not number.

for example,

sql> select lpad(1, 2, '0') dual;  lp -- 01 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -