hola amigos, Tengo un problema con una consulta para un proceso de autorización cuando trata de capturar datos tengo el error en una linea indicándome erro en sintaxis $
este es el query
DECLARE TIPODOC VARCHAR(3);
DECLARE DOC_BASE VARCHAR(2);
DECLARE STATUS VARCHAR(1);
DECLARE DocTotal DECIMAL (21,6);
STATUS := '-';
TIPODOC := SUBSTRING('Entregas - C038435280', 1, 3);
DOC_BASE := 'NO';
IF :TIPODOC = 'Fac' THEN
BEGIN
IF '-1' = '15' THEN
BEGIN
STATUS := IFNULL((SELECT "WddStatus" FROM ODLN WHERE "DocNum" = ''),'Z');
IF :STATUS = 'P' THEN
BEGIN
IF ((SELECT (IFNULL("DocTotal",0) - IFNULL("PaidToDate",0)) FROM ODLN WHERE "DocNum" = '') - 23800.000000) >= 0 THEN
BEGIN
DOC_BASE := 'SI';
END;
END IF;
END;
END IF;
END;
ELSE
BEGIN
IF '-1' = '17' THEN
BEGIN
STATUS := IFNULL((SELECT "WddStatus" FROM ORDR WHERE "DocNum" = ''),'Z');
IF :STATUS = 'P' THEN
BEGIN
IF ((SELECT (IFNULL("DocTotal",0) - IFNULL("PaidToDate",0)) FROM ORDR WHERE "DocNum" = '') - 23800.000000) >= 0 THEN
BEGIN
DOC_BASE := 'SI';
END;
END IF;
END;
END IF;
END;
END IF;
END;
END IF;
SELECT CASE
WHEN (SELECT OINV."GrosProfit"/ ((OINV."DocTotal" - OINV."VatSum") *0.01) FROM OINV WHERE OINV."DocNum" = '1250002' ) < 29 AND :DOC_BASE = 'NO' THEN 'TRUE'
ELSE 'FALSE'
END
FROM DUMMY;
END;
ELSE
BEGIN
IF :TIPODOC = 'Ent' THEN
BEGIN
IF '-1' = '17' THEN
BEGIN
STATUS := IFNULL((SELECT "WddStatus" FROM ORDR WHERE "DocNum" = ''),'Z');
IF :STATUS = 'P' THEN
BEGIN
IF ((SELECT (IFNULL("DocTotal",0) - IFNULL("PaidToDate",0)) FROM ORDR WHERE "DocNum" = '') - 23800.000000) >= 0 THEN
BEGIN
DOC_BASE := 'SI';
END;
END IF;
END;
END IF;
END;
END IF;
SELECT CASE
WHEN (SELECT ODLN."GrosProfit"/ ((ODLN."DocTotal" - ODLN."VatSum") *0.01) FROM ODLN WHERE ODLN."DocNum" = '1250002' ) < 29 AND :DOC_BASE = 'NO' THEN 'TRUE'
ELSE 'FALSE'
END
FROM DUMMY;
END;
ELSE
BEGIN
SELECT CASE
WHEN ( SELECT $[ORDR."GrosProfit"] / (($[ORDR."DocTotal"] - $[ORDR."VatSum"])* 0.01) FROM DUMMY) < 29 AND :DOC_BASE = 'NO' THEN 'TRUE'
ELSE 'FALSE'
END
FROM DUMMY;`
END;
END IF;
END;
END IF;
Esta es la parte especifica qeu cusa el error
SELECT CASE
WHEN ( SELECT $[ORDR."GrosProfit"] / (($[ORDR."DocTotal"] - $[ORDR."VatSum"])* 0.01) FROM DUMMY) < 29 AND :DOC_BASE = 'NO' THEN 'TRUE'
ELSE 'FALSE'
END
FROM DUMMY;`
Necesito ayuda por favor