Expand my Community achievements bar.

Adding an item to the database

Avatar

Former Community Member

Hello!

I am currently using a SQLAssembler to read and write to an Oracle database. When my Flex application loads, I call a fill method to get a list of customers. This list of customers is about 9000 so it take a little bit of time to load initially. The customers are loaded into an arraycollection and that arraycollection is passed to a datagrid for displaying. After the data appears in the data grid, a user can create a new customer. The new customer is added to the arraycollection:

customerCollection.addItem(newCustomer);

Using the additem on the arraycollection calls the create-item sql in the sqlassembler which is just an insert statement. Since the arraycollection has 9000+ customers in it, it takes a long time for the new customer to be added to the database. Is there a way to speed this up? Please let me know if I am missing any information that may be useful.

Brenda

4 Replies

Avatar

Employee

When you execute the fill on the data service, you should pass the arrray collection to the fill e.g. myDataService.fill(collection, ...). When you add the item to this "managed" array collection, the create-item will get called with just the the _newly added item_, and the insert SQL executed for it on the server side.

Rohit

Avatar

Former Community Member

Yes, Rohit, I know all that. Seems I missed mentioning some information or maybe I just wasn't clear enough.

I can fill the arraycollection correctly by calling the fill method. I can add the item to the database by adding the new item to the arraycollection which executes the insert query.

The problem is that after the insert query is executed, my application seems to take a long time "returning" from that query. For example, after a customer is added, the user can go through and edit other items about that customer like their address. If the user edits the customer too soon (before the query returns), the primary key on the customer does not have a value so therefore I cannot use an update query on that customer yet.

When I look at my server when the insert is executed, I see all the customers scrolling like they are being retrieved from the database again. Is there a way to quickly add one item to the database and quickly get that item back without having to wait for the fill itself to refresh?

Avatar

Employee

Well, one option is to set autoCommit = false on the data service, and explicitly  call invoke commit on Data Service, when you are finished "cooking" the  item.

I believe, by default SQLAssembler, has autoRefreshFill(...) == true, and uses the default refreshFill(...) implementation, which results in the fill being rexecuted. You might want to extend from the assembler, as per your needs. Refer to the documentation

Good Night!

Avatar

Former Community Member

Thank you for your response! I will have to look into how to do that.

Brenda