Juan Miguel Paredes <juan.paredes@xxxxxxxxx> writes: > DECLARE > res helpdesk.tp_res_conestadosdisponiblessoporte; > BEGIN > IF estadoactual = 'Abierto' THEN > SELECT INTO res.filas * > FROM tbl_estadosoporte Without having looked at the code, I suspect that plpgsql just assumes res.filas is of scalar type and so fails to match it up to the entire SELECT INTO * list. (It's not obvious how to do "better" for arbitrary combinations of scalar types, composite types, and user expectations...) I'd recommend that you declare a row variable of type tbl_estadosoporte, select into that, and then worry about constructing the larger composite result. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match