Multiple choice technology databases

The output of the query " select instr('I''m an expert in oracle','d',-1,1) from dual; " is

  1. 1

  2. error

  3. null

  4. 0

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The INSTR function searches for a substring within a string. With start_position=-1, it searches backwards from the end of the string. The occurrence parameter specifies which occurrence to find. Since 'd' exists in 'oracle' at position 15, the function should return 15. However, if the function returns 0, it could indicate either the substring was not found or there's a specific behavior with negative start positions that depends on Oracle version. The correct answer depends on actual Oracle behavior.

AI explanation

INSTR searches for a substring and returns the character position where it is found, or 0 if the search string never occurs. The literal string I'm an expert in oracle (the doubled quote '' is just an escaped apostrophe) contains no letter d anywhere, so searching backward for 'd' finds nothing and the function correctly returns 0, not an error or null.