Ups forgot the list.
Begin forwarded message:
From: Cail Borrell <[EMAIL PROTECTED]>
Date: 20. aug 2008 18.50.44 GMT+02:00
To: Ondřej Čada <[EMAIL PROTECTED]>
Cc: Cail Borrell <[EMAIL PROTECTED]>
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 PROTECTED] http://www.ocs.cz
private [EMAIL PROTECTED] http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]