Subject Re: [firebird-support] Re: How to multiply value with value from other table
Author Helen Borrie
At 11:45 AM 9/05/2005 +0000, Zoran Zivkovic wrote:
>Helen,
>
> I need some more help. I am receiving folowing error:
>
>Invalid token.
>invalid request BLR at offset 186.
>context already in use (BLR error).
>
>when i try to execute folowing query:
>
>SELECT DISTINCT PARTNO
> , EAPARTNO
> , FILTER_TYPE
> , COMMENT
> , CAST ((CENOVNIK.SP*(SELECT KP1.KURS from KURS_POREZ KP1)*
>(SELECT 1+(KP2.POREZ/100) FROM KURS_POREZ KP2) /1.00) AS DECIMAL
>(15,2)) AS MPC
>FROM FILTER_PARTS
>JOIN CENOVNIK ON (FILTER_PARTS.EAPARTNO=CENOVNIK.EAPARTNO)
>
>Structure of table FILTER_PARTS is
>
>CREATE TABLE FILTER_PARTS (
> APPL_ID INTEGER NOT NULL,
> PARTNO VARCHAR(10) NOT NULL,
> EAPARTNO VARCHAR(11) NOT NULL,
> FILTER_TYPE VARCHAR(16),
> COMMENT VARCHAR(19),
> DETAIL_SEQ INTEGER
>);
>
>Can you please advice what this could be ???

Take out the DISTINCT and fix up your table identifiers (see my original
suggestion.)


> > SELECT
> > wpp.PARTNO
> > , wpp.EAPARTNO
> > , wpp.DESCRIPTION
> > , wpp.PART_OE AS OE /* why? */
> > , CAST ((c.SP * kp.KURS * kp.POREZ/1.00) AS DECIMAL(15,2))
>AS MPC
> >
> > CAST ((c.SP * (select kp1.KURS from KURS_POREZ kp1)
> > * (SELECT kp2.POREZ from KURS_POREZ kp2) /1.00) AS DECIMAL
>(15,2)) AS MPC
> > FROM WATER_PUMPS_PARTS wpp
> > LEFT JOIN CENOVNIK c
> > ON wpp.EAPARTNO=c.EAPARTNO
> >
> >
> > More elegant and speedy would be a selectable stored proc that
>reads the
> > KURS_POREZ record only once, into variables.
> >
> > ./hb