Search Postgresql Archives

Re: To pass schemaname as a function parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In response to Kalai R :
> Hi,
> 
> I wrote a function in plpgsql, to dispaly the student list.
> 
> In a Database all schemas contains studentlist table. so I wrote the function with schemaname as a parameter(text data type). My code is like
> 
> CREATE FUNCTION disp_fn(schemaname text) AS $$
> BEGIN
>     SELECT * FROM schemaname.studentlist;
> END;
> $$ LANGUAGE plpgsql;

Not possible in this way, use EXECUTE:

   execute 'select * from ' || schemaname || '.studentlist';


(it is a dynamic SQL, you haven't a fix tablename)

Regards, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux