Re: Function for retreiving datatype

From: Brendan Jurd <blakjak(at)blakjak(dot)sytes(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Function for retreiving datatype
Date: 2005-01-10 18:26:59
Message-ID: 41E2C8F3.7090504@blakjak.sytes.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Michael Fuhr wrote:

>On Tue, Jan 11, 2005 at 03:28:08AM +1100, Brendan Jurd wrote:
>
>
>
>>Does postgres have a function to determine the data type of an
>>argument?
>>
>>
>
>In what context? What problem are you trying to solve?
>
>
>
Well, I solved the original problem in a different way, but I'd still
like to know whether such a function exists.

The original problem had to do with querying a row-returning function.
I had an SQL function that returned "SETOF record", and I was trying to
use it in the FROM clause of a query. To do so, you need to provide a
list of column definitions. I was getting the error about the returned
row types not matching my column defs. In the end it was a simple
mistake -- I had specified 'text' where I should have specified
'varchar'. I had thought to use some kind of "gettype" function to find
out exactly what data types my query was returning.

On that note, it might be helpful to increase the verbosity of the
"returned row types" error message, so that it actually explains the
mismatch it encountered. Something like "Returned column 3 is
varchar(15) but column definition is text" would have made debugging a
whole lot easier.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Derik Barclay 2005-01-10 18:46:22 Re: SELECT from multiple tables (not join though)
Previous Message Bruno Wolff III 2005-01-10 18:26:08 Re: SELECT from multiple tables (not join though)