cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

EXTRACT relations function

DonSenchuk
7-Bedrock

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Chris3
20-Turquoise
(To:DonSenchuk)

well in that case it is simply:

 

if string_length(extract_parameter)>22

parameter = extract(extract_parameter,23,string_length(extract_parameter) - 22)

endif

View solution in original post

5 REPLIES 5
Chris3
20-Turquoise
(To:DonSenchuk)

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

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.

Chris3
20-Turquoise
(To:DonSenchuk)

well in that case it is simply:

 

if string_length(extract_parameter)>22

parameter = extract(extract_parameter,23,string_length(extract_parameter) - 22)

endif

Thanks a ton. Exactly what I needed.

TomU
23-Emerald IV
(To:DonSenchuk)

Top Tags