meaning of code

Posted on 2011-05-11
Last Modified: 2012-05-11

Can someone explain the meaning of this code in detail i couldnt understand the -2 there

TRIM (SUBSTR (i_email_cd, 1, INSTR (i_email_cd, i_locale) - 2)
Question by:thota198
    LVL 18

    Expert Comment

    INSTR (i_email_cd, i_locale) will return a numeric value, that is position of i_locale on i_eamil_cd. The 2 will be subtracted from this output. If it returns 10 then your code will be

    TRIM (SUBSTR (i_email_cd, 1, 10 - 2)
    LVL 76

    Accepted Solution

    TRIM: removes whitespace on both ends of a string:

    SUBSTR has the syntax:  substr(input,start_here, for_this_many_characters)

    INSTR says: INSTR(string,value) return the position of the first 'value' in 'string'.


    you are getting the substring from i_email_cd starting at position 1 and going until you find i_locale.  The -2 says back up two characters from that position.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
    Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
    This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
    This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now