On 28/12/12 05:44, John Fabiani wrote:
On 12/27/2012 08:21 AM, Gavin Flower wrote:
On 28/12/12 03:27, John Fabiani wrote:
Hi,
I have the following statement in a function.
UPDATE orderseq
SET orderseq_number = (orderseq_number + 1)
WHERE (orderseq_name='InvcNumber');
All it does is update a single record by incrementing a value (int).
But it never completes. This has to be some sort of bug. Anyone
have a thought what would cause this to occur. To my knowledge it
was working and does work in other databases.
Johnf
It might help if you give the table definition.
Definitely important: is the exact version of PostgreSQL used, and
the operating system.
Cheers,
Gavin
9.1.6 updated 12.22.2012, openSUSE 12.1 64 bit Linux
CREATE TABLE orderseq
(
orderseq_id integer NOT NULL DEFAULT
nextval(('orderseq_orderseq_id_seq'::text)::regclass),
orderseq_name text,
orderseq_number integer,
orderseq_table text,
orderseq_numcol text,
CONSTRAINT orderseq_pkey PRIMARY KEY (orderseq_id )
)
WITH (
OIDS=FALSE
);
ALTER TABLE orderseq
OWNER TO admin;
GRANT ALL ON TABLE orderseq TO admin;
GRANT ALL ON TABLE orderseq TO xtrole;
COMMENT ON TABLE orderseq
IS 'Configuration information for common numbering sequences';
Johnf
I had a vague idea what the problem might be, but your table definition
proved I was wrong! :-)
This won't sole your problem, but I was wondering why you don't use a
simpler definition like:
CREATE TABLE orderseq
(
orderseq_id SERIAL PRIMARY KEY,
orderseq_name text,
orderseq_number integer,
orderseq_table text,
orderseq_numcol text
);
SERIAL automatically attaches the table's own sequence and does a
DEFAULT nextval
PRIMARY KEY implies NOT NULL & UNIQUE
OIDS=FALSE is the default
My personal preference is just to use the name 'id' for the tables own
primary key, and only prepend the table name when it is foreign key -
makes them stand out more.
Cheers,
Gavin