pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hélder M. Vieira <hmv@mail.telepac.pt>
To: pgsql-sql@postgresql.org
Subject: max() unexpected type conversion
Date: Mon, 21 Nov 2005 12:47:40 -0000
Message-ID: <000901c5ee99$c275e380$580bfea9@hmv02> (raw)

Hello.

I'm having some trouble with an unexpected conversion performed by the max() 
function.
If max() operates on a 'varchar' type column, the result appears with 'text' 
type.
Should I expect this behaviour in the current and later versions ?

I mention this because I'm using ODBC in VB, and this type conversion has a 
bad outcome, because 'text' columns require a specific treatment (a second 
reading of the column contents returns null). Therefore, if this conversion 
is beeing made as a result of a design option, I'll have to use a different 
approach (something like 'select ... order by ... desc limit 1').

A small sample follows, giving a 'text' type result:


create table test
(
  testcol varchar(4) not null
);

insert into test (testcol) values ('A');
insert into test (testcol) values ('A');
insert into test (testcol) values ('B');
insert into test (testcol) values ('B');
insert into test (testcol) values ('C');
insert into test (testcol) values ('C');

select max(testcol) from test;



Thank you

Hélder M. Vieira





view thread (3+ messages)  latest in thread

Message-ID: <000901c5ee99$c275e380$580bfea9@hmv02>
Permalink:  ../000901c5ee99$c275e380$580bfea9@hmv02/
Also on:    postgresql.org/message-id/000901c5ee99$c275e380$580bfea9@hmv02

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: hmv@mail.telepac.pt
  Subject: Re: max() unexpected type conversion
  In-Reply-To: <000901c5ee99$c275e380$580bfea9@hmv02>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox