Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

meaning of code


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)
0
thota198
Asked:
thota198
1 Solution
 
sventhanCommented:
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)
0
 
slightwv (䄆 Netminder) Commented:
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'.

so:

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.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now