Skip site navigation (1) Skip section navigation (2)

Re: Initialize the User-defined Aggregate in ECPG

From: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
To: Chengjie Qin <cqin3(at)ucmerced(dot)edu>
Cc: pgsql-in-general(at)postgresql(dot)org
Subject: Re: Initialize the User-defined Aggregate in ECPG
Date: 2012-03-20 04:06:13
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-in-general
On Tue, Mar 20, 2012 at 5:37 AM, Chengjie Qin <cqin3(at)ucmerced(dot)edu> wrote:

> Hi all,
> I'm using the embedded SQL in C to create the User-Defined Aggregate(UDA).
> The command is :
> CREATE AGGREGATE aggname( sfunc=kmeans,
>                          stype=double precision[],
>                          finalfunc=kmeansfinal,
>                          INITCOND='{1,2,3}');
> Since I need to do the aggregation in multiple rounds. I need to initialize
> the INITCOND using the execution result of last execution (aggregation.)
> Any one can tell me how can I initialize the INITCOND using host variables
> instead of hard code the INITCOND?

There is no straight forward way to have 'variable' initial condition.
According to, initial
condition can be a constant string acceptable by state_data_type's in
function. You might be able to achieve what you want by changing sfunc().
Set initial condition as null, and inside sfunc(), i.e. state transition
function, if you see NULL initial condition, pull the initial condition
from the database appropriately. But, this is the last resort. Why do you
need to have variable initial condition? Can you please elaborate the
problem you are solving, there might be simpler ways to handle this.

Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company

In response to

pgsql-in-general by date

Next:From: Pavan DeolaseeDate: 2012-03-20 08:13:51
Subject: Re: Initialize the User-defined Aggregate in ECPG
Previous:From: Chengjie QinDate: 2012-03-20 00:07:53
Subject: Initialize the User-defined Aggregate in ECPG

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group