Problem while creating a Left function in PostgreSQL
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
LEFT
function already exists in pg_catalog. So try a different function name or run
SELECT public.LEFT(',a,b,c' , 2)
精彩评论