The string scalar function STRIP added to DB2 V9

Source: Internet
Author: User

The STRIP environment product of the string scalar function added by DB2 V9: DB2 UDB platform: Linux Unix Windows Version: V9 V9.5 the problem starts from DB2 V9 and a new string scalar function STRIP is added, it is convenient for developers to process strings. Note: To display spaces, use # to indicate the starting and ending positions of strings. in DB2 program development, you may sometimes need to remove spaces or "0" characters before or after a string, for example: the expected string --------- ---------------- #00000999000 #999 #999 #00990090000 #99 #99 9 #99 9 #990090000 # Before DB2 V8.2, developers generally use a combination of REPLACE, LTRIM, and RTRIM. Starting from V9.1, we can use the STRIP function or TRIM function. Here we will briefly introduce the STRIP function. The TRIM function is similar in usage. If you are interested, refer to the DB2 SQL reference manual. The syntax of the STRIP function is as follows:

>-STRIP -- (--- string -- expression -- + -------------------- + ---)-> <'-, -- + -- BOTH ---- + -- + ---- + --- '+ -- LEADING-++ -- L ------- ++ -- TRAILING +'-T --------- 'B: BOTH indicates two ends of L: LEADING: T: TRAILING: strip-character: a single character constant to be truncated

 

The preceding string is used as an example:
db2 "select '#'||strip('00000999000',b,'0')||'#' from sysibm.sysdummy1" 1            ------------- #999#          1 record(s) selected. db2 "select '#'||strip('     999   ',t,' ')||'#' from sysibm.sysdummy1"  1            ------------- #     999#     1 record(s) selected.   db2 "select '#'||strip('     99 9  ',t,' ')||'#' from sysibm.sysdummy1" 1            ------------- #     99 9#    1 record(s) selected.   db2 "select '#'||strip('00990090000',l,'0')||'#' from sysibm.sysdummy1" 1            ------------- #990090000#    1 record(s) selected. 

 


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.