Thread: FW: Function

FW: Function

From
"Sumita Biswas (sbiswas)"
Date:
Is there nothing like SET NOCOUNT ON; in plpgsql
Is there any option like SET ANSI_NULLS ON in plpgsql.
Do we append # before the temp table names in plpgsql, like we do for
MSSQL ? In case no how do we create a temp table in a function in plsql?



-----Original Message-----
From: Stephan Szabo [mailto:sszabo@megazone.bigpanda.com] 
Sent: Monday, February 16, 2004 11:10 PM
To: Sumita Biswas (sbiswas)
Cc: pgsql-sql@postgresql.org
Subject: RE: [SQL] Function


On Mon, 16 Feb 2004, Sumita Biswas (sbiswas) wrote:

> Thanks for the answer.
> I have one more issue. How do I test a function that I wrote? I was 
> able to create a function called Proc_ConferenceSummary(). In SQL 
> Server I used to run it through query analyzer by writing the 
> following command: exec Proc_ConferenceSummary 
> '12/1/2003','1/23/2004',1,1,0,5001

For functions that return setof or complex types, you can do it as
select * from Proc_ConferenceSummary(...) as alias;

For simple functions you can just use:
select functionname(...);



Re: FW: Function

From
Richard Huxton
Date:
On Tuesday 17 February 2004 14:41, Sumita Biswas (sbiswas) wrote:
> Is there nothing like SET NOCOUNT ON; in plpgsql

What is this supposed to do for you?

> Is there any option like SET ANSI_NULLS ON in plpgsql.

What is this supposed to do for you too?

> Do we append # before the temp table names in plpgsql, like we do for
> MSSQL ? In case no how do we create a temp table in a function in plsql?

The thing to remember with plpgsql is that it's compiled (unlike say plTcl). 
This means that it translates table-names etc. into oids. So what you have to 
be careful of is referring to a temporary table that is created, destroyed an 
re-created (because it's oid will change).

The solution is to use the EXECUTE command to build a dynamic query. Check the 
archives for plenty of other people doing this.

--  Richard Huxton Archonet Ltd