Indexof/lastindexof and lpad in Oracle

Source: Internet
Author: User
Indexof/lastindexof and lpad in Oracle

-- In the indexof and lastindexof instr ('upgrade floor ', 'or', 3, 2) of PL/SQL, the source string is 'upgrade floor ', the target string is 'or', the start position is 3, and the position of the first matching item is obtained.
-- The default search order is left to right. When the start position is negative, search from the right
Select substr ('2. 3.30.41 ', instr ('1. 2.30.1', '.',-1, 1) + 1) from dual

Indexof: The third parameter of substr is 1;

Lastindexor: The third parameter of substr is-1.

Application: Update subject t set T. subject_id_v = lpad (substr (T. subject_id, instr (T. subject_id ,'. ',-1, 1) + 1), 3, '0 ')

Note: Take the string following the last "." In the subject_id field. If the length of the obtained string is less than 3, add 0 to the front of the string to supplement the three.

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.