Re: Pl/pgsql function

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: Nick Raj <nickrajjain(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Pl/pgsql function
Date: 2011-06-04 14:22:16
Message-ID: 4DEA3F98.7090108@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-06-04 15:44:17 Re: Pl/pgsql function
Previous Message Nick Raj 2011-06-04 14:04:25 Pl/pgsql function