Problem with dynamic query

From: "Kumar" <sgnerd(at)yahoo(dot)com(dot)sg>
To: "psql" <pgsql-sql(at)postgresql(dot)org>
Subject: Problem with dynamic query
Date: 2003-12-05 12:43:50
Message-ID: 01c301c3bb2d$76596b80$7502a8c0@hdsc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dear Friends,
I am using postgres 7.3.4 running on RH Linux 7.2. While writing dynamic SQL stmts, i have the following problem. Using cursor works fine.

OPEN ref FOR
EXECUTE
\'SELECT comma(full_name) FROM (SELECT usr.full_name
FROM project_members,users usr
WHERE project_members.project_role_id IN\'||\'(\'|| p_res_ids||\')
AND usr.usr_id = project_members.usr_id
ORDER BY usr.full_name)foo\';

RETURN ref;

While I try to assign the value into a local variable v_names , it is not working

EXECUTE
\'SELECT comma(full_name) INTO '||v_names||' FROM (SELECT usr.full_name
FROM project_members,users usr
WHERE project_members.project_role_id IN\'||\'(\'|| p_res_ids||\')
AND usr.usr_id = project_members.usr_id
ORDER BY usr.full_name)foo\';

RETURN v_names;

Why is it so. Cant I use 'INTO [variable_name]' inside a dynamic query. Please shed some light.

Regards
Kumar

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2003-12-05 13:02:03 Re: Problem with dynamic query
Previous Message Jamie Lawrence 2003-12-04 21:17:45 Re: relationship/table design question