Q:

Using PREPARE with INTO in PostgreSQL

I'm studying the PREPARE and EXECUTE commands to optimize my functions in PostgreSQL, but i have some problems. 
I have the following PREPARE command: 
PREPARE my_query(int) AS SELECT id FROM table1 WHERE id = $1; 

So, I need store this result (ID) into a variable, like this:
EXECUTE my_query(10) INTO var_1; 

But I got a syntax error. What is the correct way to do this?

A:

Your question doesn't really make any sense to me.
If you are trying to execute the prepared statement from within PL/PgSQL than you're out of luck. The EXECUTE command is reserved for a different purpose within PL/PgSQL. Not that it would have much use, PL/PgSQL plans are prepared and cached by default anyhow :)
If you are trying to do this outside of PL/PgSQL than the INTO would mean you are trying to write the result to a new table. Something you are unlikely to do/need that often.

