Hola Amigos
Estoy trabajando store procedures en Sql server con Power builder y tengo unas dudas ya que no conozco a profundidad el sql les comento tengo un datawindows, que es llenado por un
procedimiento pero lo que deseo hacer es si cumple una determinada condicion (si el pedido solicitado es menor o igual a la capacidad de la casilla del almacen mostrar el pedido, sino mostrar 0) esto sera reflejado en el datawindows pero me muestra un error
CREATE PROCEDURE sp_inv_ingreso_existencias_S(@cc_noting varchar(12))
As
SELECT MEXIST.cc_artic AS Codigo,
MARTICUL.cd_artic AS Descripcion,
LDNOTSAL_WRK.fq_artic AS Cantidad_NI,
MEXIST.cc_ubic AS Ubicacion_Articulo,
TDISTALM.cd_ubic AS Descripcion_Ubicacion,
MARTICUL.cc_unmed AS Unidad_Original,
LDNOTSAL_WRK.cc_unmed AS Unidad_Alterna,
AARTUBIC.fq_stock/AUMALTER.fq_umdest AS Stock_Inicial,
MEXIST.fq_artic/AUMALTER.fq_umdest AS Stock_Actual,
AARTUBIC.fq_stock/AUMALTER.fq_umdest - MEXIST.fq_artic/AUMALTER.fq_umdest AS Capacidad_X_Casilla,
AUMALTER.fq_umdest AS Equivalencia,
ldnotsal_wrk.cn_item,
IF (select fq_artic from LDNOTSAL_WRK aa,AARTUBIC a,AUMALTER b,MEXIST c where aa.fq_artic<= (A.fq_stock/b.fq_umdest - c.fq_artic/b.fq_umdest))
begin
LDNOTSAL_WRK.fq_artic AS Cantidad_ingresada
end
else
begin
0.00 AS Cantidad_Ingresada
end
FROM
LDNOTSAL_WRK ,
MARTICUL (NOLOCK),
MEXIST (NOLOCK),
TDISTALM (NOLOCK),
TUNMEDID (NOLOCK),
AARTUBIC (NOLOCK),
AUMALTER (NOLOCK)
WHERE
LDNOTSAL_WRK.cc_codigo = @cc_noting AND
MARTICUL.cc_artic = LDNOTSAL_WRK.cc_artic AND
MEXIST.cc_artic = MARTICUL.cc_artic AND
TDISTALM.cc_almac = MEXIST.cc_almac AND
TDISTALM.cc_ubic = MEXIST.cc_ubic AND
MEXIST.cc_almac = LDNOTSAL_WRK.cc_almac AND
TUNMEDID.cc_unmed = LDNOTSAL_WRK.cc_unmed AND
AARTUBIC.cc_almac = MEXIST.cc_almac AND
AARTUBIC.cc_ubic = MEXIST.cc_ubic AND
AARTUBIC.cc_artic = MEXIST.cc_artic AND
AARTUBIC.cb_ACTIVO = '1' AND
AUMALTER.cc_umorig = MARTICUL.cc_unmed AND
AUMALTER.cc_umdest = LDNOTSAL_WRK.cc_unmed AND
AUMALTER.cc_artic = LDNOTSAL_WRK.cc_artic
ORDER BY MEXIST.cc_artic,MEXIST.cc_ubic
me sale error en la linea del if y del begin
ayudenme porfa
doris