Re: [SQL] Serial not nulla

2008-02-11 Thread Shavonne Marietta Wijesinghe
; <[EMAIL PROTECTED]> Cc: Sent: Friday, February 08, 2008 2:17 PM Subject: Re: [SQL] Serial not nulla Shavonne Marietta Wijesinghe wrote: Hello I am working with a database that has a Index number defined as Serial NOT NULL I used this because, 1. I want to make sure that when many users log

Re: [SQL] Serial not nulla

2008-02-08 Thread Shane Ambler
Shavonne Marietta Wijesinghe wrote: Hello I am working with a database that has a Index number defined as Serial NOT NULL I used this because, 1. I want to make sure that when many users login at the same time the Index number won't be repeated. 2. I don't have to increment it by programming (

[SQL] Serial not nulla

2008-02-08 Thread Shavonne Marietta Wijesinghe
Hello I am working with a database that has a Index number defined as Serial NOT NULL I used this because, 1. I want to make sure that when many users login at the same time the Index number won't be repeated. 2. I don't have to increment it by programming (I use ASP) But now i have a situation

Re: [SQL] SERIAL type's sequence is double-called or ?

2007-09-07 Thread Richard Huxton
Aleksandr Vinokurov wrote: Logging will be done with this rule: create or replace rule chuwee_rule as on insert to chuwee do insert into chuwee_log (num, mesg) values (new.num, new.mesg); Don't do logging with rules, do logging with triggers. See mailing-list archives for details. -- R

[SQL] SERIAL type's sequence is double-called or ?

2007-09-07 Thread Aleksandr Vinokurov
Hello all, I have a question with the SERIAL type. I want to use it for default identification of table entries: create table chuwee ( num serial primary key, mesg varchar(50) not null ); And all the inserts to this table I'm gonna log to this table: create table chuwee_log ( id seri

Re: [SQL] Serial number of a record

2007-05-15 Thread Andrew Sullivan
On Tue, May 15, 2007 at 07:40:25AM -0400, [EMAIL PROTECTED] wrote: > Suppose if i will fire a query "select Name from tablename where age=30". > it will give output "shyam" but i also want record no. other then oid, in > this case it is 3. > > is it possible? > if yes then how? > plz. help me. Th

[SQL] Serial number of a record

2007-05-15 Thread [EMAIL PROTECTED]
Hi List, I have one table something like this Name Age = tom 20 ram 25 shyam 30 balram15 hari 10 Now i want serial number of a record. Suppose if i will fire a query "select Name from tablename where age=30". it will give outp

Re: [SQL] Serial

2007-04-03 Thread Richard Broersma Jr
--- > Yes there is, and you generally shouldn't do it. There are issues with > race conditions and misreferenced data that can happen when you try to > reuse sequence numbers. > > Sadly, some poorly defined business processes require this. > > Are you required to have sequential numbers, or is

Re: [SQL] Serial

2007-04-03 Thread Scott Marlowe
On Tue, 2007-04-03 at 04:20, Shavonne Marietta Wijesinghe wrote: > Ok so i'm posting alot in the forums. Anyway for a change i have > another problem ^___^ > > I have a table that has a field n_gen serial NOT NULL > > ermm let me explain. I have 5 records inserted (n_gen = 1, 2, 3, 4, 5) > >

Re: [SQL] Serial

2007-04-03 Thread A. Kretschmer
am Tue, dem 03.04.2007, um 12:29:37 +0200 mailte Shavonne Marietta Wijesinghe folgendes: > I'm mixed up now. I was suppose to something but i did something else. > > OK so i have my FAMOUS table with the n_gen serial NOT NULL > I got lost a bit. When and where do i use the setval() ?? Only to m

Re: [SQL] Serial

2007-04-03 Thread Shavonne Marietta Wijesinghe
I'm mixed up now. I was suppose to something but i did something else. OK so i have my FAMOUS table with the n_gen serial NOT NULL I got lost a bit. When and where do i use the setval() ?? For example i INSERT records via ASP. so i should put the setval() in the INSERT INTO of the ASP page?? A

Re: [SQL] Serial

2007-04-03 Thread A. Kretschmer
am Tue, dem 03.04.2007, um 11:55:10 +0200 mailte Shavonne Marietta Wijesinghe folgendes: > thanks. I read the page you gave. Really? > > CREATE SEQUENCE seq_mytable_n_gen; > > CREATE TABLE mytable > ( > n_gen int nextval('seq_mytable_n_gen'), > mycolumn1 int, > mycolumn2 int > ); > > >

Re: [SQL] Serial

2007-04-03 Thread Milen A. Radev
Shavonne Marietta Wijesinghe wrote: > thanks. I read the page you gave. > > CREATE SEQUENCE seq_mytable_n_gen; > > CREATE TABLE mytable > ( > n_gen int nextval('seq_mytable_n_gen'), > mycolumn1 int, > mycolumn2 int > ); > > > i tried creating it like that. The sequence was created without an

Re: [SQL] Serial

2007-04-03 Thread Shavonne Marietta Wijesinghe
R: syntax error at or near "nextval" at character 38 What should i do? Shavonne Wijesinghe - Original Message - From: "A. Kretschmer" <[EMAIL PROTECTED]> To: Sent: Tuesday, April 03, 2007 11:32 AM Subject: Re: [SQL] Serial am Tue, dem 03.04.2007, um 11:

Re: [SQL] Serial

2007-04-03 Thread A. Kretschmer
am Tue, dem 03.04.2007, um 11:20:16 +0200 mailte Shavonne Marietta Wijesinghe folgendes: > The problem is when i INSERT a new record. It takes the value n_gen = 6 but i > need it to take the value 5. It keeps a record of the delete records. > > Is there anyway in PostgreSQL i can change it? or

[SQL] Serial

2007-04-03 Thread Shavonne Marietta Wijesinghe
Ok so i'm posting alot in the forums. Anyway for a change i have another problem ^___^ I have a table that has a field n_gen serial NOT NULL ermm let me explain. I have 5 records inserted (n_gen = 1, 2, 3, 4, 5) At a surtain point i DELETE the record 2 and UPDATE the record 5 with the n_gen 2

Re: [SQL] serial in output

2005-11-04 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "alessandra de gregorio" <[EMAIL PROTECTED]> writes: > Hi, > What function should I use to get a serial number, together with my results, > from a query? > Ex. Of output I want: > 1 ooo pp ij > 2 hou joo iu > 3 bhi ft yh

Re: [SQL] serial in output

2005-11-04 Thread Andreas Kretschmer
alessandra de gregorio <[EMAIL PROTECTED]> schrieb: > Hi, > > What function should I use to get a serial number, together with my results, > from a query? > > Ex. Of output I want: > > 1 ooo pp ij > 2 hou joo iu > 3 bhi ft yh > > Basically, I would l

[SQL] serial in output

2005-11-03 Thread alessandra de gregorio
Hi, What function should I use to get a serial number, together with my results, from a query? Ex. Of output I want: 1 ooo pp ij 2 hou joo iu 3 bhi ft yh Basically, I would like to have one column with integers, from 1 onwards, no matter how man

Re: [SQL] Serial and Index

2005-02-27 Thread Tom Lane
"Sam Adams" <[EMAIL PROTECTED]> writes: > I read at http://jamesthornton.com/postgres/FAQ/faq-english.html#4.15.1 > that when a serial is created then an index is created on the column. > However I can't seem to find this anywhere in the PoistgreSQL manual. Is > this true? Thanks. It was once true

Re: [SQL] Serial and Index

2005-02-27 Thread Ragnar Hafstað
On Sun, 2005-02-27 at 12:54 +, Sam Adams wrote: > I read at http://jamesthornton.com/postgres/FAQ/faq-english.html#4.15.1 > that when a serial is created then an index is created on the column. > However I can't seem to find this anywhere in the PoistgreSQL manual. Is > this true? Thanks. no,

Re: [SQL] Serial and Index

2005-02-27 Thread Miroslav Šulc
Documentation at http://www.postgresql.org/docs/8.0/interactive/datatype.html#DATATYPE-SERIAL says: "In most cases you would also want to attach a UNIQUE or PRIMARY KEY constraint to prevent duplicate values from being inserted by accident, but this is not automatic." and "*Note: * Prior to P

Re: [SQL] Serial and Index

2005-02-27 Thread Mike Rylander
On Sun, 27 Feb 2005 12:54:52 +, Sam Adams <[EMAIL PROTECTED]> wrote: > I read at http://jamesthornton.com/postgres/FAQ/faq-english.html#4.15.1 > that when a serial is created then an index is created on the column. > However I can't seem to find this anywhere in the PoistgreSQL manual. Is > thi

Re: [SQL] Serial and Index

2005-02-27 Thread Michael Fuhr
On Sun, Feb 27, 2005 at 12:54:52PM +, Sam Adams wrote: > I read at http://jamesthornton.com/postgres/FAQ/faq-english.html#4.15.1 That copy of the FAQ is over two years old according to the "Last updated" text at the top of the page. You can find the current FAQ here: http://www.postgresql.o

Re: [SQL] Serial and Index

2005-02-27 Thread Bruno Wolff III
On Sun, Feb 27, 2005 at 12:54:52 +, Sam Adams <[EMAIL PROTECTED]> wrote: > I read at http://jamesthornton.com/postgres/FAQ/faq-english.html#4.15.1 > that when a serial is created then an index is created on the column. > However I can't seem to find this anywhere in the PoistgreSQL manual. Is

[SQL] Serial and Index

2005-02-27 Thread Sam Adams
I read at http://jamesthornton.com/postgres/FAQ/faq-english.html#4.15.1 that when a serial is created then an index is created on the column. However I can't seem to find this anywhere in the PoistgreSQL manual. Is this true? Thanks. -Sam ---(end of broadcast)-

Re: [SQL] SERIAL parameters

2002-08-28 Thread Bruce Momjian
You can create the sequence manually and define that a the default for the column. I suppose we could pass the create sequence params through SERIAL but there doesn't seem like there is much demand for it. --- Arnold Puton

[SQL] SERIAL parameters

2002-08-28 Thread Arnold Putong
Would it be possible to have parameters in the SERIAL datatype? CREATE TABLE x { ID SERIAL(100, 10) } means ID starts at 100 and will be incremented by 10. And it would be nice to have CREATE TABLE x { ID SERIAL(0,0) } mean that ID will be issued random non-repeating values (period=2^bitwid

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Stephan Szabo
On Thu, 13 Jun 2002, Charlie Toohey wrote: > If session A and session B are concurrently doing the same master-detail > transaction, wouldn't currval possibly reflect the sequence value used by the > other session ? Or are you saying that since this will be an explicit > transaction that currval

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Charlie Toohey
that definitely helps ! thank you Jason --- the key thing that I didn't undertand, and you have now enlightened me, is that currval was connection dependent --- I didn't think this would be guaranteed to work with concurrent transactions, but now I understand. Just prior to receiving your mess

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Jason Earl
Charlie Toohey <[EMAIL PROTECTED]> writes: > I'm having a problem and there seems to be 2 solutions. It is simple > and straighforward, but will take several paragraphs to explain. > > I have a schema with a master-detail design. The master table does > not have an expicit id, so I have a column

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Charlie Toohey
If session A and session B are concurrently doing the same master-detail transaction, wouldn't currval possibly reflect the sequence value used by the other session ? Or are you saying that since this will be an explicit transaction that currval won't reflect the fact that the sequence may have

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Tom Lane
Charlie Toohey <[EMAIL PROTECTED]> writes: > A better solution would seem to use a sequence explicitly, rather than a id > column of type serial. I would obtain the id value from the sequence, and > then insert this id into the master table and into the detail table. Yup. But there's no need t

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Josh Berkus
Charlie, > Lets say I need to insert a row into the master table and N rows into the > detail table. After inserting a row into master, and before detail, I need to > read the master table to obtain the value of the id for the row just > inserted, so I can insert this id as the foreign key v

Re: [SQL] serial column vs. explicit sequence question

2002-06-13 Thread Stephan Szabo
On Thu, 13 Jun 2002, Charlie Toohey wrote: > I'm having a problem and there seems to be 2 solutions. It is simple and > straighforward, but will take several paragraphs to explain. > > I have a schema with a master-detail design. The master table does not have > an expicit id, so I have a column

[SQL] serial column vs. explicit sequence question

2002-06-13 Thread Charlie Toohey
I'm having a problem and there seems to be 2 solutions. It is simple and straighforward, but will take several paragraphs to explain. I have a schema with a master-detail design. The master table does not have an expicit id, so I have a column of type serial. Lets say I need to insert a row i

[SQL] serial data type

2001-10-26 Thread postgresql
CREATE TABLE tablename (colname SERIAL); okay, but how do I set the beginning number. So far the only thing I have been able to do is directly after creating the serial column, I do: select setval('tablename_colname_seq', 15753); Is this the only way to set the beginning number of a sequence?

Re: [SQL] serial type; race conditions

2001-04-03 Thread postgresql
n passing it back to my app. commit, then do an update. I can not seem to get the seq to work. Ted -Original Message- From: Michael Fork <[EMAIL PROTECTED]> To: postgresql <[EMAIL PROTECTED]> Date: Thu, 29 Mar 2001 10:04:46 -0500 (EST) Subject: Re: [SQL] serial type; race co

Re: [SQL] serial type; race conditions

2001-03-30 Thread D'Arcy J.M. Cain
Thus spake postgresql > How does currval work if you are not inside a transaction. I have > been experimenting with inserting into a table that has a sequence. > If the insert fails (not using a transaction) because of bad client input > then the next insert gets the proper next number in the s

Re: [SQL] serial type; race conditions

2001-03-29 Thread Michael Fork
want > the empty row. > > Thanks, it is getting clearer > > Ted > > > -Original Message- > From: Bruce Momjian <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Date: Mon, 26 Mar 2001 16:47:37 -0500 (EST) > Subject: Re: [SQL] serial type; race

Re: [SQL] serial type; race conditions

2001-03-29 Thread Andrew Perrin
I ditto what Bruce said - trying to get a true sequence without gaps is a losing battle. Why don't you, instead, use a serial column as the real sequence, and then a trigger that simply inserts max(foo) + 1 in a different column? Then when you need to know the column, do something like: SELECT nu

Re: [SQL] serial type; race conditions

2001-03-29 Thread Bruce Momjian
> How does currval work if you are not inside a transaction. I have > been experimenting with inserting into a table that has a sequence. > If the insert fails (not using a transaction) because of bad client input > then the next insert gets the proper next number in the sequence. If you are i

Re: [SQL] serial type; race conditions

2001-03-29 Thread postgresql
hanks, it is getting clearer Ted -Original Message- From: Bruce Momjian <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Date: Mon, 26 Mar 2001 16:47:37 -0500 (EST) Subject: Re: [SQL] serial type; race conditions > > Hi, > > > > I'm using serial fields to gen

Re: [SQL] serial type; race conditions

2001-03-26 Thread Bruce Momjian
> Hi, > > I'm using serial fields to generate IDs for almost all object in my > database. I insert an empty row, get the CURRVAL() of the sequence > and then update to that value. > > I had understood (and now, I can't find the reference to back this up) > that serial is implemented in such a w

[SQL] serial type; race conditions

2001-03-26 Thread jkakar
Hi, I'm using serial fields to generate IDs for almost all object in my database. I insert an empty row, get the CURRVAL() of the sequence and then update to that value. I had understood (and now, I can't find the reference to back this up) that serial is implemented in such a way that race con

Re: [SQL] serial type question

2001-03-19 Thread Richard Huxton
postgresql wrote: > > I have a table that I want to add a serial type column. Is there a way > to add it or do I have to create a new table and insert into it. I have > experimented with: > > insert into newdb (name) select name from olddb order by jobno; > > however, pg does not allow the 'ord

Re: [SQL] serial type question

2001-03-19 Thread Stephan Szabo
On Mon, 19 Mar 2001, postgresql wrote: > I have a table that I want to add a serial type column. Is there a way > to add it or do I have to create a new table and insert into it. I have > experimented with: > > insert into newdb (name) select name from olddb order by jobno; > > however, pg d

[SQL] serial type question

2001-03-19 Thread postgresql
I have a table that I want to add a serial type column. Is there a way to add it or do I have to create a new table and insert into it. I have experimented with: insert into newdb (name) select name from olddb order by jobno; however, pg does not allow the 'order by' during an insert/select I

Re: [SQL] SERIAL type does not generate new ID ?

2000-07-12 Thread Jean-Marc Libs
On Sat, 10 Jun 2000, Jean-Marc Libs wrote: Hi all, > I don't really understand what happens, so I put context, then problem: > > 1/ Context > -- > I have this table: > > CREATE TABLE film ( > film_id SERIAL PRIMARY KEY, snip > ) > ; > SELECT setval ('film_film_id_seq', 6); > > 2/ Prob

Re: [SQL] SERIAL type does not generate new ID ?

2000-07-10 Thread Ed Loehr
Jean-Marc Libs wrote: > > I have this table: > > CREATE TABLE film ( >film_id serial, > ... > > SELECT setval ('film_film_id_seq', 6); > > I have this query in PHP: > insert into film > >(film_country_id,film_country_id2,film_country_id3,film_country_id4,film_prod_year,film_ec_certif,film_

[SQL] SERIAL type does not generate new ID ?

2000-07-10 Thread Jean-Marc Libs
Hi all, I don't really understand what happens, so I put context, then problem: 1/ Context -- I have this table: CREATE TABLE film ( film_id SERIAL PRIMARY KEY, film_country_id CHAR(2), film_country_id2 CHAR(2), film_country_id3 CHAR(2), film_country_id4 CHAR(2), film_ec_certif BOOL DEF