0

It is not a psql terminal, I can't use \set myvariable value as suggested here, and can't use ugly set+current_setting() as here ... I am using Pg9+ (9.5), so I think I can use sql-do as this in answer... But not working.

DO $$
DECLARE foo int := bar('etc');
BEGIN
    SELECT run_somthing(foo,1);
    SELECT run_somthing(foo,2);
END
$$;
  • ERROR-1: "query has no destination for the resulting data HINT: If you want to discard the results of a SELECT, use PERFORM."

  • ERROR-2: (after add PERFORM) "ERROR: syntax error at or near "SELECT"".


NOTE:

Also sintax error when using function workaround

CREATE or replace FUNCTION doThis() RETURNS int AS $$
DECLARE 
    foo int := bar('etc');
BEGIN
    SELECT run_somthing(foo,1);  -- bug also with PERFORM clause
    SELECT run_somthing(foo,2);
    RETURN 1;
END;
$$  LANGUAGE plpgsql;

SELECT doThis();
Community
  • 1
  • 1
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304

0 Answers0