index_of function

The index_of function determines the position of the first character of the search string at its first occurrence if any.
returnvalue index_of(source, search_string [, start_position])

source ::= any*
search_string ::= any*
start_position ::= integer*
returnvalue ::= integer
Various return values:
  • Returns the position of the first character of the search string at its first occurrence. The position is relative to the start position of the string (which is zero).
  • Returns -1 if search_string is not present in the source.
  • Returns 0 for any value of source if the search_string is of length 0.
  • Returns NULL if any argument is NULL.
  • Returns NULL if any argument is an empty sequence or a sequence with more than one item.
  • Returns error if start_position argument is not an integer.
Example 1: Determine at which position "-" is found in the estimated arrival time of the first leg for the passenger with ticket number 1762320569757.
SELECT index_of(bag.baginfo.flightLegs[0].estimatedArrival,"-")
FROM BaggageInfo bag 
WHERE ticketNo=1762320569757
Output:
{"Column_1":4}
Example 2: Determine at which position "/" is found in the routing of the first leg for passenger with ticket number 1762320569757. This will help you determine how many characters are there for the source point for the passenger with ticket number 1762320569757.
SELECT index_of(bag.baginfo.routing,"/") 
FROM BaggageInfo bag 
WHERE ticketNo=1762320569757
Output:
"Column_1":3}