I am trying to create a Left function in PostgreSQL as under
CREATE OR REPLACE FUNCTION LEFT(text, integer) RETURNS text
AS 'SELECT SUBSTR($1,$2);'
LANGUAGE SQL IMMUTABLE;
It got compiled fine. Now when I am invoking it as under
select LEFT(',a,b,c',2)
I am getting the output as ,a
when the expected output is a,b,c
If I run SELECT SUBSTR(',a,b,c' , 2) it works as expected .
Please help me out in identifying the mistake
Thanks