Re: one more word about rules

From: John McKown <joarmc(at)swbell(dot)net>
To: Abe Asghar <abe(at)fish(dot)tm>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: one more word about rules
Date: 2000-09-22 15:11:40
Message-ID: Pine.LNX.4.21.0009221006180.10586-100000@linux2.johnmckown.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Abe,
How do you generate your article number? If you are using a SERIAL, then
you could change it to use a specific SEQUENCE and step the SEQUENCE by
some value other than one. Something like:

CREATE SEQUENCE article_sequence INCREMENT 100 MINVALUE 1 START 101;

CREATE TABLE article (
article_number int4 default nextval('article_sequence')
);

That would automatically generate article numbers 101, 201, 301, ...
thus leaving room for "inserted" articles.

On Fri, 22 Sep 2000, Abe Asghar wrote:

> Hi everyone,
>
> I have built a database that uses int4 as the unique identifier for a news
> database.
>
> Therefore an article has a identifier 1, the next one has 2 etc.
>
> Then I order them when they are displayed on the web reversely so that the
> last article added is at the top of the list.
>
> I now face a major problem. If we need to back dackdate an article - I
> can't. This is because the all the indexes are taken up ie 1, 2, 3......75
> odd records. If I want to add one between 50 and 51 ie 50.5, I cannot
> because the field is an int4.
>
> One idea I had to get around this was to create a new table with this column
> as a float and read and write all therecords in with a PHP script.
>
> Is there an easier way such as converting the column data type from a int4
> to a float.
>
> Thanks in advance.
> Abe.
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Charles Sigler 2000-09-22 15:24:26 Why does IE5 give me a "No suitable driver" error?
Previous Message Tom Lane 2000-09-22 14:54:43 Re: Re: Large Objects