Both the below queries return the same result. Can you please let me know why and which is more appropriate?
select substr('87731000',0,8) from dual;
select substr('87731000',1,8) from dual;
This version is more appropriate:
select substr('87731000',1,8) from dual;
The second parameter is the start position. In oracle, the start position for a string is always 1.
Both statements work just fine, but that's only because the database is being helpful and assuming that if you enter '0', you mean to start at the beginning of the string.
From the oracle docs: http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions162.htm
If position is 0, then it is treated as 1.
substr starting at character position 2, they may use 1 thinking it is zero-based!