开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜