Return and sql tuple descriptions are incompatible - Mailing list pgsql-general

From Hengky Liwandouw
Subject Return and sql tuple descriptions are incompatible
Date
Msg-id 006601cf5fcd$da992e00$8fcb8a00$@com
Whole thread Raw
Responses Re: Return and sql tuple descriptions are incompatible  (David G Johnston <david.g.johnston@gmail.com>)
List pgsql-general

Hi,

 

I have the following crosstab command :

 

Select * from crosstab($$select produkid, warehouseid,onhand from vwtest order by 1,2$$)

as t (produkid VARCHAR, warehouseid integer)

 

vwtest :

 

CREATE OR REPLACE VIEW public.vwtest (

    produkid,

    warehouseid,

    onhand)

AS

SELECT dt.produkid,

    dt.warehouseid,

    sum(dt.awal + dt.ttlmsk - dt.ttlklr) AS onhand

FROM (

    SELECT tblstockawal.kodebarang AS produkid,

                    tblstockawal.warehouseid,

                    sum(tblstockawal.qty) AS awal,

                    0 AS ttlmsk,

                    0 AS ttlklr

    FROM tblstockawal

    GROUP BY tblstockawal.kodebarang, tblstockawal.warehouseid

    UNION

    SELECT tbltransaksi.kodebarang AS produkid,

                    tbltransaksi.warehouseid,

                    0 AS awal,

                    sum(tbltransaksi.masuk) AS ttlmsk,

                    sum(tbltransaksi.keluar) AS ttlklr

    FROM tbltransaksi

    GROUP BY tbltransaksi.kodebarang, tbltransaksi.warehouseid

    ) dt

GROUP BY dt.produkid, dt.warehouseid;

 

The crosstab command didn’t work with error : Return and sql tuple descriptions are incompatible.

 

I have tried to change productid type to text and warehouseid to float8 and the problem still not solve.

 

What is wrong with the command ?

 

Thanks

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Request for Unsubscribe
Next
From: "Gunnar \"Nick\" Bluth"
Date:
Subject: Re: Patched odbc_dfw for PG >= 9.2 - compiles & works but has issues with NULL representation in ODBC?!?