0

I am new to PostgreSQL normally work with the MS-SQL stack, I would normally use the EXEC command inside a stored procedure to call other stored procedures, having trouble achieving the same thing in PostgreSQL.

I have written the below funciton to call the other function but I can't get it to work, can anyone see what I'm getting wrong?

CREATE OR REPLACE FUNCTION public.run_elt_functions ()

DO $$
    BEGIN
    PERFORM public.update_d_customer ();
    PERFORM public.update_d_site ();
    PERFORM public.update_d_service ();
    PERFORM public.update_f_service ();
END; $$
LANGUAGE 'plpgsql';

When I run the above code and get this error: [2019-08-27 11:48:06] [42601] ERROR: syntax error at end of input

Can anyone help?

1
  • DO is an SQL statement that you use if you want to run PL/pgSQL in an SQL statement without the need to define a function. Commented Aug 27, 2019 at 4:10

1 Answer 1

1

The code should be either in a do block, or in a function.

Try

CREATE OR REPLACE FUNCTION public.run_elt_functions()
RETURNS void AS $$
BEGIN
    PERFORM public.update_d_customer();
    PERFORM public.update_d_site();
    PERFORM public.update_d_service();
    PERFORM public.update_f_service();
END; $$
LANGUAGE 'plpgsql';
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.