Please explain how you can assign a query to a variable by analogy as in mssql

@ result = Select * from dual where a1 = a2; Real example

CREATE OR REPLACE FUNCTION table_test () RETURNS varchar(1) AS $BODY$ DECLARE outinfo varchar(1); test text; BEGIN test = select count(*) from table; if test>0 THEN outinfo := 'y'; else outinfo := 'n'; END if; return outinfo; end; $BODY$ LANGUAGE plpgsql VOLATILE 
  • There are no variables in the postgresql query language. They are only inside the pl / sql code (this is a separate language inside postgresql). The same tasks that you used to solve with the help of variables in mssql in the postgres are solved in completely different ways. so clarify the task, for what exactly did you need a variable - Mike
  • plpgsql, I need to assign the value of the request for further work with the output value, but rather now I will add to the question - Egor
  • one
    well if in plsql then select X from DUAL ... into Result - Mike

1 answer 1

I would rewrite your function as follows:

 CREATE OR REPLACE FUNCTION stoppagelog2ora () RETURNS BOOLEAN AS $BODY$ DECLARE _count BIGINT = 0; BEGIN SELECT INTO _count count(*) FROM mssql_startrepltoora; RETURN _count > 0; END; $BODY$ LANGUAGE plpgsql 
  • @ Egor is questionable; there is a link to "edit"; write all the information that relates to it directly in the text of the question. Read this in the comments, and even to the answer that can be deleted, no one will - Mike