NVP Function

Database
Enthusiast

NVP Function

Hi Below is the query:

I am trying to understand how NVP Function works. I tried the below simple query

SEL NVP('100:Jugal#9004','100','#',':',1)

Output:

Jugal

I want the output as

Jugal 9004(Name Value Pair)

Thanks

Jugal

Tags (1)
1 REPLY
SRM
New Member

Re: NVP Function

I know you posted this question 4 years back and that you might not need this now, but, this is for the next person who lands on this question.

The query that will get the desired output is:

 

SEL OREPLACE(Nvp('100:Jugal#9004 ','100','\ ',':',1),'#',' ')

For that you need to understand two functions:

1.  NVP

syntex for NVP:

NVP(longstring,findstring,name_delimiter,value_delimiter,occurrence)

 longstring is your name-value column

findstring is the name you want to find

name_delimiter is the character that seperates a name-value pair

value_delimiter is the character that seperates a value from the name in the name-value pair

occurrence is the occurrence of the name from which you want to fetch the value

 

2. OREPLACE

syntex for OREPLACE:

OREPLACE(string,find_string,replace_string)

string is the column you want the function to act on

find_string is the string you want to replace

replace_string is the string with which you want to replace the find_string

 

Hope that helps

-SRM