[Pgsql-ayuda] Ayuda con tipos de datos y funciones

Edwin Quijada listas_quijada@hotmail.com
Thu, 19 Feb 2004 06:59:02 +0000


Hola a las 3:10am ya no doy mas y les pido ayuda con esta funcion:

CREATE OR REPLACE FUNCTION public.entrada_recibos(date, date, int2)
  RETURNS int2 AS
'
DECLARE
     fecha1 ALIAS FOR $1;
     fecha2 ALIAS FOR $2;
     sucursal ALIAS FOR $3;
     monto  numeric(15,2);
     imp  numeric(15,2);
     comision  numeric(15,2);
     reg record;
     reg1 record;
     nodoc int4;
     tipo varchar(10);
BEGIN
   tipo:=get_tipo_doc(58);
   SELECT INTO reg1 * FROM t_cuentas_defecto;
--**************RECIBOS DE CAJA*********************
   t1:=get_tipo_doc(47) || \'%\'; t2:=get_tipo_doc(48) || \'%\';
   SELECT INTO reg SUM(f_monto)as neto,SUM(f_impuesto) as 
imp,SUM(f_montocomision) as comision
   FROM t_recibos_caja
   WHERE f_fecha>=fecha1 AND
   f_fecha<=fecha2 AND
   f_sucursal=sucursal AND
   f_posteado=FALSE AND
     (f_tipo_recibo ILIKE t1 or f_tipo_recibo ILIKE t2);
   --
    IF reg.neto >0 THEN
       descri:=\'ENTRADA DE DIARIO RECIBOS DESDE \' || cast(fecha1 as 
varchar) || \'  \' || cast(fecha2 as varchar);
       nodoc:=get_secuencia(tipo);
       INSERT INTO t_transacciones_contables    --creando la transaccion 
contable
       VALUES(tipo,nodoc,current_date,descri,reg.neto,-1,\'\');
       --Creando los detalles
       INSERT INTO t_detalle_contable --Cuenta 1201 CAJA
       
VALUES(tipo,nodoc,current_date,reg.neto,0,descri,reg1.cuenta_v10,\'\');
       --1302 cuenta por cobrar ---
       INSERT INTO t_detalle_contable
       
VALUES(tipo,nodoc,current_date,0,reg.neto,descri,reg1.cuenta_v1,\'\');
       --impuesto--
       INSERT INTO t_detalle_contable
       VALUES(tipo,nodoc,current_date,reg.imp,0,descri,reg1.cuenta_v4,\'\'); 
--reserva neto 40% gasto
       --impuesto de las ventas--
       INSERT INTO t_detalle_contable
       VALUES(tipo,nodoc,current_date,0,reg.imp,descri,reg1.cuenta_v9,\'\');
       --SI HAY COMSIONES
       IF reg.comision >0 THEN
          INSERT INTO t_detalle_contable
          
VALUES(tipo,nodoc,current_date,reg.comision,0,descri,reg1.cuenta_v7,\'\');
       --Prima Neta--
          INSERT INTO t_detalle_contable
          
VALUES(tipo,nodoc,current_date,0,reg.comision,descri,reg1.cuenta_v8,\'\');
       END IF;
          --Posteando las polizas a true--
           UPDATE t_recibos_caja SET f_posteado=TRUE
           WHERE f_fecha>=fecha1 AND
           f_fecha<=fecha2 AND
	    f_sucursal=sucursal AND
           f_posteado=FALSE AND
           (f_tipo_recibo ILIKE t1 OR f_tipo_recibo ILIKE t2);
    END IF; --If final de LOS RECIBOS--
--* * *  * * * * * * *recibos de fianzas  * * * * * * * *
  --**************RECIBOS DE CAJA FIANZAS*********************
   t1:=get_tipo_doc(50) || \'%\'; t2:=get_tipo_doc(53) || \'%\';
   SELECT INTO reg SUM(f_monto)as neto,SUM(f_impuesto) as 
imp,SUM(f_montocomision) as comision
   FROM t_recibos_caja
   WHERE f_fecha>=fecha1 AND
   f_fecha<=fecha2 AND
   f_sucursal=sucursal AND
   f_posteado=FALSE AND
     (f_tipo_recibo ILIKE t1 or f_tipo_recibo ILIKE t2);
   --
    IF reg.neto >0 THEN
       descri:=\'ENTRADA DE DIARIO RECIBOS FIANZAS DESDE \' || cast(fecha1 
as varchar) || \'  \' || cast(fecha2 as varchar);
       nodoc:=get_secuencia(tipo);
       INSERT INTO t_transacciones_contables    --creando la transaccion 
contable
       VALUES(tipo,nodoc,current_date,descri,reg.neto,-1,\'\');
       --Creando los detalles
       INSERT INTO t_detalle_contable --Cuenta 1201 CAJA
       
VALUES(tipo,nodoc,current_date,reg.neto,0,descri,reg1.cuenta_v10,\'\');
       --1302 cuenta por cobrar ---
       INSERT INTO t_detalle_contable
       
VALUES(tipo,nodoc,current_date,0,reg.neto,descri,reg1.cuenta_v1,\'\');
       --impuesto--
       INSERT INTO t_detalle_contable
       VALUES(tipo,nodoc,current_date,reg.imp,0,descri,reg1.cuenta_v4,\'\'); 
--reserva neto 40% gasto
       --impuesto de las ventas--
       INSERT INTO t_detalle_contable
       VALUES(tipo,nodoc,current_date,0,reg.imp,descri,reg1.cuenta_v9,\'\');
       --SI HAY COMSIONES
       IF reg.comision >0 THEN
          INSERT INTO t_detalle_contable
          
VALUES(tipo,nodoc,current_date,reg.comision,0,descri,reg1.cuenta_v7,\'\');
       --Prima Neta--
          INSERT INTO t_detalle_contable
          
VALUES(tipo,nodoc,current_date,0,reg.comision,descri,reg1.cuenta_v8,\'\');
       END IF;
          --Posteando las polizas a true--
           UPDATE t_recibos_caja SET f_posteado=TRUE
           WHERE f_fecha>=fecha1 AND
           f_fecha<=fecha2 AND
          f_sucursal=sucursal AND
           f_posteado=FALSE AND
           (f_tipo_recibo ILIKE t1 OR f_tipo_recibo ILIKE t2);
    END IF; --If final de LOS RECIBOS--
    RETURN 1;
END;'
  LANGUAGE 'plpgsql' VOLATILE;

Al momento de correrla me lanza el sigte error:

select entrada_recibos('2004-2-17','2004-2-17',1);

ERROR:  Function entrada_recibos("unknown", "unknown", integer) does not 
exist
	Unable to identify a function that satisfies the given argument types
	You may need to add explicit typecasts

Ya no se que mas hacer , alguien tiene alguna idea , tal vez por la hora se 
me fundio el cerebrito :(
AYUDA!!!!!

*-------------------------------------------------------*
*-Edwin Quijada
*-Developer DataBase
*-JQ Microsistemas
*-809-747-2787
* " Si deseas lograr cosas excepcionales debes de hacer cosas fuera de lo 
comun"
*-------------------------------------------------------*

_________________________________________________________________
MSN Amor: busca tu ½ naranja http://latam.msn.com/amor/