Re: Pl/pgsql function - Mailing list pgsql-general

From Rob Sargent
Subject Re: Pl/pgsql function
Date
Msg-id 4DEA3F98.7090108@gmail.com
Whole thread Raw
In response to Pl/pgsql function  (Nick Raj <nickrajjain@gmail.com>)
List pgsql-general

Nick Raj wrote:
> I am implementing some pl/pgsql functions.
>
> Is there any way to change the input
> for example- I got some value by $1. I want to modify this value
> (means split that value), Can we do this and how?
>
> Second thing,
> Suppose i defined a function test as
>
> select test('geom',the_geom,time) from tablename
> .....
> Inside body,
> How can i get the tablename inside the body (because i haven't pass
> table name to function)
> ......
> end
If 'tablename' has to change then you need to take a look at "dynamic
sql" and the EXECUTE construct.

You can surely manipulate the value of $1 into either other variables or
define it as on OUT parameter if you want the caller to get  a different
value back.  The 8.3 chapter on this is here
<http://www.postgresql.org/docs/8.3/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-ASSIGNMENT>

pgsql-general by date:

Previous
From: Jon Smark
Date:
Subject: Converting an hstore into a key/value record
Next
From: "David Johnston"
Date:
Subject: Re: Pl/pgsql function