I have an oracle column(artnr) contains a length of 1 which is of type number(9). I want to update the number as following...
Example :
If number is 0 then it should be 00000 If number is 1 then it should be 00001 If number is 12 the it should be 00012
Remember : here 00000,0000, and 00012 are of number datatypes
The following are the methods I have tried but failed..
UPDATE pitb.toestel b
SET b.artnr = LPAD (b.artnr, 5, 0)
WHERE b.idinventaris = 403743;
Failed because Lpad can only be applied on strings
UPDATE pitb.toestel b
SET b.artnr = TO_NUMBER (TO_CHAR (artnr, '00009'), '00009')
WHERE b.idinventaris = 403743;
Still failed, because to_number will not display the leading zero's. It will only consider from first number
Anyone, could you please suggest me something which will solve this scenario..
sql is preferrable than pl/sql solution