IF this field is unique you shouldn't get duplicates from a function;
the transaction will either succeed or fail; the beauty of a function
is that you can return an error message. I personally prefer to
handle errors at the application level, but if you have admins running
ad-hoc queries on the d
On 06/07/11 21:47, Gavin Flower wrote:
I forgot the format required of the order number, so to get the full
yesr, I should have used:
to_char(day, 'MMDD')
[...]
v_order_num := type::text ||
'-' ||
to_char(day, 'YYMMDD') ||
On 06/07/11 01:52, John Fabiani wrote:
Hi,
I have a special need to create a sequence like function.
"O-20110704 -2" which is
"O" for order (there are other types)
"20110704" is for July 4, 2011
'2' the second order of the day for July 4, 2011
I of course can get the type and date. What I do
On 2011-07-06, Kevin Crain wrote:
> That's why you need to do this inside a function. Basically just make
> an insert function for the table and have it calculate the count and
> do the insert in one transaction.
you will still get duplicates, so include code in the function to
retry if there is
That's why you need to do this inside a function. Basically just make
an insert function for the table and have it calculate the count and
do the insert in one transaction.
On Tue, Jul 5, 2011 at 5:41 PM, Samuel Gendler
wrote:
>
>
> On Tue, Jul 5, 2011 at 2:42 PM, John Fabiani wrote:
>>
>> On T
On Tue, Jul 5, 2011 at 2:42 PM, John Fabiani wrote:
> 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
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 somet
My previous reply was intended for John.
On Tue, Jul 5, 2011 at 1: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:
>
> se
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
On Tue, Jul 5, 2011 at 6:52 AM, John Fabiani wrote:
> Hi,
>
> I have a special need to create a sequence like function.
>
> "O-20110704 -2" which is
> "O" for order (there are other types)
> "20110704" is for July 4, 2011
> '2' the second order of the day for July 4, 2011
>
> I of course can get
Hi,
I have a special need to create a sequence like function.
"O-20110704 -2" which is
"O" for order (there are other types)
"20110704" is for July 4, 2011
'2' the second order of the day for July 4, 2011
I of course can get the type and date. What I don't know is how to get is the
last numb
11 matches
Mail list logo