Re: ERROR: return and sql tuple descriptions are incompatible

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: M Sarwar <sarwarmd02(at)outlook(dot)com>
Cc: "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: ERROR: return and sql tuple descriptions are incompatible
Date: 2024-05-05 00:56:21
Message-ID: 7kadkskdcixknub2dvc4ovm24q5thdptxj2opu42pninbadonm@h5opztcvzcrh
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 2024-05-05 02:38 +0200, M Sarwar wrote:
> TEST1P1 data is coming from the category column, TESTC.TEST_NUMBER.
> TRESULT.TEST_RESULT column is giving value data.

Column TESTC.TEST_NUMBER (i.e. the second column) is ignored by crosstab
and it only requires the use of ORDER BY 1,2 to get correct results.
Output columns TEST1P1 and TEST_RESULT are two of the many value columns
which are only filled by the third result column.

I now remember it's the same issue from your very first crosstab mail:

https://www.postgresql.org/message-id/q2cdz27dkwel73k27ckt2i6g6ce55wzodaogbgfnoqccupqndx%40vz3cnoihz4j5

> As I stated in my first email which has results of
> '\d bronx.TEST_RESULTS_ALL_MCM_INIt' and
> '\d bronx.TEST_TEST_DETAILS_ALL_MCM_INIT', columns TESTC.TEST_NUMBER
> and TRESULT.TEST_RESULT data types are numeric and character(10) .
> This is as per table definitions.
>
> Are you suggesting me to use the type either TEXT or some other data
> type in the below clause of the SQL.

I'd say use numeric for TEST1P1 and TEST_RESULT. But the column names
and types suggest that you expect the second result column in the
crosstab output. Which isn't possible to my knowledge.

--
Erik

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Edwin UY 2024-05-05 03:07:38 Foreign tables - oracle_fdw
Previous Message Scott Ribe 2024-05-05 00:52:56 Re: ERROR: return and sql tuple descriptions are incompatible