Locate and posstr of DB2

Source: Internet
Author: User

The locate and posstr functions of DB2 first describe the usage of the two functions: locate (arg1, arg2, <pos>) to find the location where arg1 appears for the first time in arg2, specifying pos, the first position of arg1 appears at the pos of arg2. Www.2cto.com posstr (arg1, arg2) view the position of arg2 in arg1 select posstr ('mytest-100', ('test-'|. COL_VC) FROM T_TEST_ZRK A; // error select posstr ('mytest-000000', ('test-') FROM T_TEST_ZRK; // success select posstr ('mytest-100 ',. COL_VC) FROM T_TEST_ZRK A; // error select posstr (. COL_VC, '2') FROM T_TEST_ZRK A; // success select locate ('test-'|. COL_VC), 'mytest-100 '),. col_vc FROM T_TEST_ZRK A; // success select l Ocate ('good-'|. COL_VC), 'hello-'|. col_vc),. col_vc FROM T_TEST_ZRK A; // success www.2cto.com can be easily Viewed FROM the preceding statements. In posstr, arg2 can only be a fixed str and cannot be replaced by fields. arg1 can dynamically generate arg1 and arg2 In the locate.

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.