No, it will not work twice in the same query as is.

If you want to code two counter buckets and pass in
some way to distinguish between the two yada yada yada
it is possible.  It is also possible to code this to
do multi-level counting/breaks/calculations, etc.

But the SD dictionary is by connection. So any values
stored in it need to be initialized at the appropriate
time *outside* of the first use.

elein

On Sun, Apr 11, 2004 at 12:38:20AM -0400, Greg Stark wrote:
> 
> elein <[EMAIL PROTECTED]> writes:
> 
> > create or replace function pycounter(integer)
> > returns integer as
> > '
> >    if args[0] == 0:
> >       SD["nextno"] = 1
> >       return SD["nextno"]
> >    try:
> >       SD["nextno"] += 1
> >    except:
> >       SD["nextno"] = 1
> >    return SD["nextno"]
> > ' language 'plpythonu';
> > 
> > And clearly it can be done faster as a little
> > C function.
> 
> Does this approach have a hope of working if it's used twice in the same
> query?
> 
> 
> -- 
> greg
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to