Re: stored procedure / Function

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Alain Roger <raf(dot)news(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: stored procedure / Function
Date: 2006-11-07 08:59:17
Message-ID: 45504AE5.4060004@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alain Roger wrote:
> Hi,
>
> How to retrieve the IN parameter of a function for later use ?
>
> i tried this :
>
> CREATE OR REPLACE FUNCTION "public"."SP_U_001" ("TypeOfArticle" varchar)
> RETURNS SETOF "public"."active_articles" AS

My advice: Don't quote your identifiers unless you really really want
them to be case sensitive. Usually there's no benefit, and it can add
quite a bit of confusion ("What do you mean my function does not
exist?!? It's right here!").

> $body$
> DECLARE
> TypeArt VARCHAR := TypeOfArticle;
> rec RECORD;
> res active_articles;
> /**************************************/
> BEGIN
>
> SELECT articletypes.articletype_id INTO tpart FROM articletypes
> WHERE articletypes.articletype_type = TypeArt;
> ....
>
> but it seems that TypeArt VARCHAR := TypeOfArticle; does not
> work....
>
> Can you help me ?

I don't think that assignments in the declare block are allowed. You
could make your variable an alias though:
DECLARE
TypeArt ALIAS FOR "TypeOfArticle";

You could also move the assignment into the body of the function.

Although I wonder why you don't just use the IN parameter.

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2006-11-07 09:05:08 Re: FOR ... IN
Previous Message Joe Conway 2006-11-07 08:22:39 Re: R and postgres