Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/07/2013, 14:35
Avatar de shake2427
shake2427
 
Fecha de Ingreso: julio-2011
Mensajes: 116
Antigüedad: 12 años, 9 meses
Puntos: 3
procedimientos almacenados error

buenas tardes

tengo el siguiente codigo

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

pero al tratar de ejecutarlo me muestra un error de sintaxis, le he buscado una y mil formas de buscar la solucion, pero no he podido.

por favor si me pueden ayudar o darme alguna guia.

gracias de antemano.