Tuesday, June 23, 2009

PL/SQL: Split Key-Value Pairs

In that previous post, I was taking a URL string and splitting it based on the delimiter, which is typically the ampersand &. In ApEx it is the colon :. I'd take a wild guess and say there are others, but I'm not going to look them up. An example string looks like this:

param1=value1&param2=value2

Etc. Etc. Etc.

The output of that split looks like this:

param1=value1param2=value2

Now you need that string parsed. Instead of just a string being returned however, you'd like to know the name of the parameter as well, thus key/value. Desired format looks like this:

Now I just need to wrap this up into package form and I'm all done. That will be another post with the unit tests provided.

UpdateSo after rereading this post, I realized that I just confused it with the previous post on splitting URL strings. Probably the best solution would be to combine these 2 functions, or at least pipe out the key/value pairs from the main function (previous post). Did I catch a niner in there?