行类型

150
2023/08/01 16:42:29

简介

行变量 表名%ROWTYPE;
-- 或者
行变量 视图名%ROWTYPE;

要访问行变量的字段,可以使用 .

行变量.字段名

示例

我们将使用示例数据中的 actor 表来作演示。

以下示例显示了 id 为 10的演员的信息:

do $$
declare
   selected_actor actor%rowtype;
begin
   -- 选择ID为10的演员   
   select * 
   from actor
   into selected_actor
   where actor_id = 10;

   -- 显示演员信息
   raise notice '演员的名字是:% %',
      selected_actor.first_name,
      selected_actor.last_name;
end $$;