Answer the question
In order to leave comments, you need to log in
How in procedure to write down array of row of the temporary table in var?
Hello.
In a procedure (postgreSQL) I create a temporary table with a random name, from which I then want to select and put the data into a variable.
DECLARE
temp_table_name TEXT;
temp_table_records RECORD[]; -- знаю, это не корректно, но как будет правильно?
BEGIN
SELECT INTO temp_table_name CONCAT('temp_manager_operative', floor(random()*(999999-100000)+100000)); -- генерация случайного имени таблицы
EXECUTE 'CREATE TEMP TABLE IF NOT EXISTS ' || temp_table_name || ' (id INT, name TEXT)'; -- создаем временную таблицу
EXECUTE 'SELECT * FROM ' || temp_table_name INTO temp_table_records ; -- выполняем sql запрос во временную таблицу и кладем результат в переменную
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question