Re: Dynamic function execution? - Mailing list pgsql-general

From Nick Johnson
Subject Re: Dynamic function execution?
Date
Msg-id F65AC517-AB1D-468C-BCAA-0BAC46A5B8FC@notdot.net
Whole thread Raw
In response to Re: Dynamic function execution?  (Michael Fuhr <mike@fuhr.org>)
List pgsql-general
On 14/03/2006, at 10:26 AM, Michael Fuhr wrote:

On Tue, Mar 14, 2006 at 07:21:51AM -0800, Nick Johnson wrote:

On 14/03/2006, at 12:05 AM, Michael Fuhr wrote:

Why do you need to do this?  What problem are you trying to solve?


I want to associate Postgres functions with rows of a table (eg, a  
table column of datatype regproc or regprocedure) and be able to  
execute the function associated with that  row in a query.


Could you post an example?  Others might be interested in seeing
an application of something like that.

The example that's actually driving this is rather stupid (though amusing). I'm building a Postgres based adventure game. Eg, SELECT n(); SELECT look(); etc. I want to be able to execute on_enter, on_exit etc events, the handles to the event functions being stored in the table.

A more sensible example (though not one this will be immediately used for) is something we're doing at my work: The database contains a number of stored procedures implementing 'models' - they're functions that essentially perform data-mining on the database. There's a table that has metadata about each of these models, allowing the system to determine which ones need executing, and when. Being able to directly call them would be useful here, too.

-Nick Johnson

pgsql-general by date:

Previous
From: Chris
Date:
Subject: Re: Turn OFF Stats of Postgresql
Next
From: Bruno Wolff III
Date:
Subject: Re: Wisconsin Circuit Court Access (WCCA) on