2014-02-11 17:17 GMT-05:00 cDaniel GE <[email protected]>: > > CREATE OR REPLACE FUNCTION pagar( id_deuda integer, modo integer, monto > double precision) > RETURNS double precision AS > $BODY$ > > declare > _cur_amort refcursor; > _amort tabla_amortizacion%rowtype; >
no hay necesidad de usar un cursor, puedes usar un for, algo como for _amort in select * from .... loop /* contenido */ end loop; http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-RECORDS-ITERATING > order by case > when modo =1 then fecha asc > else fecha desc end; y funciona tambien si haces esto: for _amort in execute 'select * from tabla where condiciones order by fecha ' || case modo when 1 then ' asc ' else ' desc ' loop end loop; y puedes hacer lo mismo con cursores open _cur_amort for execute var_consulta_armada -- Jaime Casanova www.2ndQuadrant.com Professional PostgreSQL: Soporte 24x7 y capacitación Phone: +593 4 5107566 Cell: +593 987171157 - Enviado a la lista de correo pgsql-es-ayuda ([email protected]) Para cambiar tu suscripción: http://www.postgresql.org/mailpref/pgsql-es-ayuda
