Re: Table name as parameter in function
От | Timothy Perrigo |
---|---|
Тема | Re: Table name as parameter in function |
Дата | |
Msg-id | E0B75230-3D94-11D9-8D91-000A95C4F0A2@wernervas.com обсуждение исходный текст |
Ответ на | Table name as parameter in function (Alexander Pucher <pucher@atlas.gis.univie.ac.at>) |
Ответы |
Re: Table name as parameter in function
|
Список | pgsql-general |
You'll need to use the EXECUTE command to build the SQL dynamically. See: http://www.postgresql.org/docs/7.4/interactive/plpgsql- statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN On Nov 23, 2004, at 2:56 PM, Alexander Pucher wrote: > Hi, > > struggling around with this for some time: > > How can I use a table name as a parameter in a PL/pgSQL function ?? > > I tried this but it didn't work... > > > CREATE OR REPLACE FUNCTION my_row_count(text) RETURNS int4 AS ' > DECLARE > num_rows int4; > BEGIN > num_rows := (select count(*) from $1); > RETURN num_rows; > END; > ' LANGUAGE plpgsql; > > Thnaks for any input! > > regards, > alex. > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to > majordomo@postgresql.org >
В списке pgsql-general по дате отправления: