Subject Re: RES: RES: [firebird-support] It works on FB 2.5 but does not work in FB 1.5
Author setysvar
>does not work.
error remains...

I can understand that you still get an error, but are you sure the error message is identical when changing from CREATE OR ALTER VIEW to CREATE VIEW?

The below statement should be legal in Firebird 1.5, of course I'm assuming all fields have appropriate and compatible types (most importantly: CLI.NOMECLI and FORN.RAZFOR), and that TIPOPROD is a field only existing in EQ. Also, the view should of course not exist before you create it (as I wrote previously CREATE OR ALTER VIEW did not exist in Firebird 1.5).

CREATE VIEW ESPELHO(DTMOVPROD,  TIPOMOV,  CODNAT,     CODVENDA,     CODCOMPRA,    CODPROD,      DESCPROD, CODFISC,           TIPOMOVPROD, DOCMOVPROD,
                    CODALMOX,   CODLOTE,  QTDMOVPROD, PRECOMOVPROD, ESTOQMOVPROD, SLDMOVPRODAX, TIPOPROD, CUSTOMPMMOVPRODAX, SLDMOVPROD,  CUSTOMPMMOVPROD,
                    CODMOVPROD, CODEMPTM, CODEMP,     CODFILIALTM,  CODFILIAL,    SALDO,        NOME)
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,   MP.CUSTOMPMMOVPROD,
       MP.CODMOVPROD,   MP.CODEMPTM, TM.CODEMP,            MP.CODFILIALTM,  TM.CODFILIAL,
       (MP.sldmovprod*MP.CUSTOMPMMOVPROD), CLI.NOMECLI
FROM EQMOVPROD MP
inner join EQTIPOMOV TM on MP.CODEMPTM=TM.CODEMP
                       and MP.CODFILIALTM=TM.CODFILIAL
                       and MP.CODTIPOMOV=TM.CODTIPOMOV
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
where eq.tipoprod='P' and mp.codcompra is null
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,   MP.CUSTOMPMMOVPROD,
       MP.CODMOVPROD,   MP.CODEMPTM, TM.CODEMP,            MP.CODFILIALTM,  TM.CODFILIAL,
       (MP.sldmovprod*MP.CUSTOMPMMOVPROD), FORN.RAZFOR
FROM EQMOVPROD MP
inner join  EQTIPOMOV TM on MP.CODEMPTM=TM.CODEMP
                        and MP.CODFILIALTM=TM.CODFILIAL
                        and MP.CODTIPOMOV=TM.CODTIPOMOV
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
where eq.tipoprod='P' and mp.codvenda is null;

HTH,
Set
Den 23.06.2016 22:58, skrev 'Israel Pinheiro' israel.ipnet@... [firebird-support]:

does not work. error remains...

De: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com]
Enviada em: quinta-feira, 23 de junho de 2016 17:45
Para: firebird-support@yahoogroups.com
Assunto: Re: RES: [firebird-support] It works on FB 2.5 but does not work in FB 1.5

>CREATE OR ALTER VIEW ESPELHO(
...
>Error Message is:
>Invalid Token. Dynamic SQL Error code = -104. Invalid Command. Data
Type unknown

CREATE OR ALTER VIEW was new in Firebird 2.5. I don't even think ALTER
VIEW existed in Firebird 1.5, but CREATE VIEW should exist.

>FROM EQMOVPROD MP, EQTIPOMOV TM
>INNER JOIN EQPRODUTO eq on mp.codprod = eq.codprod

Mixing SQL-89 and SQL-92 like you do above is not recommended (although
it is legal) in any version. Rather, change this to SQL-92 only, e.g.
like this:

FROM EQMOVPROD MP
INNER JOIN EQTIPOMOV TM on MP.CODEMPTM=TM.CODEMP
and MP.CODFILIALTM=TM.CODFILIAL
and MP.CODTIPOMOV=TM.CODTIPOMOV
INNER JOIN EQPRODUTO eq on mp.codprod = eq.codprod

HTH,
Set