pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Morgan Curley <mcurley@e4media.com>
To: pgsql-sql@postgresql.org
Subject: Re: Re:  Inserts in triggers Follow Up
Date: Wed, 25 Jul 2001 08:14:09 -0700
Message-ID: <web-91191@davinci.ethosmedia.com> (raw)
In-Reply-To: <4.3.2.7.2.20010725085946.023e24a8@e4media.com>

Morgan,

> One other problem I am having in that proc is SELECT'ing INTO a var.
> 
> declare
>          id lookup_sports.sport_id%TYPE;
> begin
>          SELECT INTO id sport_id FROM lookup_sports WHERE....some
> clause
> 
> id is always null

That's because the SELECT INTO variable and SELECT INTO record syntax
are confusingly different.  It's

for records:
SELECT INTO record_var * FROM ...

for simple variables:
SELECT column INTO variable FROM ...

I'm not clear on the origin of the inconsistency; my guess is that jan
copied it over from PL/SQL.

> good suggestion to differentiate my vars from my columns. For the
> sake of 
> expediency I named them the same so when I was writing the insert 
> statements I could just copy/past my columns list into my values
> list.

You should *always* do this.  Most functions with identical column and
variable names will confuse the compiler and result in errors.

It'd have been nice if PL/pgSQL supported variable naming with a special
character preifx (e.g. $variable).  Does anyone know of a character that
won't give the parser fits?  Currently I'm using "v_", same as Richard.

-Josh


______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco







view thread (5+ messages)  latest in thread

Message-ID: <web-91191@davinci.ethosmedia.com>
Permalink:  ../web-91191@davinci.ethosmedia.com/
Also on:    postgresql.org/message-id/web-91191@davinci.ethosmedia.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, mcurley@e4media.com
  Subject: Re: Re:  Inserts in triggers Follow Up
  In-Reply-To: <web-91191@davinci.ethosmedia.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox