Re: [GENERAL] Function for retreiving datatype

2005-01-14 Thread Sim Zacks
Brendan, I have had similar problems and the way I resolve it is by running the SQL statement directly in PGAdmin and in the resultset it tells you what the field types are. For example. create or replace function test1(vara int, varb int) returns setof record as $$ declare row record; begin

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Joe Conway
Michael Fuhr wrote: On Tue, Jan 11, 2005 at 11:00:15AM +1100, Brendan Jurd wrote: Your coltype() function is exactly what I'm looking for. I'd envisaged something that takes an anyelement argument and returns the type as text, but returning the OID is even better. [...snip slick function...] Now

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Michael Fuhr
On Tue, Jan 11, 2005 at 11:00:15AM +1100, Brendan Jurd wrote: > Your coltype() function is exactly what I'm looking for. I'd envisaged > something that takes an anyelement argument and returns the type as > text, but returning the OID is even better. > > Can you please provide the source for t

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Brendan Jurd
Michael Fuhr wrote: On Tue, Jan 11, 2005 at 09:31:26AM +1100, Brendan Jurd wrote: Actually I'm looking for an internal function -- something within postgres' implementation of SQL itself, which I can use in queries independent of the front-end language. The same way you use functions like to

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Michael Fuhr
On Tue, Jan 11, 2005 at 09:31:26AM +1100, Brendan Jurd wrote: > Actually I'm looking for an internal function -- something within > postgres' implementation of SQL itself, which I can use in queries > independent of the front-end language. The same way you use functions > like to_char() or now

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Brendan Jurd
Michael Fuhr wrote: On Tue, Jan 11, 2005 at 08:29:33AM +1100, Brendan Jurd wrote: My post was all about finding out whether postgres has this functionality. Certainly PostgreSQL provides a way to discover a row's column types, but how to do it depends on where you're trying to do it from.

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Michael Fuhr
On Tue, Jan 11, 2005 at 08:29:33AM +1100, Brendan Jurd wrote: > My post was all about finding out whether postgres has this > functionality. Certainly PostgreSQL provides a way to discover a row's column types, but how to do it depends on where you're trying to do it from. If you're writing a cl

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Brendan Jurd
Michael Fuhr wrote: On Tue, Jan 11, 2005 at 05:26:59AM +1100, Brendan Jurd wrote: 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

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Brendan Jurd
Pierre-Frédéric Caillaud wrote: Example : psql create table test (id serial primary key, data10 varchar(10), data20 varchar(20), data text ); insert into test (data10, data20, data) values ('ten','twenty','all i want'); python I know that these kinds of functions are available from other la

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Brendan Jurd
Michael Fuhr wrote: On Tue, Jan 11, 2005 at 05:26:59AM +1100, Brendan Jurd wrote: 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

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Pierre-Frédéric Caillaud
Example : psql create table test (id serial primary key, data10 varchar(10), data20 varchar(20), data text ); insert into test (data10, data20, data) values ('ten','twenty','all i want'); python import psycopg db = psycopg.connect("host=localhost dbname=.") c = db.cursor() c.execute( "SELE

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Michael Fuhr
On Tue, Jan 11, 2005 at 05:26:59AM +1100, Brendan Jurd wrote: > > 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 colu

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Brendan Jurd
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 t

Re: [GENERAL] Function for retreiving datatype

2005-01-10 Thread Michael Fuhr
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? -- Michael Fuhr http://www.fuhr.org/~mfuhr/ ---(end of broadcast)-