From: | Rory Campbell-Lange <rory(at)campbell-lange(dot)net> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com> |
Cc: | Postgresql Novice List <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: reuse RECORD in function 'select into'? |
Date: | 2003-05-27 16:42:25 |
Message-ID: | 20030527164225.GA2445@campbell-lange.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Thanks again for your help, Josh.
On 27/05/03, Josh Berkus (josh(at)agliodbs(dot)com) wrote:
> > In the function below I do four "select into" actions to check if
> > particular values already exist in any one of several tables.
> >
> > Can I reuse the RECORD for each 'select into'? The RECORDs are
> > presumably empty after each select into, as the function needs FOUND to
> > be false to continue.
>
> You certainly can, technically. In fact, you don't even need the RECORD to be
> empty.
That makes sense, although my "Postgresql Essential Reference" book
selects into an "EmpRec" record. FOUND eq true if one (or more) rows
returned, I see.
> But you want to be *real* careful doing this. Re-using variables for
> different purposes (in procedural languages), in general, is a very bad idea
> unless you are desperately shourt of memory. It's far too easy to lose
> track of a re-used variable and waste hours debugging.
>
> O'Reilly's "PL/SQL Programming" has an excellent chapter on good programming
> practives for SQL-procedural languages that I would love to razor out and
> distribute as a pamphlet. It would be worth a gander the next time you have
> a long lunch in your local tech book store.
Is this the Oracle PL/SQL book?
--
Rory Campbell-Lange
<rory(at)campbell-lange(dot)net>
<www.campbell-lange.net>
From | Date | Subject | |
---|---|---|---|
Next Message | Rory Campbell-Lange | 2003-05-27 16:47:24 | Re: Examples of accessing postgresql with scripts? |
Previous Message | Josh Berkus | 2003-05-27 16:12:07 | Re: reuse RECORD in function 'select into'? |