
Create table people (
        nif   char(12),
        age   int4,
        primary key (nif)
);

insert into people (nif, age) values (
	'001', 10);
insert into people (nif, age) values (
	'002', 30);

Create Function get_age(text) Returns text as '
Declare
  param_nif Alias For $1;
  person record;
  text_to_return text;
Begin
 Select people.age into person
 From people
 Where people.nif = param_nif;
 text_to_return := person.age::text;
 Return text_to_return;
End;
' language 'plpgsql';

Select get_age('001');

