Official documentation explains:https://www.postgresql.org/docs/9.1/plpgsql-declarations.html
postgres=# do $$
declare
counter integer := 1;
first_name varchar(50) := 'John';
last_name first_name%type := 'Doe';
payment numeric(11,2) := 20.5;
begin
raise notice '% % % has been paid % USD',
counter,
first_name,
last_name,
payment;
end $$;
NOTICE: 1 John Doe has been paid 20.50 USD
DO
postgres=# create table actor(actor_id int, fname varchar(20), lname varchar(20));
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'actor_id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE
postgres=# insert into actor values ( 1, 'join', 'mal');
INSERT 0 1
postgres=# select * from actor;
actor_id | fname | lname
----------+-------+-------
1 | join | mal
(1 row)
postgres=# do $$
declare
selected_actor actor%rowtype;
begin
select *
from actor
into selected_actor;
-- show the number of actor
raise notice 'The actor name is % %',
selected_actor.fname,
selected_actor.lname;
end $$;
NOTICE: The actor name is join mal
DO
postgres=# do $$
declare
r record;
begin
select *
from actor
into r;
-- show the number of actor
raise notice 'The actor name is % %',
r.fname,
r.lname;
end $$;
NOTICE: The actor name is join mal
DO
end~