Error pl : missing FROM-clause entry for table

From: "Conrado Blasetti" <conrado(at)mapfre(dot)com(dot)ar>
To: <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Error pl : missing FROM-clause entry for table
Date: 2009-02-13 14:02:18
Message-ID: 76A99F19229DC440909CF1B905F8012C077AB8DB@sar001998.Mapfre.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Gente, buenos días.
Tengo una function que me está arrojando este error:

NOTICE: 2º Alumno: 1127 Ano: 2009 Mes: 04 Cuota: CUO
CONTEXT: PL/pgSQL function "recibos_gen01" line 31 at assignment
NOTICE: pasa 0: 200904
CONTEXT: PL/pgSQL function "recibos_gen02" line 21 at assignment
PL/pgSQL function "recibos_gen01" line 31 at assignment
NOTICE: pasa 00: 1127
CONTEXT: PL/pgSQL function "recibos_gen02" line 21 at assignment
PL/pgSQL function "recibos_gen01" line 31 at assignment
NOTICE: pasa 000: N
CONTEXT: PL/pgSQL function "recibos_gen02" line 21 at assignment
PL/pgSQL function "recibos_gen01" line 31 at assignment
ERROR: missing FROM-clause entry for table "reg_alumnos"
LINE 1: SELECT TO_CHAR(reg_alumnos.fec_ingreso,'YYYYMM')
^
QUERY: SELECT TO_CHAR(reg_alumnos.fec_ingreso,'YYYYMM')
CONTEXT: PL/pgSQL function "recibos_gen03" line 193 at RAISE
PL/pgSQL function "recibos_gen02" line 21 at assignment
PL/pgSQL function "recibos_gen01" line 31 at assignment

********** Error **********

ERROR: missing FROM-clause entry for table "reg_alumnos"
SQL state: 42P01
Context: PL/pgSQL function "recibos_gen03" line 193 at RAISE
PL/pgSQL function "recibos_gen02" line 21 at assignment
PL/pgSQL function "recibos_gen01" line 31 at assignment

Tengo el acceso a una tabla donde asigno la fila a una variable del rowtype de esta tabla, luego, cuando leo el campo fec_ingreso, me arroja el error de arriba.
El registro tiene datos, en los raise notices estan los datos, pero cuando quiero hacer RAISE NOTICE 'error: %', TO_CHAR(reg_alumnos.fec_ingreso,'YYYYMM'); salta el error.

Tabla:

CREATE TABLE alumnos_generacion
(
cod_alumno numeric NOT NULL,
orden integer NOT NULL,
fec_equipo timestamp without time zone NOT NULL,
cod_usr character varying(8) NOT NULL,
fec_ingreso date NOT NULL,
fec_baja date,
nivel numeric NOT NULL,
mca_egresado character varying(1) NOT NULL,
mca_egresado_anio_siguiente character varying(1) NOT NULL,
mca_hijo_maestro character varying(1) NOT NULL,
mca_beca character varying(2) NOT NULL,
nro_hijo numeric NOT NULL,
nro_hijo_anio_siguiente numeric NOT NULL,
porc_descuento numeric(10,2) NOT NULL,
imp_descuento numeric(10,2) NOT NULL,
observaciones text,
CONSTRAINT pk_alumnos_generacion PRIMARY KEY (cod_alumno, orden)
);

Por otro lado, la function es:

DECLARE
l_ret TEXT;
--
c_alumno CURSOR ( p_cod_alumno NUMERIC ) IS
SELECT a.*
FROM alumnos_generacion a
WHERE orden = ( SELECT MAX(orden)
FROM alumnos_generacion
WHERE cod_alumno = p_cod_alumno)
AND cod_alumno = p_cod_alumno
;
..
..
reg_alumno alumnos_generacion%ROWTYPE; --Datos del alumno
..
..
..

BEGIN
....
...
..

OPEN c_alumno ( p_cod_alumno );
FETCH c_alumno INTO reg_alumno;
IF NOT FOUND THEN
CLOSE c_alumno;
RETURN 'N|Alumno inexistente: ' || p_cod_alumno;
END IF;
CLOSE c_alumno;
..
...
.
raise notice 'pasa 0: % ', l_per_pago;
raise notice 'pasa 00: % ', reg_alumno.cod_alumno;
raise notice 'pasa 000: % ', reg_alumno.mca_egresado;
raise notice 'pasa 1: % ', TO_CHAR(reg_alumnos.fec_ingreso,'YYYYMM');

END;

En el 4 raise se va

Ven algo raro?
Desde ya, gracias.
Saludos,
Conrado

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message marcelo Cortez 2009-02-13 14:17:27 Re: Error pl : missing FROM-clause entry for table
Previous Message p2p p2p 2009-02-13 13:27:40 Re: High Load Average