• 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
Re: [SOLVED] how to insert records in database in the order of insertion to EC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SOLVED] how to insert records in database in the order of insertion to EC


  • Subject: Re: [SOLVED] how to insert records in database in the order of insertion to EC
  • From: "Shravan Kumar. M" <email@hidden>
  • Date: Sun, 1 Nov 2009 04:40:03 -0800 (PST)

Thanks Kieran for your solution. But unfortunately, we don't extend ERXGenericRecord, so we cannot get benefits of this!!! I have actually read about your this solution in a similar kind of issue posted and responded by you here: http://www.mail-archive.com/email@hidden/msg25975.html


From: Kieran Kelleher <email@hidden>
To: Shravan Kumar. M <email@hidden>
Cc: Chuck Hill <email@hidden>; WO Dev Group <email@hidden>
Sent: Sun, November 1, 2009 5:55:25 PM
Subject: Re: how to insert records in database in the order of insertion to EC

Or if you want the order of the PKs to be the same order as your insertion into the EC, you can try calling

eo.primaryKeyInTransaction    (or sth like that)

which is provided by ERXGenericRecord subclass.

That method assigned the PK ....... do it in each iteration. Then the items are saved the the PK order the same as insertion order.

Regards, Kieran

On Nov 1, 2009, at 12:11 AM, Shravan Kumar. M wrote:

Okay. So, as determined I will just with adding a new field to set the order of records inserted to DB.

Thanks again Chuck for your insight!!!


From: Chuck Hill <email@hidden>
To: Shravan Kumar. M <email@hidden>
Cc: WO Dev Group <email@hidden>
Sent: Sun, November 1, 2009 9:34:31 AM
Subject: Re: how to insert records in database in the order of insertion to EC


On Oct 31, 2009, at 8:46 PM, Shravan Kumar. M wrote:

> Thanks so much for your quick response Chuck.
> 
> We use Frontbase. I have no FK issue here. It's just that the objects should be inserted to DB in the order I have created and inserted into EC.
> 
> Why EC saveChanges() operation just not save the objects in the order of insertion??? Isn't it simple? I believe EC maintains an array insertedObjects(), so it should just follow that array order, unless otherwise any constraints as you have mentioned!!! Just trying to understand the mystery behind the complexity :)

For what you want, it would not matter if it did.  The defined order of records in an un-ordered Select (a select with no Order By clause) is indeterminate.  The database is free to change the order of such result sets to return the result set in the shortest amount of time or any other reason it might have.


> If there's no built-in solution, then probably adding a "sortOrder" field to my table would fix this issue.

That is the ONLY solution you can depend on.


Chuck


> From: Chuck Hill <email@hidden>
> To: Shravan Kumar. M <email@hidden>
> Cc: WO Dev Group <email@hidden>
> Sent: Sun, November 1, 2009 8:49:54 AM
> Subject: Re: how to insert records in database in the order of insertion to EC
> 
> 
> On Oct 31, 2009, at 6:57 PM, Shravan Kumar. M wrote:
> 
> > Hi Group,
> >
> > Could any one please advise me how can I insert records in database in a specific order or as per the order of insertion of objects to EditingContext
> 
> AFAIK, you can't.  The order of insertion is not tracked.
> 
> 
> > for eg:
> >
> > I have inserted objects to EC in the following order: A1, A2, A3, A4, A5 (and then saved the EC once - editingContext.saveChanges())
> > But, when these got saved to database the order is disturbed and is not guaranteed i.e., I see following order sometimes: A2, A5, A1, A3, A4, whereas I want the order of these objects as I have inserted to EC.
> >
> > I heard that we can do something with AdaptorOperations, but not sure of that exactly and am trying to see if we have an higher level API for that. (Just a note: We do not use Wonder to the fullest, of course we use Wonder API's as required.)
> 
> 
> If your problem is FK constraint violations, make the constraints DEFERRABLE INITIALLY DEFERRED when you create them.
> 
> If you are using MS SQL Server, then you are in a world of hurt.  It includes not supporting deferrable constraints in its set of unsupported yet highly desirable features.  There is a reason why people mock that "database".  You can order the operations using EOF but (a) is isn't easy and (b) you can't expect to know the order of insertion and (c) I can't think of many useful examples to follow.  You could start with the source for myhttp://www.global-village.net/chill/ms_sql_server_eof_plugin
> 
> 
> 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/products/practical_webobjects
> 
> 
> 
> 
> 
> 
> 
> 
> 

--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/products/practical_webobjects








_______________________________________________
Do not

 _______________________________________________
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

  • Follow-Ups:
    • Re: [SOLVED] how to insert records in database in the order of insertion to EC
      • From: Patrick Middleton <email@hidden>
    • Re: [SOLVED] how to insert records in database in the order of insertion to EC
      • From: Mike Schrag <email@hidden>
References: 
 >Re: how to insert records in database in the order of insertion to EC (From: Kieran Kelleher <email@hidden>)

  • Prev by Date: Re: how to insert records in database in the order of insertion to EC
  • Next by Date: Re: [SOLVED] how to insert records in database in the order of insertion to EC
  • Previous by thread: Re: how to insert records in database in the order of insertion to EC
  • Next by thread: Re: [SOLVED] how to insert records in database in the order of insertion to EC
  • Index(es):
    • Date
    • Thread