Re: Derived read-only attribute to expose PK [Was: Re: postgresql serial columns and wonder]
Re: Derived read-only attribute to expose PK [Was: Re: postgresql serial columns and wonder]
- Subject: Re: Derived read-only attribute to expose PK [Was: Re: postgresql serial columns and wonder]
- From: Chuck Hill <email@hidden>
- Date: Wed, 03 Oct 2012 15:55:57 -0700
On 2012-10-03, at 3:50 PM, Paul Hoadley wrote:
> On 04/10/2012, at 6:45 AM, Chuck Hill wrote:
>
>>> I'm not one of those people, and I did consider that. What I've done instead is used the opportunity to look at ERXSequence and NativeDatabaseSequence in particular. This is one of those perennial "invoice number" situations, where all I really need is an increasing integer sequence. Integer primary key fit that bill, and I was happy to double up on it, but I'll probably use an additional native database sequence instead.
>>
>> I would NOT be in favour using the PK as in invoice number. That IS offensive! :-P
>
> Heh. I guess it depends on your requirements for an invoice number.
I just object to the use of the PK for a piece of data that has meaning to the user. Sooner or later they want to edit it or control it. "I want them to start with 2013 next year"
>> The PKs generated by EOF are not guaranteed to be an unbroken sequence.
>
> No, but they're guaranteed to be unique, which would be sufficient—for me, anyway. If the _unbroken_ sequence (by which I assume you mean "no numbers missing") is important, then you'd need something more sophisticated than a native database sequence anyway, wouldn't you?
Yes!
> Say I generate an invoice which I need to scrap—it has too many mistakes in it, and it's easier to delete than edit. Then I've lost that number in the sequence and can't get it back.
Exactly the issue.
> So, what's your beef with sparse sequences for invoice numbers (some local tax/legal issue?), and just out of interest, how would you solve the problem then?
I have run into that requirement before. IIRC from someone who was used to a paper system were every invoice was kept, voided or not. It is a tricky thing to solve with EOF. An ON INSERT trigger would be one way.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/gvc/practical_webobjects
Global Village Consulting ranks 13th in 2012 in BIV's Top 100 Fastest Growing Companies in B.C!
Global Village Consulting ranks 76th in 24th annual PROFIT 200 ranking of Canada’s Fastest-Growing Companies by PROFIT Magazine!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden