Re: interesting sequence - Mailing list pgsql-sql

From John Fabiani
Subject Re: interesting sequence
Date
Msg-id 201107051442.29875.johnf@jfcomputer.com
Whole thread Raw
In response to Re: interesting sequence  (Kevin Crain <kevin.crain1@gmail.com>)
Responses Re: interesting sequence
List pgsql-sql
On Tuesday, July 05, 2011 01:11:11 pm Kevin Crain wrote:
> You don't need a loop there.  Assuming your order id field is of type
> varchar you can just build the first part of your string and then do a
> count to get the last part using a LIKE comparison:
> 
> select count(id_order) + 1  from sometable WHERE id_order LIKE 'O-20110704
> -%';
> 
> If you do this inside a function it will be like running it in a
> transaction so you shouldn't have to worry about it being a multi-user
> system.
> 
> 
> 

I like this - looks better than what I'm currently doing.  Thanks
Johnf


pgsql-sql by date:

Previous
From: Viktor Bojović
Date:
Subject: overload
Next
From: Samuel Gendler
Date:
Subject: Re: interesting sequence