Ver Mensaje Individual
  #4 (permalink)  
Antiguo 31/07/2013, 17:19
Avatar de gnzsoloyo
gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: procedimientos almacenados error

Estás mezclando C con MySQL. Has puesto cosas que nunca vi, y no estoy segudo de que funcionen.
Además, la consulta a mi entender es innecesariamente ineficiente.

Yo la armaría así:
Código MySQL:
Ver original
  1. -- --------------------------------------------------------------------------------
  2. -- Routine DDL
  3. -- Note: comments before and after the routine body will not be stored by the server
  4. -- --------------------------------------------------------------------------------
  5. DELIMITER $$
  6.  
  7. CREATE PROCEDURE `recargas_detallado_agente` (
  8. IN p_iniciolimit int,
  9. IN p_finlimit int,
  10. IN p_fechainicial datetime,
  11. IN p_fechafinal datetime
  12. )
  13.  
  14. SET @qryrecdene = concat('SELECT
  15.     a . fecha_venta ,
  16.     b . cod_vendedor        codigo_vendedor ,
  17.     b . nom_vendedor        Nombre_vendedor ,
  18.     a . num_iden_cliente    Identificacion ,
  19.     a . nombre_Cliente      Cliente ,
  20.     a . numero_icc          numero_icc ,
  21.     a . celular             numero_celular ,
  22.     b . Valor_recarga       valor_recarga ,
  23.     D.nombre               Distribuidor,
  24.     N.nombre               Negocio,
  25.     b . fecha_recarga ,
  26.     b . fecha_Actualizacion
  27. FROM
  28.     radicaciones a
  29.     INNER JOIN  recargas   b ON a.Celular  =  b.num_celular
  30.     INNER JOIN distribxnegocio c ON a.id_radicaciones  =  c.id_radicaciones  
  31.     INNER JOIN distribuidores D ON  D.id_distribuidores = c.id_distribuidor
  32.     INNER JOIN negocios N ON N.id_negocio = c.id_negocio
  33.     INNER JOIN simcard s ON s.id_simcard  =  c.id_simcard
  34. WHERE
  35.       a.producto  = ''PREPAGO''');
  36.  
  37. IF ((p_fechainicial != 0) AND (p_fechafinal != 0)) then
  38.     SET @qryrecdene = concat(@qryrecdene, ' AND b.fecha_recarga between ''', p_fechainicial ,''' AND ''', p_fechafinal, '''');
  39.  
  40. SET @qryrecdene = concat(@qryrecdene, ' order by Negocio');
  41. SET @qryrecdene. = concat(@qryrecdene, 'LIMIT ', p_iniciolimit ,',', p_finlimit);
  42.  
  43. PREPARE qryexnede FROM @qryrecdene;
  44. EXECUTE qryexnede;
  45.  
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)