470,614 Members | 1,396 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

How can the sequence become out of sequence?


I wonder how this can happen.
A "not null" field is set to "" even if a sequence should set this
to next sequence number.

Ok, I know it is not set to null, it is set to '' which is proven by
the below
Select statement but it is not set to the next sequence number and the
does not specify any value in the insert statement for the id-column.

Are there any reasons for this behaviour?

/ Axier

CREATE TABLE public.mytable (
id int4 DEFAULT nextval('mytable_seq'::text) NOT NULL,
srcid int4,
name varchar(50),
date date,
"time" time,
week int4,
CONSTRAINT mytable_idx UNIQUE (name, date),
CONSTRAINT mytable_pkey PRIMARY KEY (id)
2147483647 CACHE 1;
SELECT setval('public.mytable_seq', 39903);
mydatabase=# select * from mytable where length(name)<1;
id | srcid | name | date | time | week |
| 12 | |2004-01-21 | 09:39:00 | 4 |
(1 rad)

mydatabase=# delete from mytable where length(name)<1;

mydatabase=# select * from mytable where id is null;
id | srcid | name | date | time | week |
(0 rows)

Here is the executed Insert-SQL.

INSERT INTO mytable ( srcid, name, date, time, week )
VALUES( $srcid, '$name', '$date', '$time', DATE_PART('week',
Jul 19 '05 #1
1 1882

at a guess try qualifying sequence name

id int4 DEFAULT nextval('public.mytable_seq'::text) NOT NULL

Posted via http://www.webservertalk.co
View this thread: http://www.webservertalk.com/message93627.htm

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Honne Gowda A | last post: by
reply views Thread by Steven Bethard | last post: by
6 posts views Thread by Randy Harris | last post: by
4 posts views Thread by j | last post: by
4 posts views Thread by bboyle18 | last post: by
17 posts views Thread by pedestrian via DotNetMonster.com | last post: by
2 posts views Thread by jaka | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.