Re: creating a function with a variable table name

From: George Nychis <gnychis(at)cmu(dot)edu>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: creating a function with a variable table name
Date: 2007-03-01 16:47:02
Message-ID: 45E70386.8080900@cmu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

do I need to use PREPARE with it also?

A. Kretschmer wrote:
> am Thu, dem 01.03.2007, um 11:17:46 -0500 mailte George Nychis folgendes:
>> Hey all,
>>
>> I'm trying to create a function in which the table a query is run on is
>> variable, but I guess this is not as easy as I thought.
>>
>> BEGIN
>> dp=> CREATE FUNCTION stats_addr_dst(date,text)
>> ...
>> dp'> FROM $2
>> ^
>> How can I pass the table name?
>
> Build a string with your SQL and EXECUTE this string.
>
>
> Andreas

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-03-01 16:48:23 Re: Why does "group by" need to match select fields?
Previous Message George Nychis 2007-03-01 16:40:11 get username of user calling function?