Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-28 Thread Alvaro Herrera
andi wrote: > I have seen this is very drawback of our beloved postgres databases, > postgres do not support sql 2003 standards, > > I hope soon we can support this standards. Hmm. True. It is also true that we'll be there sooner if you help out. -- Alvaro Herrera

Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-28 Thread andi
Dear friends,   I have seen this is very drawback of our beloved postgres databases, postgres do not support sql 2003 standards,  I hope soon we can support this standards.   Thank you  

Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-27 Thread Jesper K. Pedersen
Andrew Sullivan wrote: On Fri, May 26, 2006 at 05:11:26PM +0700, andi wrote: select rank() over(order by testeridpk ) as rank , * from tester; I get the result is like this, RANK TESTERIDPK TESTER_NAME 1 10TESSS 2 90NAMAAA 3

Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-26 Thread Andrew Sullivan
On Fri, May 26, 2006 at 09:08:20AM -0500, Bruno Wolff III wrote: > > Rollbacks will not reset sequence values. Use setval to do that. No, what I posted was the CREATE SEQUENCE after the BEGIN. ROLLBACK gets rid of the sequence. The next time you create the same sequence, therefore, it also star

Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-26 Thread Bruno Wolff III
On Fri, May 26, 2006 at 06:50:37 -0400, Andrew Sullivan <[EMAIL PROTECTED]> wrote: > On Fri, May 26, 2006 at 05:11:26PM +0700, andi wrote: > > select rank() over(order by testeridpk ) as rank , * from tester; > > > > I get the result is like this, > > > > > > RANK TESTERIDPK TESTER_NA

Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-26 Thread Andrew Sullivan
On Fri, May 26, 2006 at 05:11:26PM +0700, andi wrote: > select rank() over(order by testeridpk ) as rank , * from tester; > > I get the result is like this, > > > RANK TESTERIDPK TESTER_NAME > > 1 10TESSS > > 2 90NAMAAA > > 3 100

Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-26 Thread andi
When  I use this syntax select * from TESTER; I got   TESTERIDPK  TESTER_NAME 10  TE 90     NAM 100 U   In ms sql server 2005 I use this select rank() over(order by testeridpk ) as rank , * from tester; I get the result is like this,   RAN

Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-24 Thread Richard Huxton
andi wrote: Dear friends, I have table MD_CUSTOMER MD_CUSTOMERIDPK integer primary key NAME varchar OK - two columns. But my primary key is not in correct order like MD_CUSTOMER MD_CUSTOMERIDPK NAME 10 ANDI 33 TESTER 100

Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-24 Thread Franco Bruno Borghesi
Well, you could add a serial column. I'll tell you how, but I haven't tested the code, so be sure to check it! And using BEGIN and COMMIT/ROLLBACK to delimit transactions would not be a bad idea at all ;-)To add a serial column, just write: --create new serial field ALTER TABLE md_customer ADD id

Re: [SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-24 Thread Andrew Sullivan
On Wed, May 24, 2006 at 05:35:10PM +0700, andi wrote: > > But my primary key is not in correct order like What does this mean? Is the key being generated by a sequence (i.e. is the column DEFAULT nextval('some_sequence'))? If so, the primary key will be assigned in COMMIT order. Note that the

[SQL] PLEASE help ME , HOW TO GENERATE PRIMARY Keys on the fly

2006-05-24 Thread andi
Dear friends,   I have table MD_CUSTOMER MD_CUSTOMERIDPK integer primary key NAME   varchar     But my primary key is not in correct order like MD_CUSTOMER MD_CUSTOMERIDPK NAME 10