pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: Finding Max Value in a Row
Date: Fri, 11 May 2012 22:00:52 +0200
Message-ID: <jojr3q$uof$1@dough.gmane.org> (raw)
In-Reply-To: <CAAQLLO5x8_kxpM8epdqjh7UPG7tTX8i0w04fODZd1F+8bKdr0A@mail.gmail.com>
References: <CAAQLLO6EhUi0OUi38BiH+qmgKqY+mY27_hGBQJiC5rbWorXQbw@mail.gmail.com>
	<00ee01cd2fab$1b528b80$51f7a280$@yahoo.com>
	<CAAQLLO7-O26xpisutPoud__iDaco6WtZCr6CBG5OgiwpgvWd6g@mail.gmail.com>
	<jojq4e$ogj$1@dough.gmane.org>
	<CAAQLLO5x8_kxpM8epdqjh7UPG7tTX8i0w04fODZd1F+8bKdr0A@mail.gmail.com>

Carlos Mennens wrote on 11.05.2012 21:50:
> On Fri, May 11, 2012 at 3:44 PM, Thomas Kellerer<spam_eater@gmx.net>  wrote:
>> Use this:
>>
>> alter table users
>>     alter column users_id type integer using to_number(users_id, '99999');
>>
>> (Adjust the '99999' to the length of the char column)
>
> When you wrote "Adjust the '99999' to the length of the char column,
> do you mean change '99999' to '312' if my last used maximum value was
> 312? So the next sequence primary key value would be '313', right?
>
No, the number of 9's defined the number of digits in the numbers.
There must not be less 9's in the format mask than the number of digits in the highest value.

The above example would create wrong values if the highest "number" was 100000

Check the manual about details on the format mask for to_number()







view thread (18+ messages)  latest in thread

Message-ID: <jojr3q$uof$1@dough.gmane.org>
Permalink:  ../jojr3q$uof$1@dough.gmane.org/
Also on:    postgresql.org/message-id/jojr3q$uof$1@dough.gmane.org

 · 

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: spam_eater@gmx.net
  Subject: Re: Finding Max Value in a Row
  In-Reply-To: <jojr3q$uof$1@dough.gmane.org>

* 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