Re: pl/pgsql list as parameter.

From: David Gagnon <dgagnon(at)siunik(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: pl/pgsql list as parameter.
Date: 2005-11-04 20:07:43
Message-ID: 436BBF8F.2060402@siunik.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Here is an example

Regards
/David

CREATE OR REPLACE FUNCTION
usp_Inventaire_Transaction_Statut_Changer(int[], varchar, int, date)
RETURNS INTEGER AS '
DECLARE
requestIds ALIAS FOR $1;
companyId ALIAS FOR $2;
targetStatus ALIAS FOR $3;
transactionDate ALIAS FOR $4;
transactionDate_ timestamp;
inventoryTransaction IR%ROWTYPE;
temp RECORD;
itemIds varchar[]:= ''{}'';
BEGIN

IF ( transactionDate IS NOT NULL) THEN
-- Si la date de requˆte est vide ou si c est la date du jour
IF ( date_trunc(''day'', transactionDate) = CURRENT_DATE )
THEN
transactionDate_ := CURRENT_TIMESTAMP;
ELSE
transactionDate_ := transactionDate;
END IF;

Assa
Assad Jarrahian wrote:

> Hi,
> I have a couple questions, I am tryingto write a function that takes
> as input a list (size being dynamic) of primaryIDKeys, along with a
> userdefined type and returns a set of rows containing those keys.
> Furthermore the rows are exactly (columns) like the table that
> contains the keys, but has an extra field.((so I define my own tupe)
>
>CREATE FUNCTION somefunc(<how do I declare a list of ints>,my_predef_type ) RETURNS SETOF tp_lm_object AS '
>DECLARE
>
> ..........
>
> How do you take in a list of int? And how would one loop through that?
>
>
> Much thanks in advance.
>
> -assad

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Bartlett 2005-11-04 20:42:20 Re: Using native win32 psql.exe using alternative cygwin terminal
Previous Message Jan Peterson 2005-11-04 20:03:39 Re: Image File System Question