472,145 Members | 1,406 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

is General Bits Issue # 43 correct?

In this issue the following statement is made:

"In plpgsql, you cannot run a dynamic SELECT statement and be able to
do anything with the selected data. You cannot assign the selected
value to a variable or return the selected value from the function. You
can, however, easily construct INSERT, UPDATE and DELETE statements as
well a DDL (Data Definition Language: CREATE, ALTER, etc.)"

This is not my experience. For example, I am doing the following in my
code and it works just fine:

for v_tmp in execute ''select min(list_price) as price_selected_min,
max(list_price) as price_selected_max
from table1
where xx_id = '' || p_xx_id ||
'' and date_deleted is null'' loop

v_price_selected_min := v_tmp.price_selected_min;
v_price_selected_max := v_tmp.price_selected_max;

end loop;

It works just fine for me.

I also can return result set using

for r in execute ''select statement'' loop
return next r;
end loop;

Avi
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #1
0 1021

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ken | last post: by
64 posts views Thread by yossi.kreinin | last post: by
13 posts views Thread by Tomás | last post: by
12 posts views Thread by Arash Partow | last post: by
23 posts views Thread by Umesh | last post: by
40 posts views Thread by KG | last post: by
77 posts views Thread by borophyll | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.