From: | Rob Sargent <robjsargent(at)gmail(dot)com> |
---|---|
To: | Ben Carbery <ben(dot)carbery(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PL/PGSQL - dynamic variable names |
Date: | 2011-06-29 02:30:40 |
Message-ID: | 4E0A8E50.3090304@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ben Carbery wrote:
>
> Hm, "a" isn't a variable,it's the value of stuff[1].
>
>
> It's both..
>
> DECLARE
> a integer;
> b integer;
>
> The point is I want a dynamically named variable. Here I've named them
> the same as stuff[i] but they can be anything provided it is a
> different variable name on each loop iteration. The manual is not
> entirely clear on where loop variable substitution does and does not
> apply with FOR.
>
>
>
> Did you try
> declaring a,b,c,d as the return type of the respective functions?
>
>
> How would this help?
I understand that your original post was pseudo-code, but aren't you
forced into firing a fixed set of functions {stuff[]} which all use the
same parameters? Seems that set of functions could be rolled into one
which returns a list of values. Or are you also passing in a,b,c,d (with
name-of-function values (strings)) and hoping to slam the function's
return value (int?) back into the corresponding (perhaps out)
parameter? Hm, you could pass in an array of names, iterate over the
array, call the named function and load the return value into a single
declared array, by index, in each iteration of the loop.
Weird!
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2011-06-29 02:55:45 | Re: [PERFORM] change sample size for statistics |
Previous Message | Ben Carbery | 2011-06-29 02:10:32 | Re: PL/PGSQL - dynamic variable names |