Subject I create View in FB 2.5 but does not work in FB 1.5
Author Israel Pinheiro
Create a view FB 2.5 but does not create in FB 1.5



Message error ==> Line 201 | Invalid Token. Dynamic SQL Error code = -104.
Invalid command. Data Type unknown





<code>

CREATE VIEW ESPELHO(

DTMOVPROD,

TIPOMOV,

CODNAT,

CODVENDA,

CODCOMPRA,

CODPROD,

DESCPROD,

CODFISC,

TIPOMOVPROD,

DOCMOVPROD,

CODALMOX,

CODLOTE,

QTDMOVPROD,

PRECOMOVPROD,

ESTOQMOVPROD,

SLDMOVPRODAX,

TIPOPROD,

CUSTOMPMMOVPRODAX,

SLDMOVPROD,

ESTOQUE,

CUSTOMPMMOVPROD,

CODMOVPROD,

CODEMPTM,

CODEMP,

CODFILIALTM,

CODFILIAL,

CODTIPOMOV,

SALDO,

CUSTOMPMPROD,

PRECOITVENDA,

SLDPROD)

AS

SELECT

MP.DTMOVPROD,

TM.TIPOMOV,

MP.CODNAT,

MP.CODVENDA,

MP.CODCOMPRA,

MP.CODPROD,

EQ.DESCPROD,

EQ.CODFISC,

MP.TIPOMOVPROD,

MP.DOCMOVPROD,

MP.CODALMOX,

MP.CODLOTE,

MP.QTDMOVPROD,

MP.PRECOMOVPROD,

MP.ESTOQMOVPROD,

MP.SLDMOVPRODAX,

EQ.TIPOPROD,

MP.CUSTOMPMMOVPRODAX,

MP.SLDMOVPROD,

CAST(MP.SLDMOVPROD AS NUMERIC(15, 2)) AS ESTOQUE,

MP.CUSTOMPMMOVPROD,

MP.CODMOVPROD,

MP.CODEMPTM,

TM.CODEMP,

MP.CODFILIALTM,

TM.CODFILIAL,

cast(CLI.NOMECLI as char(60)) AS CODTIPOMOV,

CAST((MP.SLDMOVPROD * MP.CUSTOMPMMOVPROD) AS NUMERIC(15, 2)) AS SALDO,

EQ.CUSTOMPMPROD,

sum(VDITVENDA.PRECOITVENDA) AS PRECOITVENDA,

ES.SLDPROD

FROM

EQMOVPROD MP

INNER JOIN EQPRODUTO EQ ON (MP.CODPROD = EQ.CODPROD)

INNER JOIN VDVENDA VD ON (MP.CODVENDA = VD.CODVENDA)

INNER JOIN VDCLIENTE CLI ON (VD.CODCLI = CLI.CODCLI)

INNER JOIN VDITVENDA ON (VD.CODEMP = VDITVENDA.CODEMP)

AND (VD.CODFILIAL = VDITVENDA.CODFILIAL)

AND (VD.TIPOVENDA = VDITVENDA.TIPOVENDA)

AND (VD.CODVENDA = VDITVENDA.CODVENDA)

AND (VDITVENDA.CODEMPPD = EQ.CODEMP)

AND (VDITVENDA.CODFILIALPD = EQ.CODFILIAL)

AND (VDITVENDA.CODPROD = EQ.CODPROD)

INNER JOIN EQSALDOPROD ES ON (EQ.CODEMP = ES.CODEMP)

AND (EQ.CODFILIAL = ES.CODFILIAL)

AND (EQ.CODPROD = ES.CODPROD),

EQTIPOMOV TM

WHERE

MP.CODEMPTM = TM.CODEMP AND

MP.CODFILIALTM = TM.CODFILIAL AND

MP.CODTIPOMOV = TM.CODTIPOMOV AND

TIPOPROD = 'P' AND

MP.CODCOMPRA IS NULL

GROUP BY

MP.DTMOVPROD,

TM.TIPOMOV,

MP.CODNAT,

MP.CODVENDA,

MP.CODCOMPRA,

MP.CODPROD,

EQ.DESCPROD,

EQ.CODFISC,

MP.TIPOMOVPROD,

MP.DOCMOVPROD,

MP.CODALMOX,

MP.CODLOTE,

MP.QTDMOVPROD,

MP.PRECOMOVPROD,

MP.ESTOQMOVPROD,

MP.SLDMOVPRODAX,

EQ.TIPOPROD,

MP.CUSTOMPMMOVPRODAX,

MP.SLDMOVPROD,

MP.CUSTOMPMMOVPROD,

MP.CODMOVPROD,

MP.CODEMPTM,

TM.CODEMP,

MP.CODFILIALTM,

TM.CODFILIAL,

CLI.NOMECLI,

EQ.CUSTOMPMPROD,

ES.SLDPROD



UNION ALL



SELECT

MP.DTMOVPROD,

TM.TIPOMOV,

MP.CODNAT,

MP.CODVENDA,

MP.CODCOMPRA,

MP.CODPROD,

EQ.DESCPROD,

EQ.CODFISC,

MP.TIPOMOVPROD,

MP.DOCMOVPROD,

MP.CODALMOX,

MP.CODLOTE,

MP.QTDMOVPROD,

MP.PRECOMOVPROD,

MP.ESTOQMOVPROD,

MP.SLDMOVPRODAX,

EQ.TIPOPROD,

MP.CUSTOMPMMOVPRODAX,

MP.SLDMOVPROD,

CAST(MP.SLDMOVPROD AS NUMERIC(15, 2)) AS ESTOQUE,

MP.CUSTOMPMMOVPROD,

MP.CODMOVPROD,

MP.CODEMPTM,

TM.CODEMP,

MP.CODFILIALTM,

TM.CODFILIAL,

CAST((MP.SLDMOVPROD * MP.CUSTOMPMMOVPROD) AS NUMERIC(15, 2)) AS SALDO,

FORN.RAZFOR AS CODTIPOMOV,

EQ.CUSTOMPMPROD,

ES.SLDPROD,

sum(CPITCOMPRA.PRECOITCOMPRA) AS PRECOITCOMPRA

FROM

EQMOVPROD MP

INNER JOIN EQPRODUTO EQ ON (MP.CODPROD = EQ.CODPROD)

INNER JOIN CPCOMPRA CP ON (MP.CODCOMPRA = CP.CODCOMPRA)

INNER JOIN CPFORNECED FORN ON (CP.CODFOR = FORN.CODFOR)

INNER JOIN CPITCOMPRA ON (CP.CODEMP = CPITCOMPRA.CODEMP)

AND (CP.CODFILIAL = CPITCOMPRA.CODFILIAL)

AND (CP.CODCOMPRA = CPITCOMPRA.CODCOMPRA)

AND (CPITCOMPRA.CODEMPPD = EQ.CODEMP)

AND (CPITCOMPRA.CODFILIALPD = EQ.CODFILIAL)

AND (CPITCOMPRA.CODPROD = EQ.CODPROD)

INNER JOIN EQSALDOPROD ES ON (EQ.CODEMP = ES.CODEMP)

AND (EQ.CODFILIAL = ES.CODFILIAL)

AND (EQ.CODPROD = ES.CODPROD),

EQTIPOMOV TM

WHERE

MP.CODEMPTM = TM.CODEMP AND

MP.CODFILIALTM = TM.CODFILIAL AND

MP.CODTIPOMOV = TM.CODTIPOMOV AND

TIPOPROD = 'P' AND

MP.CODVENDA IS NULL

GROUP BY

MP.DTMOVPROD,

TM.TIPOMOV,

MP.CODNAT,

MP.CODVENDA,

MP.CODCOMPRA,

MP.CODPROD,

EQ.DESCPROD,

EQ.CODFISC,

MP.TIPOMOVPROD,

MP.DOCMOVPROD,

MP.CODALMOX,

MP.CODLOTE,

MP.QTDMOVPROD,

MP.PRECOMOVPROD,

MP.ESTOQMOVPROD,

MP.SLDMOVPRODAX,

EQ.TIPOPROD,

MP.CUSTOMPMMOVPRODAX,

MP.SLDMOVPROD,

MP.CUSTOMPMMOVPROD,

MP.CODMOVPROD,

MP.CODEMPTM,

TM.CODEMP,

MP.CODFILIALTM,

TM.CODFILIAL,

FORN.RAZFOR,

EQ.CUSTOMPMPROD,

ES.SLDPROD;



</code>



---
Este email foi escaneado pelo Avast antivĂ­rus.
https://www.avast.com/antivirus


[Non-text portions of this message have been removed]