Skip site navigation (1) Skip section navigation (2)

foreach in sql functions

From: "Zac Hillier" <zac(at)affectors(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: foreach in sql functions
Date: 2002-10-02 22:16:16
Message-ID: 007801c26a61$567f4af0$667ba8c0@ws (view raw or flat)
Thread:
Lists: pgsql-general
Hi All,

I have only recently started using pgsql and would like to try some internal
functions as it appears this would be quicker than running similar functions
from php.

Is it possible to write sql functions with a foreach style loop?


CREATE FUNCTION crt_bsk_dtl(integer) RETURNS integer AS '

SELECT PrdKey FROM Prd WHERE Sts < 999;

foreach(Prd.PrdKey){

    INSERT INTO BskDtl (BskKey, PrdKey) VALUES ($1, Prd.PrdKey);

}

SELECT 1;
' LANGUAGE SQL


Any help or pointers very much appreciated.

Thanks

Zac


Responses

pgsql-general by date

Next:From: Oleg LebedevDate: 2002-10-02 22:24:41
Subject: Re: foreach in sql functions
Previous:From: Mark WilsonDate: 2002-10-02 22:13:00
Subject: Re: database session variables

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group