create a variable with dynamic data type in plpgsql
<p><br>
Is there a way to declare a variable in a plpgsql function, which data type is set on a parameter? <br>
For example:<br><br></p>

<pre><code>create or replace function test(datatype text)&lt;br&gt; returns void as $$
declare
  data datatype;  -- data type is stored in the text string, for example int
begin
  raise notice '%', (select pg_typeof(data));
end;
$$ language plpgsql;
</code></pre>

<p>In other words, i am trying to write a function, and inside that function i need a variable, and that variable data type must be defined in another input parameter.
Any ideas?
Bests regards </p>