I have a function in oracle that i need converted to postgres.
i can't seem to find a reason for this difference in docs docs but:
oracle:
SELECT substr('1236',-4, 4) FROM DUAL;
Result: 1236
postgres:
SELECT substr('1236',-4, 4);
Result: empty (Null)
i need an output similiar to oracle and i cant seem to understand why the postgres function differs, and what i can use as an alternative
substr()doesn't accept a negative starting position in Postgresselect substr('string', -1, 3)returns st. I think it assumes you have something in -ve positions, and takes in account but returns only the valid values, so above returnsselect substr('string', 1, 1)