Updating of serial ID fields

From: Lan Barnes <lan(at)falleagle(dot)net>
To: Postgres Newbie <pgsql-novice(at)postgresql(dot)org>
Subject: Updating of serial ID fields
Date: 2006-07-19 20:46:13
Message-ID: 20060719204613.GA24974@falleagle.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have defined several tables with a field names "id" that is type
serial-not null-primary index. Here is a partial dump:

CREATE TABLE builds (
id serial NOT NULL,
dev_label character varying(25),
build_label character varying(25),
build_category character varying(15),
sw_delta_build text,
request_date date,
delivery_date date,
scm_remarks text,
requester character varying(25),
build_reason text,
build_number character varying(5),
code_line character varying(25),
unit_test_results text,
change_lists_submitted text,
lines_of_code character varying(8),
build_logs text,
special_instructions text,
build_status character varying(10),
scm_builder character varying(15)
);

The field in question is the first field.

I have written front ends in Tcl/Tk (using pgtcl) to, among other
things, insert records. Originally, I added logic to get the last value
on this field, increment it, and then insert the new value. However, I
noticed that this happened whether or not I added the logic, so I
stopped doing that.

Now after several iterations, I find that this is no longer happening.
Also, even though the dumps still list these fields as serial, pgaccess
now says they're int4.

I have done several schema saves, db drops, and schema restores. Did I
lose something?

I figured these fields were getting updated as automatic triggers. I
need them to stay consistent for internal integrity. How do I best do
this?

TIA,

--
Lan Barnes
Linux Guy, SCM Specialist
Tcl/Tk Enthusiast

No matter how good you feel, if four friends tell you you're drunk,
you'd better lie down.
- Theodore Sorensen

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Richard Broersma Jr 2006-07-19 21:38:25 Re: Updating of serial ID fields
Previous Message Gregory Amato 2006-07-19 18:40:51 Installation error