0

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

1 Answer 1

3

LEFT function already exists in pg_catalog. So try a different function name or run

SELECT public.LEFT(',a,b,c' , 2)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.