Re: Function for retreiving datatype - Mailing list pgsql-general

From Brendan Jurd
Subject Re: Function for retreiving datatype
Date
Msg-id 41E2C8F3.7090504@blakjak.sytes.net
Whole thread Raw
In response to Re: Function for retreiving datatype  (Michael Fuhr <mike@fuhr.org>)
Responses Re: Function for retreiving datatype
Re: Function for retreiving datatype
List 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.


pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: SELECT from multiple tables (not join though)
Next
From: Madison Kelly
Date:
Subject: Re: SELECT from multiple tables (not join though)