Hello,

you should execute your select statement as an dynamic query, because plpgsql assumes
that there is valid / parseable query (and not a string containing a query) after the 
"IN".

( the skeleton for iterating on the result of dynamic queries)
FOR record | row IN EXECUTE text_expression LOOP 
    statements
END LOOP;

so you may use this as follows:
FOR each_row IN EXECUTE  ''select * from '' || table_name LOOP
    raise notice 'row';
END LOOP;

I don't test it, so maybe there are some mistakes in it.
It's possible too, that you must prepare your query itself into a text variable before 
use in FOR IN EXECUTE LOOP.
I suspect that EXECUTE was added in v7.1.

hope this helps,

Papp Gyozo 
- [EMAIL PROTECTED]

----- Original Message ----- 
From: "toto" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 2001. május 21. 08:46
Subject: [PHP] OOT - postgress help


> First, i'm sorry if this is an out of topic subject, but i've try to post
> this email to one of postgres mailing list, and i can't find any help there.
> i wish, if one of you know the solutions of my problem, you can share it
> with me.
> 
> i create a little stored procedure using plpgsql from pgaccess. function
> input is table name where the function will simply iterate along each record
> in the table and raise notice for each of them.
> 
> when i run this function from shell command using : select
> browse_table('sex'), the function error with error message 'ERROR:  parser:
> parse error at or near "$2"'. As i concern, this error came from the line i
> mark because the function can't receive variable 'table_name' to generate
> query.
> 
> i'm new here, so can some body help me, please....
> 
> the source code is below.
> ===========================================================
> DECLARE
> table_name ALIAS for $1;
> each_row RECORD;
> BEGIN
> FOR each_row IN select * from table_name LOOP     ==> i believe this's an
> error source
> raise notice 'row';
> END LOOP;
> END;
> ===========================================================
> function description :
> function name : browse_table
> returns   : bpchar
> parameters   : bpchar
> language   : plpgsql
> 
> 
> -toto-
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to