>>CREATE PROCEDURE crea_ventas_cliente >>@cid_plan char(10), >>@error_msg char(100) output >> >>AS >> >>/*declares here */ >>insert into monithor..ventas_cliente( cid_plan, cid_clie, carticulos_id, ccategoria_3, cproveedor_id, nimporte, npeso) >> select @cid_plan, a.cid_clie, b.carticulos_id, c.ccategoria_3, c.cproveedor_id, >> sum(round(b.nimporte_total,2) * (1 - b.lgratuito) * case when a.ctipo_documento_id = 'NC' then -1 else 1 end ) >> as nimporte, >> sum(b.npeso_detalle * case when a.ctipo_documento_id = 'NC' then -1 else 1 end ) >> as npeso >> from >> ventas.._movimiento_ventas a, >> ventas.._movimiento_ventas_detalle b, >> bdmain.._articulos c >> where >> a.dfecha_documento >= @dfecha_prom_i and >> a.dfecha_documento <= @dfecha_prom_f and >> a.cnumero_documento = b.cnumero_documento and >> b.carticulos_id = c.carticulos_id and >> a.ctipo_documento_id = b.ctipo_documento_id and >> a.cserie_documento = b.cserie_documento and >> a.cestado_documento_id <> 'X' and >> a.ctipo_documento_id in ('FA', 'BO', 'NC', 'ND') and >> b.ckits <> '1' >> group by >> a.cid_clie, b.carticulos_id, >> c.ccategoria_3, c.cproveedor_id >>>>If I call this stored procedure:
>>declare @error2 char(100) >>exec monithor..crea_ventas_cliente '0000000012',@error2 >>>>