how to get table's name from variable ?

From: maack <massqcbe(at)cetus(dot)zrz(dot)TU-Berlin(dot)DE>
To: pgsql-sql(at)postgresql(dot)org
Subject: how to get table's name from variable ?
Date: 1999-06-01 02:18:49
Message-ID: Pine.SUN.3.91.990601041404.18281A-100000@aries.zrz.TU-Berlin.DE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi everybody,

I have a problem with getting a table's name from a
variable.

example:

create function check_date(int4) returns date as '
declare
my_date date ;
my_tablename text ;
begin
select tname into my_tablename from tw where id = $1 ;
select max(idate) into my_date from my_tablename where id = $1 ;
return(my_date);
end;
' language 'plpgsql';

in the second select-query 'my_tablename' should give the (result-)
tablename
from the first query. How can this be done with postgres?

a friend has shown me the following with oracle:
select .... from &var ;

is this possible with postgres too?

greetings+thanks,
Thomas

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 1999-06-01 02:41:14 Re: [SQL] Column name's length
Previous Message Pham, Thinh 1999-06-01 01:23:18 Column name's length