[GENERAL] About using plpgsql funciton variable as the table name

2005-08-11 Thread Ying Lu
Greetings, I met a question about how to use *function variable *as the *table name* to select count(*) into an integer variable for the table. CREATE OR REPLACE FUNCTION update_code_map(VARCHAR, VARCHAR) RETURNS VARCHAR AS $$ DECLARE *tableName ALIAS FOR $1*; *rec_num

Re: [GENERAL] About using plpgsql funciton variable as the table

2005-08-11 Thread Richard Huxton
Ying Lu wrote: Greetings, I met a question about how to use *function variable *as the *table name* to select count(*) into an integer variable for the table. Look at: FOR-IN-EXECUTE http://www.postgresql.org/docs/8.0/static/plpgsql-control-structures.html#PLPGSQL-RECORDS-ITERATING --

Re: [GENERAL] About using plpgsql funciton variable as the table

2005-08-11 Thread Ying Lu
Thank you all for the helping. I made a bit changes as the following and it works. CREATE OR REPLACE FUNCTION update_code_map(VARCHAR, VARCHAR) RETURNS VARCHAR AS $$ DECLARE tableName ALIAS FOR $1; st1_tabno_value ALIAS FOR $2; rec_num INTEGER;