Pass in variable from user???

Поиск
Список
Период
Сортировка
От syohonn@gmail.com
Тема Pass in variable from user???
Дата
Msg-id 1147554952.782465.146620@i40g2000cwc.googlegroups.com
обсуждение исходный текст
Ответы Re: Pass in variable from user???  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: Pass in variable from user???  ("Michael Artz" <mlartz@gmail.com>)
Список pgsql-general
Using PL/PGSQL, I am trying to create a procedure to display the count
of rows in any single table of a database. The End-user would pass in a
table name and the prodecure would display the table name with the row
count.
I am able to hardcode the variable for table and get the appropriate
results from my count function (see below), but cannot pass in a
variable and have the function work. Any suggesstions???

CREATE FUNCTION get_table_count(tablename text) RETURNS integer AS $$
  DECLARE

    --tablename ALIAS FOR $1;

     rowcount INTEGER;
  BEGIN

    SELECT INTO rowcount count(*) FROM tablename;

    RETURN rowcount;

  END;
$$ LANGUAGE 'plpgsql';


В списке pgsql-general по дате отправления:

Предыдущее
От: FirstDBA@gmail.com
Дата:
Сообщение: Re: Creating of User and Database
Следующее
От: winlinchu@yahoo.it
Дата:
Сообщение: Help!