Ver Mensaje Individual
  #3 (permalink)  
Antiguo 31/07/2013, 16:47
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 pisando lo que contiene la variable.
Lo único que termina quedando es esto:
Código MySQL:
Ver original
  1. SET @qryrecdene = CONCAT('LIMIT ', p_iniciolimit ,',', p_finlimit);
Debes encadenar lo que ya tiene la variable con lo que le agregas.


ya logre que me uniera toda la consulta el codigo es el siguiente

Código SQL:
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 `movistarmoviles_dev`.`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. BEGIN
  14.  
  15. SET @qryrecdene = concat('SELECT a.fecha_venta,
  16.                                                 b.cod_vendedor as codigo_vendedor,
  17.                                                 b.nom_vendedor as Nombre_vendedor,
  18.                                                 a.num_iden_cliente as Identificacion,
  19.                                                 a.nombre_Cliente as Cliente,
  20.                                                 a.numero_icc as numero_icc,
  21.                                                 a.celular as numero_celular,        
  22.                                                 b.Valor_recarga as valor_recarga,
  23.                                                 (select nombre
  24.                                                    from distribuidores
  25.                                                   where id_distribuidores = (select id_distribuidor  
  26.                                                                                from distribxnegocio
  27.                                                                               where id_radicaciones = a.id_radicaciones)) as Distribuidor,
  28.                                                  (select nombre
  29.                                                      from negocios
  30.                                                     where id_negocio in (select id_negocio from distribxnegocio where id_radicaciones = a.id_radicaciones) ) as Negocio,
  31.                                                 b.fecha_recarga,
  32.                                                 b.fecha_Actualizacion
  33.                                        
  34.                                           FROM radicaciones a, recargas b, distribxnegocio c
  35.                                          where a.Celular = b.num_celular
  36.                                            AND a.producto ="PREPAGO"
  37.                                            and a.id_radicaciones = c.id_radicaciones
  38.                                            and a.numero_icc = (select numero_icc from simcard where id_simcard = c.id_simcard)
  39. ' );
  40.  
  41. IF ((p_fechainicial != 0) AND (p_fechafinal != 0)) THEN
  42.     SET @qryrecdene. = concat('AND b.fecha_recarga between ', p_fechainicial ,' AND ', p_fechafinal);
  43. END IF;
  44.  
  45. SET @qryrecdene. = concat('order by Negocio');
  46. SET @qryrecdene. = concat('LIMIT ', p_iniciolimit ,',', p_finlimit);
  47.  
  48. PREPARE qryexnede FROM @qryrecdene;
  49. EXECUTE qryexnede;
  50.  
  51. END

quiero saber si la condicion del IF esta bien realizada es que estoy llamando el procedimiento de la siguiente forma

call recargas_detallado_agente(1,1000,'2012-11-01','2012-11-13')

y ahi deveria entrar al if y poner el filtro en la consulta pero no me lo pone.