LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Regarding Postgresql - plpgsql proceduce... (https://www.linuxquestions.org/questions/programming-9/regarding-postgresql-plpgsql-proceduce-688288/)

maradnus 12-04-2008 07:58 AM

Regarding Postgresql - plpgsql proceduce...
 
Dear Linux Experts,

I have a table which has to be found dynamically while the program is running.

Could any one give the way to pass the table name as argument to
a PLPGSQL Procedure in postgresql or a way to compose a table name.


Thanks in advance.

With Regards
Sundaram

jan61 12-08-2008 04:07 PM

Moin,

do you mean something like this?
Code:

create function do_something(tablename varchar) as '
  execute ''update '' || tablename || '' set seen=1'';
' language 'plpgsql';
-- or
create function do_something(tablename varchar) return integer as '
  open cursor for execute ''select count(*) from '' || tablename;
  -- ...
' language 'plpgsql';

Look here: http://www.postgresql.org/docs/8.1/i...l-cursors.html
and here: http://www.postgresql.org/docs/8.1/i...-EXECUTING-DYN

Jan

maradnus 12-08-2008 11:26 PM

Thank you very much.

I got the solution.


All times are GMT -5. The time now is 12:34 AM.