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