• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Fwd: sequential numbering across more instances
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: sequential numbering across more instances


  • Subject: Fwd: sequential numbering across more instances
  • From: Cail Borrell <email@hidden>
  • Date: Wed, 20 Aug 2008 18:51:45 +0200

Ups forgot the list.

Begin forwarded message:

From: Cail Borrell <email@hidden>
Date: 20. aug 2008 18.50.44 GMT+02:00
To: Ondřej Čada <email@hidden>
Cc: Cail Borrell <email@hidden>
Subject: Re: sequential numbering across more instances

Hi Ondra,

I believe I did leave out a few details :-)

That would be kind of problem, for I am working with a legacy database which already contains lots of rows.

You don't have to change the database. When I say "internal data type" I mean in the 
context of the EOModel.

Your attribute could look some thing like this

           columnName = <unique column>;
           externalType = NUMERIC; <- an integer column would be fine to
           name = <attribute name>;
           valueClassName = NSString;
           width = 256;

In your EO class you can have the accessors

public void set<attribute name>(Object value)
public Object <attribute name>()

the you can set the sql value however way you desire since
the set method uses takeStoredValueForKey to store the value.

(select max(<unique column>) from (<table name>))+1

could I not? (Assumed there is at least one non-nil column, which it happens to be there all right -- otherwise I could use the improvements Florijan or Francis suggested.)

The coalesce is just used in case you are starting with an empty table 
and need some initial value.

-Cail

On 20/08/2008, at 16.54, Ondřej Čada wrote:

Cail,

On Aug 20, 2008, at 3:47 PM, Cail Borrell wrote:

If you change the internal data type of your unique attribute to String

That would be kind of problem, for I am working with a legacy database which already contains lots of rows.

Not that it would be entirely out of question, but it would complicate things considerably :(

you should be able to use a little sql injection when inserting your record.

Sorry, I got lost here. You mean I should catch the generated SQL in EOF just before sent to the database, and replace the value which is sent to the column by the "coalesce(...)+1" _expression_?

Just set the value of your unique column to something like:
coalesce (select max(<unique column>) from <table name>, cast (1000000 as <unique column data type>)) + 1
and invalidate the eo after insertion.

If not, colour me please dumb and elucidate.

If so... well, I haven't considered this possibility -- good point!

Perhaps I could do the same with an integer column and simpler _expression_

(select max(<unique column>) from (<table name>))+1

could I not? (Assumed there is at least one non-nil column, which it happens to be there all right -- otherwise I could use the improvements Florijan or Francis suggested.)

In the latest versions of FrontBase triggers are enabled by default.

Good, didn't know that. Thanks!
---
Ondra Čada
OCSoftware:     email@hidden               http://www.ocs.cz
private         email@hidden             http://www.ocs.cz/oc





 _______________________________________________
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

  • Prev by Date: Re: Single Table inheritance and EM question
  • Next by Date: Immortal sessions in production
  • Previous by thread: Re: sequential numbering across more instances
  • Next by thread: WOBuilder substitute for Eclipse 3.3+ in Leopard
  • Index(es):
    • Date
    • Thread