Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/08/2013, 06:52
Avatar de shake2427
shake2427
 
Fecha de Ingreso: julio-2011
Mensajes: 116
Antigüedad: 12 años, 9 meses
Puntos: 3
Respuesta: procedimientos almacenados error

Cita:
Iniciado por gnzsoloyo Ver Mensaje
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 que te refieres con cosas que nunca habias visto?

la verdad apenas estoy empezando en esto de los procedimientos almacenados, y me gustaria que me orientaras un poco en este sentido.

gracias de antemano