How do I get query result(select e.g.) from a dynamic command(EXECUTE)? - Mailing list pgsql-general

From Wei Wang
Subject How do I get query result(select e.g.) from a dynamic command(EXECUTE)?
Date
Msg-id 008001c3f6de$9c75e310$726ee880@weiwang
Whole thread Raw
Responses Re: How do I get query result(select e.g.) from a dynamic command(EXECUTE)?
List pgsql-general
Hi,

I want to do a select in dynamic command, something like:

TRIGGER FUNCTION
DECLARE
    table_name_suffix text;
    temp_result RECORD;
    temp_result2 RECORD;

...

BEGIN
    --initialization of table_name_suffix(from TG_RELNAME e.g.)


    select into temp_result from
''fixed_table_name_prefix''||table_name_suffix where another_table_name =
abc;

    --Then I want to use part of the result as part of the table name for my
next query
    select into temp_result2 from
''fixed_table_name_prefix''||temp_result.anothertablename;

END

I know that SELECT INTO doesn't support dynamic command, EXECUTE does. But
if I EXECUTE a select query, how do I get
the select result from it?

Many thanks,

Wei Wang


pgsql-general by date:

Previous
From: Alexander Priem
Date:
Subject: Re: Grant / Revoke functionality
Next
From: "Wei Wang"
Date:
Subject: Re: How do I get query result(select e.g.) from a dynamic command(EXECUTE)?