This is my function:
create function get_info(p_schema_prefix text)
returns table (... column definitions go here ...)
as
$$
declare
l_rec record;
l_sql text;
begin
for l_rec in select table_schema, table_name
from information_schema.tables
where table_name = 'info'
and table_schema like p_schema_prefix||'%'
loop
l_sql := format('select id, data from %I.%I', l_rec.table_schema, l_rec.table_name);
return query execute l_sql;
end loop;
end;
$$
language plpgsql;
In the firste line inside the loop I have a format select string format('select id, data from %I.%I', l_rec.table_schema, l_rec.table_name);
. How do I refer to l_rec.table_schema more than once? I know the first %I refers to the first parameter and the second %I refers to the second. However I want to refer to the first parameter multiple times, how do I do that?
你没有——只是多次使用相同的论点。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.