foreach in sql functions - Mailing list pgsql-general

From Zac Hillier
Subject foreach in sql functions
Date
Msg-id 007801c26a61$567f4af0$667ba8c0@ws
Whole thread Raw
Responses Re: foreach in sql functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: foreach in sql functions  (Richard Huxton <dev@archonet.com>)
Re: foreach in sql functions  (Tino Wildenhain <tino@wildenhain.de>)
List 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


pgsql-general by date:

Previous
From: "Mark Wilson"
Date:
Subject: Re: database session variables
Next
From: "Oleg Lebedev"
Date:
Subject: Re: foreach in sql functions