Update question and SQL question

From: Steve Lane <slane(at)fmpro(dot)com>
To: PostgreSQL General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Update question and SQL question
Date: 2002-07-02 05:28:19
Message-ID: B946A423.F7DC%slane@fmpro.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-advocacy pgsql-general

Hello all:

Two unrelated questions.

1. I needed to do an update to a table called iep_form_002. It has a number
of triggers on it. The update was to a single field, which is not involved
in any way in any of the triggers. When I executed the update, I got the
message

NOTICE: Error occurred while executing PL/pgSQL function
lookup_name_district
NOTICE: line 1 at select into variables
ERROR: record student_rec is unassigned yet

lookup_name_district is defined as follows:

DECLARE student_rec record; BEGIN SELECT INTO student_rec * FROM iep_student
WHERE id_student = new.id_student; SELECT INTO new.name_district
name_district FROM iep_district WHERE id_county = student_rec.id_county AND
id_district = student_rec.id_district; RETURN new; END;

I had seen earlier references to this problem. Something I read led me to
think that upgrading to 7.2 (from 7.1) would make this go away, but it
didn't. Temporarily disabling all triggers on the table worked just fine.

So I'm guess there's something systematically off in the way I'm doing
triggers. Any clues? I can provide more info if necessary, of course.

2. I thought I had understood the SQL standard to say that using AS when
making column aliases was always optional, yet in postgres I encounter cases
where I must use it or a parse error results. As far as I can tell, these
cases only occur when I'm aliasing a column that has some kind of function
or aggregate. so:

iep_db=# select name_list_guardian, length(name_list_guardian) l from
iep_form_001;
ERROR: parser: parse error at or near "l"
iep_db=# select name_list_guardian, length(name_list_guardian) as l from
iep_form_001;

The second form of this works. Am I just misremembering SQL?

Thanks,

Steve

In response to

Responses

Browse pgsql-advocacy by date

  From Date Subject
Next Message Tom Lane 2002-07-02 13:54:54 Re: Update question and SQL question
Previous Message Justin Clift 2002-06-28 03:52:27 Suggestions for an update to the PHP manual?

Browse pgsql-general by date

  From Date Subject
Next Message Christoph Dalitz 2002-07-02 10:38:46 namespaces and schemas
Previous Message Lev Lvovsky 2002-07-02 05:25:23 triggers on date?