EXTRACT relations function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
EXTRACT relations function
I'm setting up some relations to extract portions of a master parameter into other parameters.
So far, everything went as expected. Until I got to the end of the string. The last bit of the master parameter may vary between one and 5 characters. If I enter the length bit of the extract relation as 5, it doesn't like when the master parameter has fewer than 5 characters.
Is there a way to get around this issue?
Solved! Go to Solution.
- Labels:
-
General
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
well in that case it is simply:
if string_length(extract_parameter)>22
parameter = extract(extract_parameter,23,string_length(extract_parameter) - 22)
endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
If I am reading your question right you are running into an issue in which the extract function is trying to extract more characters than exist in some cases. This returns a null which causes the relation to fail.
The way to get around this is to check the length of the string prior to executing the extract function.
if string_length(extract_parameter)>5
parameter = extract(extract_parameter,1,5)
endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I did think about trying to use string length. With that last portion being between 1 and 5 characters (at the end of 22 other characters) I was hoping there was a more elegant solution than nesting a bunch of "IF STRING_LENGTH" statements together.
Something that would tell the system to just extract all characters past the 22nd one, regardless of how many exist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
well in that case it is simply:
if string_length(extract_parameter)>22
parameter = extract(extract_parameter,23,string_length(extract_parameter) - 22)
endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks a ton. Exactly what I needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Use the string_length() function to determine how many characters to extract.
