D
D
des1roer2015-09-18 08:53:39
PostgreSQL
des1roer, 2015-09-18 08:53:39

Postgres select into multiple values?

Is it possible to write multiple variables in a query in plpgsql?

SELECT "ID_TagData", value
       INTO avg_id, val 
FROM "SC_Tag"."T_TagData"
WHERE "F_TagName_ID" = 192
  AND "F_Date">(now()- interval '12:00:00')
ORDER BY "F_Date" DESC LIMIT 1;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vmas, 2015-09-24
@vmas

It is possible, but in plpgsql INTO is written to variables at the end of the query.

SELECT "ID_TagData", value
FROM "SC_Tag"."T_TagData"
WHERE "F_TagName_ID" = 192
  AND "F_Date">(now()- interval '12:00:00')
ORDER BY "F_Date" DESC LIMIT 1
INTO avg_id, val;

And here INTO in the middle of request is a selection in the table (in one).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question