Posts Tagged ‘android’

How to avoid mutation on database tables

Posted in General, java, oracle on September 5th, 2012 by admin – Be the first to comment

What is mutation ?

Clear definition here – http://www.databasejournal.com/features/oracle/article.php/3329121/The-Mutation-error-in-Oracle-Database-Triggers.htm

When will you come across mutation?

In practice, you will come across mutation problems when you are trying to modify a table in the database while that same table is getting updated by another process.

A typical scenario

Think of sort in a table. You let the client modify the sort order for each entry on a table. To accomplish this, you will create a trigger on update, that takes the new sort value of the row that was modified and changes the entries before and after accordingly. So if you have 10 employees, each with incremental sort orders from 1 to 10, changing number 6 to number 7 will perform the following logic.

– Find the employee with a sort order of 7, change it to 6.

Notice that during this operation, you will have to update the same table inside the update trigger. This is a classic Oracle mutation issue. Usually you will get a

ORA-04091: table TRANSACTIONS is mutating, trigger/function may not see it

 

Solution

When you research online, you will find a variety of solution. Asktom’s solution will suggest that you create a custom view based on that table, and then create a trigger on that view which updates the original table. This didn’t really work for us.

Some other solutions also mentioned creating a new package etc.

What works perfectly is inside the trigger, create an autonomous context in the code. This tells oracle to  consider the chunk of code that is inside the autonomous context annotation to work in a new session from the rest of the procedure.

Consider the following for example,

CREATE OR REPLACE TRIGGER TRG_UPDATE
AFTER UPDATE ON TABLEX
FOR EACH ROW
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION; — This is where the magic happens
BEGIN

UPDATE TABLEX …
COMMIT;

END TRIGGER TRG_UPDATE;

Related Links and Solutions

 

http://docs.oracle.com/cd/B14117_01/appdev.101/b10807/13_elems002.htm

 

 

Android Application development Basics

Posted in General, Mobile on December 22nd, 2010 by admin – 2 Comments

Fantastic! You have finally decided to jump into android development. Let’s face it, with the growth of droid devices and predictions of where it will be in the next couple of years and with google’s new announcements such as googletv, it is the perfect time to start off.

We have started on the same journey and as we go along, we will post tips and tricks that we have found useful. There are numerous articles online with detailed instructions on the “how to”s, but there is a lack of comprehensive lists, or index of tutorials if you will, to let developers know how they should dive deep into android development. Hence we decided to write this article in such a way that it will sort of serve a study plan for to-be android developers as well.

Prerequisites

  1. You are  a Java developer or you are very familiar with Java
  2. You know how to use the eclipse IDE

Setup instructions

  1. Get the android SDK
  2. Add android to your path
  3. Add software on Eclipse IDE
  4. Run the AVD ( Android Virtual Device) with some sample application to get a feel of it

Developer’s Notes

  1. Check out the application framework
  2. Memorize the following set of services that you can use in your application
    • Views ( All UIs, like buttons,grids)
    • Content providers ( Access the phone, like contacts)
    • Resource Managers (Provide access not non-code elements such as graphics fonts etc and things under the res/ folder )
    • Notification Managers (Used to create custom alerts that can pop up)
    • Activity Managers (  By definition: “An activity is a single, focused thing that the user can do”. This is what the user sees)
  3. There is no main() method. The application starts by loading components, namely
    • Activity ( Think of it as a screen that has views. In the WAP world, this will be similar to a “deck”)
    • Broadcast Receivers ( Receive and react to the notification manager)
    • Cotent providers ( Makes data available to other applications)
    • Services ( runs in the background and actually does the job)
  4. An example to put things in perspective
    An mp3 player applications has a list of songs, drawn by the Activity, The file list is retrieved by a service and the music is actually played by a service as well. While the music is playing a broadcast receiver can pop up a message saying the battery is low, while a content provider tells another application which song is currently being played so that it can tweet it
  5. The components are all defined on the Manifest file

Once you have finished reading this far, and all the related articles. Do the complete Notepad exercise

Getting Wifi Tether on your motorola backflip

Posted in Mobile on December 7th, 2010 by admin – Be the first to comment

Ok So I have checked hundreds of tutorials online regarding this, but after much experiment, The following is the best way to root your Motorola Backflip (MB 300) and get Wi-Fi tether on it. Why would we “root”? to use an ipod touch with my android on nearby

Have the following things handy

  1. Motorola device driver http://modmymobile.com/forums/downloads.php?do=file&id=28159
  2. connectbot for shell access to your device http://code.google.com/p/connectbot/
  3. Install adb here http://developer.android.com/sdk/index.html

Ok so to root it follow this tutorial

http://modmymobile.com/forums/567-motorola-backflip-general/555749-root-all-versions-backflip.html

Once you are done rooting, install the wifi tether from here

http://code.google.com/p/android-wifi-tether/downloads/list

if the Wi-fi tether doesnt work, try barnacle , this definitely works

http://szym.net/projects/index.html