"Alex Weslowski" <[EMAIL PROTECTED]> writes: > DECLARE > peg VARCHAR(5) := ''; > rs03 VARCHAR(3) := ''; > rs12 VARCHAR(3) := ''; > rec RECORD; > BEGIN > FOR rec IN SELECT Symbol, RS03, RS12, Peg > FROM TestBug WHERE Date=d > ORDER BY RS12 DESC LOOP
The problem is that you've got local variables shadowing the field names you want to use. What the SQL engine sees from that is SELECT Symbol, $1, $2, $3 FROM TestBug WHERE Date=$4 ORDER BY $5 DESC and it just assigns random ?columnN? names to the record columns (which are going to have useless empty-string values anyway). Use different local variable names, or qualify the field references in the SELECT, eg TestBug.RS03. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org