In oracle, the pure number in the updated bytes data is set to a fixed length (0 on the left)

Source: Internet
Author: User

The error in the previous requirement document resulted in the fact that the originally three-digit number was not fixed, and later it was found that the requirement document had mistaken the requirement. The pure number in this field must be three digits.
This field currently has thousands of rows of data, including a combination of letters, numbers, and numbers. The number of digits is not fixed. therefore, you can only write a script to update data, but oracle does not judge whether it is a numeric or a letter type data function. it can only be changed. the complete example is as follows (update the codevalue field in all data rows with typecode = 'fenju' to ensure that the original numeric data has a fixed length of three bits ):
Update Intf_Datadict t Set t. codevalue =
(Case lower (t. codevalue)
When upper (t. codevalue) Then
Case length (t. codevalue)
When 3 Then t. codevalue
When 2 Then '0' | t. codevalue
When 1 Then '00' | t. codevalue
End
Else t. codevalue
End
)
Where t. typecode = 'fenju ';


Author: "insects cool"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.