How  to make  Purging better in terms  of performance

Hi
I am trying to purge(delete) data from 4 tables on the basis of a flag in the lookup table.
Now, there are 3 million records to be deleted from each of the 4 tables .
My piece of code is like this
for i in(select ids from lookup_table where flag_val='N')
loop
delete from table_a where id=i.ids;
delete from table_b where id=i.ids;
delete from table_c where id=i.ids;
delete from table_d where id=i.ids;
if commit_interval=5000 then
commit;
commit_interval:=0;
end if;
commit_interval:=commit_interval +1;
end;
I am trying to commit for 5000 records.
its taking a lot of time
like 10-12 hrs .
Can anyone solve this issue its urgent .
regards
shubh

Now in your code you have written delete statements for all the four tables. Now convert it to four different procedures each handling only a single table.
something like this.........
for i in(select ids from lookup_table where flag_val='N')
loop
delete from table_a where id=i.ids;
if commit_interval=5000 then
commit;
commit_interval:=0;
end if;
commit_interval:=commit_interval +1;
end;
for i in(select ids from lookup_table where flag_val='N')
loop
delete from table_b where id=i.ids;
if commit_interval=5000 then
commit;
commit_interval:=0;
end if;
commit_interval:=commit_interval +1;
end;
Run these procedures simultaneously.... say thru different windows/terminals.
Since these procedures are running simultaneously, the server efficiency will improve. Also make sure that the server is not used by other users/ less number of users so that max. resources are available for your code.

Similar Messages

  • Code comparission which is better in terms of performance

    In my pl/sql procedure the following code exist
    SELECT count(*) INTO L_exists
              FROM txt
         WHERE templ_id in (ISecurTempl,ESecurTempl);
    Now i want to replace the query with
    SELECT count(*) INTO L_exists
              FROM txt
    WHERE templ_id in (                                                       SELECT INT_SEC_TMP FROM table(cast(parse_table as sec_template_tbl))
                                                      UNION
    SELECT EXT_SEC_TMP FROM table(cast(parse_table as sec_template_tbl))
    Can you please tell me which part of code is better in terms of performance
    and why?
    Thanks in advance

    I want to know which is betterThere's not enough information for anyone here to be able to tell you.
    Obviously the first one "looks" faster, but without knowing the tables, structure, data, indexes, platform etc. etc. etc. we won't have a clue.

  • How to make sound better quality?

    So I exported a preview of my animation but the sound isn't high quality. How can I make it better quality? It doesn't sound like when I press Enter in Flash CS5.

    Go to the publish preferences and see what bit rate is set for the compression of the audio. Be sure to check both stream and event.

  • Look this image, how to make it better

    Can anyone help me to have a look at this picture? It was captured by the camera, and the camera is connected with NI 1427. The middle of the image is so bright. The gap in the middle can not be recognized. Please give some advices on how to make the image better. There must be something with the hardware setting. What should I need to do with that? Thanks for any help.
    Jane
    Attachments:
    NIR1129000019.zip ‏428 KB

    I assume you need to have the overhead lamp on for testing the solar cell?  If you could turn it off during photos, that would improve your images.  Right now I am guessing you are getting a good reflection of the overhead lamp in the center of your image.  Having diffuse lights (like long flourescent bulbs) in multiple places would greatly improve your image quality.  A general rule in lighting for shiny surfaces is to avoid placing a light where you can see its reflection in the image.  This way you won't get any bright spots in the image.
    If you could even tip the solar cell or camera a little bit so the overhead light is not reflected directly into the camera, that would help.
    It is hard to make recommendations without knowing the limitations.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • How to make a better trace

    Using CS5.
    I'm trying to take our old (probably) hand-drawn logo and turn it into a smooth vector image.  I've removed most of the color in Photoshop, blurred it a little, and then opened it in Illustrator.  I then did a LiveTrace.  I end up with lettering that is kindof funky looking. I messed around with the different trace options, but noe of them seem to do the trick.  Thetraced sample below is "detailed illustration".  Is there a way to retain the look of the original logo without having to sacrifice a bunch?  I'm VERY new at this, so I may be describing this all wrong.  I've included the photoshop image and the post-live-trace image.
    After Trace:
    As you can see, there's some weirdness going on in the lettering, for example:the shape of the "S".  How can I make this lettering look "normal"?
    Thanks.
    -Mike

    The answer is what you're probably dreading, if you're new to all this - you must do it yourself. It's pen tool time!
    This is a case where filters/effects/automation is only going to hurt your end-result.
    Get your best cleaned version on the logo. Put it on a new layer and lock it. You might want to make it partially transparent - I don't like drawing on top of high-contrast images when doing a manual re-draw. All you need to see are the edges/outlines, afterall.
    Lock your reference layer.
    Draw on a new layer, on top of your logo reference. Take your time. Make it look good. Carefully craft each path, paying attention to each bezier curve.
    If you know the font originally used, you might try and use that as a base. Manually warp each letterform correctly to match the logo. Might try a Warp or Mesh Envelope Distort.

  • Found Out Why Reception is Bad and How to Make it Better (BT Required)

    When you hold the Iphone in your hand like the Commercial it actually looses reception because the Antena is on the bottom part of the iPhone, and you hand is blocking the anttena, so if u hold the top portion with two fingers careful not to drop it, it actually keeps better signal and less dropped calls, or when u leave it sitting in you lap or on a couter while on your bluetooth it keeps awsome reception, hope this works for all of you.

    Interesting. I've not found that to be entirely the case.
    I've used a BT handsfree kit in my car for a while and call quality and signal have always been stable, and remain so even if I have the iPhone in my pocket, lap or am holding it.
    I also don't find much difference between holding it as per the ad, or setting it down on my desk. Signal remains at the same level - AND subject to the same fluctuations. Those fluctuations seem rather less pronounced since the 1.0.2 update, but are consistent regardless of how the iPhone is held or positioned. Just to be sure, I placed my iPhone face down on a glass table top, and witnessed the same signal as before when it was in my hand.
    I think this device suffers two directly related issues: that it is less sensitive to signal than many other cellphones operating in the same bands, and that as a result it is more sensitive to even slight variations in those signals. Thus for some, in a strong signal area and with little or nothing to negatively impact signal, holding it almost any way won't change the signal. Others, in less strong signal areas or who suffer potentially interfering issues, will see significant variations in signal or call quality dependent on handling of the device or where it is located.

  • How to make a better Page Up/Page Down keyboard shortcut

    I don't like the standard Fn + Up/Down Arrow shortcut because it requires two hands.  How can I make a new one that can be done with just the right hand (like maybe Alt + Arrow or something)?

    @gooballala - the fn + up / down is the only way I can currently do a page up / page down - that's my issue.  For some reason it actually isn't listed anywhere in the keyboard shortcut settings...
    @SwankPeRFection - is there some setting I need to change to make this work?  As of now, Option + Up/Down does the same thing as Up/Down without Option - a very small scroll.

  • Noisy recording when using adobe audition _ how to make it better

    Hi there,
    I have just downloaded adobe audition cs5 for my recordings. When I record something, I have a noise at the back round which is created by I don`t know what. The computer doesn ot make noise and my room is quite.
    Configuration before recording :
    Primary recording :
    After the amplification :
    [0 to 1.8] ms shows the sounds that has been generated by I don`t know what.
    You can get a wave file "Untitled 1.wav" I made from http://dk0.ti1ca.com/get/27.18.148.125/1m7qm7qh/Untitled%201.wav
    I am using  Windows XP sp3
    Thanks for your help.

    @topomorto   Please find below the snaps you asked for.  
    Here is another test I have just done : http://dk1.ti1ca.com/get/27.18.148.125/2myov2k6/Untitled%201.wav

  • Flickr uploading is a horrible experience. Does anyone have any ideas on how to make it better?

    I am using iPhoto and I amd trying to upload several undred pictures to Flickr at a time.
    The native iPhoto exporter hangs and crashes.
    The Flickr Exporter plugin by ConnectiveFlow does the same.
    The web based importer will also do the same and it can only do 200 pictures at a time.
    I am considering Apeture, but does anyone have better experience with Apeture's native uploader?
    Thanks

    I don't believe there's a solution to that. I don't believe there's a way to upload hundreds at one go. But you could contact Flickr support and see what they suggest.

  • Layout suggestions...how to make it better?

    Hi all,
    Just wondering if anyone might be willing to critique my
    site. Please note that I have not yet begun styling the type, which
    I will do later with CSS. Overall I am happy with my direction but
    it's not quite singing yet...
    http://www.bittybox.com/home.html
    Feedback appreciated.
    Thanks!
    V

    Hi all,
    Just wondering if anyone might be willing to critique my
    site. Please note that I have not yet begun styling the type, which
    I will do later with CSS. Overall I am happy with my direction but
    it's not quite singing yet...
    http://www.bittybox.com/home.html
    Feedback appreciated.
    Thanks!
    V

  • How to make program eat less memory/enhance performance ?

    Dear experts,
    I have a program that creates 3 tables containing series of line vectors. These are created from data contained in an ascii file. The program performs some calculations on the data. I have everything working perfectly i.e. it creates the tables, does the calculations and gives me the final results which I need (but this only happens when I use a data file that is 88Kb in size).
    However, the frustrating problem I am experiencing currently is that when I use a heavier file e.g size 4.22mb, after a short delay, Windows starts complaining about memory errors and Windows task manager's Mem usage goes through the roof!
    Eventually, I get an Exception in thread ?main? java.lang.OutOfMemoryError <<no stack trace available>> error from the JVM.
    I have tried "java -Xrunhprof" command and it suggests that the real memory hogging line of code is:
    name = ((String) v.elementAt(nj))+"\t"+((String) reference_vec.elementAt(nj));As the program is dynamically allocating and creating a full nxn matrix of the input data lines at run-time that means it is creating zillions of strings at that line? Concatenation of Strings is not a good idea either as this blows performance too. I am thinking of re-writing the program in C. I have run out of ideas. Please can you suggest how I can make some tweaks to the java code so that the program runs more efficiently? Any comments welcome. Program is approx 500 LOC, can post on request.
    d.

    import java.io.*;
    import java.util.*;
              Mobile ID Classification Program - 2003
              Currently known memory bugs -
              15/10/03      -          JVM reports OutOfMemoryError when gsm_data.txt used as input
    public class DataAnalysis {
    /* Data structures used to store values **/
                   private Hashtable Activity = null;
                   private Vector table1 = null;
                   private Vector table2 = null;
                   private Vector table3 = null;
                   private BufferedReader fin;
                   private StringTokenizer st;
         Mobile activity description strings       
         private final String A1 = "IMSI attach";
         private final String A2 = "IMSI detach";
         private final String A3 = "Periodic location update";
         private final String A4 = "Normal location update+authentication";
         private final String A5 = "Service request mobile call";
         private final String A6 = "Service request SMS";
         private final String A7 = "Service request supplementary service activation";
         private final String A8 = "paging response";
         //           private final String A8a = "Paging response+authentication";
         private final String A9 = "Service request energy";
    /*     main function where the program begins execution **/
         public static void main(String args[]) {
                   if(args.length == 0) {
                             System.out.println("File name not specified. Usage : java -Xmx500mb DataAnalysis <file name> ");
              else if(args.length > 1) {
                             System.out.println("Too many parameters. Usage : java -Xmx500mb DataAnalysis <file name> ");
              else {
                                  new DataAnalysis(args[0]);
    /*          Constructor. Takes input file name string as parameter      **/
         public DataAnalysis(String data_file_name) {
                   Activity = new Hashtable();
                                            table1 = new Vector();
                                            table2 = new Vector();
                                            table3 = new Vector();
         //                Parse the input file. Read in lines.
              try{
                   fin= new BufferedReader(new FileReader(data_file_name));
                   String line;
                   while((line = fin.readLine()) != null) {
                        if (line.trim().length() > 0) {
                             tokenize(line);
              catch(Exception e) {
                                  System.out.println(e.getMessage());
              finally {
                   try {
                                  fin.close();                    //       Close the file input stream then 
                   catch(Exception ee) {
                   //           Create the first two tables
                                                           createTable1();
                                                           createTable2();
              //                     Free the memory occupied by table 1
              //                    freeTable(table1);
                        table1 = null;
                                                           createTable3();
                             //                Free the memory occupied by table 2          
                             //                freeTable(table2);
                   table2 = null;
              //                Select all the mobile ids in gsm_data.txt which have a city block distance value less than 0.25 threshold (upper limit)
              System.out.println("--------------------------Table 3 : Relationship between mobile ids using Manhattan City Block distance -------------------------- \n" );
              for(int ni =0;ni<table3.size();ni++) {
                   Vector inner_vec = (Vector) table3.elementAt(ni);
                   for(int nj = 0;nj<(inner_vec.size()-1);nj= nj+2) {
                             float val = ((Float) inner_vec.elementAt(nj)).floatValue();
                             if(val <= 0.25 && val > 0.0)  {                              
                                            System.out.println((String) inner_vec.elementAt(nj+1));
    /*      Returns the index from table 1  **/
         public int getIndexFromTable1(String id) {
              int index = -1;
              for(int ni = 0;ni<table1.size();ni++) {
                   Vector v = (Vector) table1.elementAt(ni);
                   String vect_id = (String) v.elementAt(0);
                   if(vect_id.equalsIgnoreCase(id)) {
                             index = ni;
                             return index;
                        Create table with actual frequency of mobile activity for each mobile id.   
                        Number of times an activity occurred in the input file.          
         public void createTable1() {
                        Enumeration e = Activity.keys();
                        int sum;
              while(e.hasMoreElements()) {
                        Vector table1_row = null;
                        String s = (String) e.nextElement();
                        Integer num = (Integer) Activity.get(s);
                        StringTokenizer st1 = new StringTokenizer(s, "|");
                        String mobile_id = (String) st1.nextToken();
                        String mobile_act = (String) st1.nextToken();
                        int row_index = getIndexFromTable1(mobile_id);
                   if(row_index > 0) {
                                  table1_row = (Vector) table1.elementAt(row_index);
                                  sum = ((Integer) table1_row.lastElement()).intValue();
                   else {
                                       table1_row = new Vector();
                                       sum = 0;                    
                   if(table1_row.contains(mobile_id)) {
                        if(mobile_act.equalsIgnoreCase(A1)) {                              //                IMSI attach activity
                                  table1_row.setElementAt(num, 1);
                                  sum += num.intValue();
                        else if(mobile_act.equalsIgnoreCase(A2)) {                    //                IMSI detach activity
                                  table1_row.setElementAt(num, 2);
                                  sum += num.intValue();
                        else if(mobile_act.equalsIgnoreCase(A3)) {                    //                Periodic location update activity
                                  table1_row.setElementAt(num, 3);
                                  sum += num.intValue();
                        else if(mobile_act.equalsIgnoreCase(A4)) {                    //            Normal location update+authentication activity
                                  table1_row.setElementAt(num, 4);
                                  sum += num.intValue();
                        else if(mobile_act.equalsIgnoreCase(A5)) {                    //            Service request mobile call activity
                                  table1_row.setElementAt(num, 5);
                                  sum += num.intValue();
                        else if(mobile_act.equalsIgnoreCase(A6)) {                    //                Service request SMS activity
                                  table1_row.setElementAt(num, 6);
                                  sum += num.intValue();
                        else if(mobile_act.equalsIgnoreCase(A7)) {                    //                Service request supplementary service activation activity
                                  table1_row.setElementAt(num, 7);
                                  sum += num.intValue();
                        else if(mobile_act.equalsIgnoreCase(A8)) {               //                     Paging response activity                         
                                  table1_row.setElementAt(num, 8);
                                  sum += num.intValue();
                        else if(mobile_act.equalsIgnoreCase(A9)) {               //                    Service request energy activity          
                                  table1_row.setElementAt(num, 9);
                                  sum += num.intValue();
                                  int lastIndex = table1_row.lastIndexOf(table1_row.lastElement());               //       This is the last index which this table
                                  table1_row.setElementAt(new Integer(sum), lastIndex);
                   else {
                        table1_row.addElement(mobile_id);
                        if(mobile_act.equalsIgnoreCase(A1)) {
                             table1_row.addElement(num);
                             sum += num.intValue();
                        else {
                             table1_row.addElement(new Integer("0"));
                        if(mobile_act.equalsIgnoreCase(A2)) {
                             table1_row.addElement(num);
                             sum += num.intValue();
                        else {
                             table1_row.addElement(new Integer("0"));
                        if(mobile_act.equalsIgnoreCase(A3)) {
                             table1_row.addElement(num);
                             sum += num.intValue();
                        else {
                             table1_row.addElement(new Integer("0"));
                        if(mobile_act.equalsIgnoreCase(A4)) {
                             table1_row.addElement(num);
                             sum += num.intValue();
                        else {
                             table1_row.addElement(new Integer("0"));
                        if(mobile_act.equalsIgnoreCase(A5)) {
                             table1_row.addElement(num);
                             sum += num.intValue();
                        else {
                             table1_row.addElement(new Integer("0"));
                        if(mobile_act.equalsIgnoreCase(A6)) {
                             table1_row.addElement(num);
                             sum += num.intValue();
                        else {
                             table1_row.addElement(new Integer("0"));
                        if(mobile_act.equalsIgnoreCase(A7)) {
                             table1_row.addElement(num);
                             sum += num.intValue();
                        else {
                                  table1_row.addElement(new Integer("0"));
                        if(mobile_act.equalsIgnoreCase(A8)) {
                             table1_row.addElement(num);
                             sum += num.intValue();
                        else {
                             table1_row.addElement(new Integer("0"));
                        if(mobile_act.equalsIgnoreCase(A9)) {
                             table1_row.addElement(num);
                             sum += num.intValue();
                        else {
                                       table1_row.addElement(new Integer("0"));
                                       table1_row.addElement(new Integer(sum));
                   if(row_index > 0){
                        //          Replace the vector in table1 with updated vector
                                            table1.remove(row_index);
                                            table1.insertElementAt(table1_row, row_index);
                   else {
                                       //                 Add the row vector to the table vector as a row.
                                                           table1.addElement(table1_row);
                   tableToString(table1, "--------------------------Table 1: Number of times activity occurred in input txt file -------------------------- " );
                        Create table 2 by normalising the data values from table 1 
         public void createTable2() {
              for(int ni = 0;ni<table1.size();ni++) {
                        int sum;
                        String name = "";
                                            Vector table2_row = new Vector();
                                            Vector table1_row = (Vector) table1.elementAt(ni);
                   //            For each record of table 1
                   for(int nj = 0;nj<table1_row.size();nj++) {
                        sum = ((Integer) table1_row.lastElement()).intValue();
                        //               Name of the activity
                        if(nj == 0) {
                                       name = (String) table1_row.elementAt(nj);
                                       table2_row.addElement(table1_row.elementAt(nj));
                        else if (nj == (table1_row.size() - 1)) {
                                  //                Don't do any thing, we dont want the sum of activities in table 2 !
                        else {
                             Integer num = (Integer) table1_row.elementAt(nj);
                             int num_val = num.intValue();
                             if(num_val == 0) {
                                            table2_row.addElement(new Float("0.0"));
                             else {
                                  if(sum > 0.0) {
                                            table2_row.addElement(new Float((float)num_val/sum));
                                  else {
                                            table2_row.addElement(new Float("0.0"));
                        table2.addElement(table2_row);
                                            tableToString(table2, "--------------------------Table 2: Table 1's Normalised Values --------------------------");
              Create table 3 by comparing the relationship between vectors of table 2 using
              the Manhattan City Block distance.
         public void createTable3() {
                   Vector reference_vec = null;
              for(int ni = 0;ni<table2.size();ni++) {
                                  reference_vec = (Vector)table2.elementAt(ni);
                                  createTable3Record(reference_vec);
    /*       public void createTable3Record(Vector reference_vec) {
              //       Vector table3_record = new Vector();
              Table3Record table3_record = new Table3Record();
              for(int ni = 0;ni<table2.size();ni++) {
                   float sum = 0;
                   //           String name = "";
                   Vector v = (Vector) table2.elementAt(ni);        //           each record of table2
                   for(int nj = 0;nj<v.size();nj++) {                    //           for each element of a record of table 2. Iterate through table 2.
                        if (nj == 0) {
                             //           name = ((String) v.elementAt(nj))+"\t"+((String) reference_vec.elementAt(nj));
                                            table3_record.name_prefix = (String) v.elementAt(nj);
                                            table3_record.name_suffix = (String) reference_vec.elementAt(nj);
                                                 //       table3_record.value = sum;                         
                        else {
                                                 float f1 = ((Float) v.elementAt(nj)).floatValue();
                                                 float f2 = ((Float) reference_vec.elementAt(nj)).floatValue();
                                  sum += Math.abs(f1-f2);
                                  table3_record.value = sum;
                                       //               table3_record.addElement(new Float(table3_record.value));                    //                Value
                                       //             table3_record.addElement(table3_record.name);                                             //                Vector Names for that value
                                                      table3.addElement(table3_record);
                                       //                table3_record = null;                         
                   OLD CODE BUT AT LEAST IT WORKS !!  //    Creates a record for the third table            //  OLD CODE BUT IT WORKS
         public void createTable3Record(Vector reference_vec) {
                        Vector table3_record = new Vector();
              for(int ni = 0;ni<table2.size();ni++) {
                        float sum = 0;
                        String name = "";
                        Vector v = (Vector) table2.elementAt(ni);             //           each record of table2
                   for(int nj = 0;nj<v.size();nj++) {                    //           for each element of a record of table 2. Iterate through table 2.
                             if (nj == 0) {
                              name = ((String) v.elementAt(nj))+"\t"+((String) reference_vec.elementAt(nj));               /**  MEMORY BUG  ?   */
                                  //name = new StringBuffer().append((String) v.elementAt(nj)).append("\t").append((String) reference_vec.elementAt(nj)).toString();               
                        else {
                                            float f1 = ((Float) v.elementAt(nj)).floatValue();
                                            float f2 = ((Float) reference_vec.elementAt(nj)).floatValue();
                                            sum += Math.abs(f1-f2);                              //            Calculate the sum
                                            table3_record.addElement(new Float(sum));                    //           Value
                                            table3_record.addElement(name);                                             //           Vector Names for that value
                                            table3.addElement(table3_record);
                                            table3_record = null;
                   Method which breaks the contents of the file which is read into memory for processing 
         public void tokenize(String s) {
                                  st = new StringTokenizer(s, "\t");
                                  String id = "";
                                  //       String time = "";
                                  String activity = "";
              if(st.hasMoreTokens()) {
                                            st.nextToken();                                                            //                      Date e.g. 13052003
                                            //           time = st.nextToken();                                                            //            Time          e.g. 11:30:18
                                            st.nextToken();
                                            st.nextToken();                                                            //                      Frame Number e.g. 166827                              
                                            id = st.nextToken().trim();                                   //                          ID e.g. f47c12cffb or 2943012109009630
                                            st.nextToken();                                                            //                          Classmark  e.g 33
                                            st.nextToken();                                                            //                          Float e.g. 2.2  (the distance from base station)
                                            activity = st.nextToken().trim();                    //                      Activity e.g IMSI attach
                   String key = id+"|"+activity;
                                            key = key.intern();               
                   if (Activity.containsKey(key)) {
                                       Integer num = (Integer) Activity.get(key);
                                       int num_val = num.intValue();
                                       num_val += 1;
                                       num = new Integer(num_val);
                                       Activity.put(key, num);
                   else {
                             Activity.put(key, new Integer(1));               //  Insert key into our Hashtable
                   Frees the memory used by a table 
         public void freeTable(Vector table) {
                        for (int ni = 0;ni<table.size();ni++) {
                                            Vector inner = (Vector) table.elementAt(ni);
                                            inner = null;
                                            table = null;
                   Convert a vector to a string suitable for displaying on console output               
         public void tableToString(Vector table, String table_name){
                   System.out.println(table_name + "\n");
                                  for (Iterator it = table.iterator(); it.hasNext();) {                                                              
                                                 System.out.println(it.next());
                   Function which sepearates mobile id usage beween day/night usage.     
         public void calculateTimeInterval(String t1, String t2){
                             //           t' = t1 - t2          
                             //           Look at all the ids
              Date d1,d2;
                             d1 = new Date(t1);
                             d2 = new Date(t2);
                             // TBD
    }

  • How to make use of byte array to perform credit and debit in Wallet Applet

    Hi,
    Can anyone please explain me how to use the concept of byte arrays.. to perform credit and debit operations of a 6byte amount. Say for example.. the amount contains 3 bytes whole number, 1 byte decimal dot and 2 bytes fractional part.
    It would be helpful if anyone could post a code snippet.. that way i can undersatnd easily.
    Thanks in Advance
    Nara

    Hello
    as explained in the other topic, remember your high school years and how you leart to add numbers.
    then, reproduce these algorithms for base-256 numbers.
    fractional? just google about fixed point math and floating point math. The first one is easier, as they are managed as integers.
    example, you want to store 1,42€. Then you decide the real number to deal with is N*100, and you store 142. You get 2 decimal places of precision.
    in the computer world it's easier to store n*256 as it's just a byte shift.
    then the addition operations are the same, and you just interpret the values as fractional numbers.
    regards
    sebastien

  • Which is better in terms of performance

    Dear All,
    which is better..
    to use FOR ALL ENTRIES      or
    to build a range and use  WHERE IN RANGE_TABLE     .. Does this have data limitation problem.
    is there a better method?
    Thanks,
    Raghavendra
    Moderator message - Please search before asking - post locked
    Edited by: Rob Burbank on Jul 7, 2009 10:53 AM

    I want to know which is betterThere's not enough information for anyone here to be able to tell you.
    Obviously the first one "looks" faster, but without knowing the tables, structure, data, indexes, platform etc. etc. etc. we won't have a clue.

  • How could I make Siri better?

    On the Siri official page, Apple states that Siri gets better by learning owners' accent.
    Here comes the question: how does Siri get better?
    I mean, once you used Siri and found the words are slighty off from what you actually said.
    Most people might just launch Siri again and re-spoke the sentence again until Siri finally got what they wanted.
    Is Siri able to learn the accent from this action?
    Siri sometimes got wrong on certain names especially they're ones Nickname and probably not even a complete word.
    Then Siri tried to make the whole senetence logical by changing the entire sentence which will result something completely off the original given command.
    Anyone knows how to make Siri better and more personalized?

    I'd suggest:
    1) don't have setNumeratorr and setDenominator methods. Make the numerator and denominator final fields in Rational. That is, make each Rational instance immutable.
    2) Give Rational a constructor that takes two longs. One is the numerator and the other is the denominator. The constructor removes common factors between the two and stores the values in their most reduced form.
    3) The add method can probably be cleaned up give (2).
    4) Don't name the argument to add "object". Of course it's an object. Call it "operand" or even just "other".

  • Suggestions on how to make this coding better?

    Hey everyone, I was just wondering if anyone had any suggestions on how to make my code better. It's for a project and I want to get a good grade on it. It works fine but I just want to see what everyone thought before I hand it in.
    import java.io.*;
    import java.util.StringTokenizer;
         This class process the input expressions containing rational expressions and proecesses them and then outputs the results.
         @author *****
         @version 1.0
    public class Proj1
         private static String buffer = null; //User input
         private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         private static PrintWriter outfile = null;
         private static int totCount = 0, goodCount = 0, badCount = 0; //Total, Valid, and Invalid counts
         private static boolean fileInput = false; //File to read data
         private static boolean fileOutput = false; //Output for the data
         private static boolean screenOutput = false; //Output so the user can view it
         private static String outFile = null; //File for output
         private static String inFile = null; //File for input
              Main method
         public static void main (String[] args) throws Exception
              Proj1 proj1 = new Proj1();
              proj1(args);
              runs the program
         private static void proj1(String [] args) throws Exception
              if (args.length == 0)
                   printBanner();
                   System.out.println("\n" + "\n" + "Please enter an expression, or type quit");
                   do
                        screenOutput=true;
                        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                        processData();
                   }while(!buffer.equals("quit"));//exits if quit is entered
              if (args[0].charAt(0) != '-')
                   badOption("Invalid Option Specified ");
              for(int i=1; i<args[0].length(); i++)
                   switch(args[0].charAt(i))
                        case 'f': fileInput = true;
                                    break;
                        case 'o': fileOutput = true;
                                    break;
                        case 'b': fileOutput = true;
                                    screenOutput = true;
                                    break;
                        default:  printBanner();
                                    invalidOption("Proj1: Invalid Option Found: " + args[0].charAt(i));
              if(fileInput && args[0].length() == 2)
                   screenOutput = true;
              if(fileInput && !fileOutput)
                   if(args.length == 1)
                        badOption("No Input File Specified.");
                   else
                        File inFile = new File(args[1]);
                        if(!inFile.exists())
                             nonExist("Input File " + args[1] + " not found");
                   br = new BufferedReader(new FileReader(args[1]));
                   printBanner();
                   processData();
                   closeFiles();
              if(fileOutput && fileInput)
                   printBanner();
                   if(args.length > 2)
                        outFile = args[2];
                   else
                        if(args.length > 1)
                             outFile = "proj1.dat";
                             noOut("No output file specified , defaulting to proj1.dat");
                   inFile = args[1];
                   br = new BufferedReader(new FileReader(inFile));
                   processData();
                   closeFiles();
              if(fileOutput && screenOutput)
                   printBanner();
                   if(args.length == 1)
                        outFile = "proj1.dat";
                        noOut("No output file specified, defaulting to proj1.dat");
                        System.out.println("\n" + "\n" + "Please enter an expression, or type quit");
                        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
                        processData();
                        closeFiles();
                   else
                        outFile=args[1];
                        System.out.println("\n" + "\n" + "Please enter an expression, or type quit");
                        br = new BufferedReader(new InputStreamReader(System.in));
                        processData();
                        closeFiles();
         Processes the input data by the user by doing the specified operations and then displays the output
         private static void processData() throws Exception
              if(fileOutput)
                   outfile = new PrintWriter(new FileOutputStream(outFile), true);
              else if(fileOutput && screenOutput)
                   outfile = new PrintWriter(new FileOutputStream(outFile), true);
              buffer = br.readLine();
              while(!buffer.equals(""))
                   StringTokenizer reader = new StringTokenizer(buffer);
                   int count = 0;
                   String number1 = null;
                   String number2 = null;
                   String op = null;
                   boolean valid = true;
                   boolean secondNumber = true;
                   while (reader.hasMoreTokens())
                        switch(count)
                             case 1: number1 = reader.nextToken();
                                       break;
                             case 2: op = reader.nextToken();
                                       break;
                             case 3: number2 = reader.nextToken();
                                       break;
                        count++;
                   if(number1 == null || number1.equals("quit"))
                        printSummary(goodCount, badCount, totCount);
                        closeFiles();
                   if(number2 == null)
                        secondNumber = false;
                   char character;
                   int position = 0;
                   String s = "0123456789/-";
                   for(int i = 0; i < number1.length(); i++)
                        character = number1.charAt(i);
                        position = s.indexOf(character);
                        if(position == -1)
                             valid = false;
                   if(secondNumber)
                        for(int i = 0; i < number2.length(); i++)
                             character = number2.charAt(i);
                             position = s.indexOf(character);
                             if(position == -1)
                                  valid=false;
                   int denomin2 = 0;
                   int numer2 = 0;
                   String n1 = null;
                   String d1 = null;
                   int izerCount = 0;
                   StringTokenizer st2 = new StringTokenizer(number1,"/");
                   while(st2.hasMoreTokens())
                        switch(izerCount)
                             case 1: n1 = st2.nextToken();
                                       d1 = "1";
                                       break;
                             case 2: d1 = st2.nextToken();
                        izerCount++;
                   int numer1;
                   int denomin1;
                   int tokenCount = 0;
                   if(valid)
                        numer1 = Integer.parseInt(n1);
                        denomin1 = Integer.parseInt(d1);
                        String n2 = null;
                        String d2 = null;
                        if(secondNumber)
                             StringTokenizer st3 = new StringTokenizer(number2, "/");
                             while(st3.hasMoreTokens())
                                  switch(tokenCount)
                                       case 1: n2 = st3.nextToken();
                                                 d2 = "1";
                                                 break;
                                       case 2: d2 = st3.nextToken();
                                  tokenCount++;
                             numer2 = Integer.parseInt(n2);
                             denomin2 = Integer.parseInt(d2);
                             RationalNumber z1 = new RationalNumber(numer2, denomin2);
                        RationalNumber z = new RationalNumber(numer1,denomin1);
                        RationalNumber z1 = new RationalNumber(numer2,denomin2);
                        boolean lt = true; //whether the first number is less than the second
                        boolean gt = true; //whether the first number is greater than the second
                        boolean eq = true; //whether the first number is equal to the second
                        boolean le = true; //whether the first number is less or equal to the second
                        boolean ge = true; //whether the first number is greater than or equal to the second
                        boolean zeroDenom = true; //whether the denominator is zero
                        if(denomin1 == 0 || denomin2 == 0)
                             zeroDenom = true;
                             badCount++;
                        else
                             zeroDenom = false;
                        if(!zeroDenom && secondNumber)
                             if(op.equals("+"))
                                  RationalNumber z2 = z.add(z1);
                                  if(screenOutput)
                                       System.out.println(buffer + " = " + z2.getNumerator()+ "/" +z2.getDenominator());
                                  if(fileOutput || fileOutput && screenOutput)
                                       outfile.println(buffer + " = " + z2.getNumerator()+ "/" +z2.getDenominator());
                                  goodCount++;
                             else if(op.equals("-"))
                                  RationalNumber z3 = z.sub(z1);
                                  if(screenOutput)
                                       System.out.println(buffer + " = " + z3.getNumerator()+ "/" +z3.getDenominator());
                                  if(fileOutput || fileOutput && screenOutput)
                                       outfile.println(buffer + " = " + z3.getNumerator()+ "/" +z3.getDenominator());
                                  goodCount++;
                             else if(op.equals("*"))
                                  RationalNumber z4 = z.mlt(z1);
                                  if(screenOutput)
                                       System.out.println(buffer + " = " + z4.getNumerator()+ "/" +z4.getDenominator());
                                  if(fileOutput || fileOutput && screenOutput)
                                       outfile.println(buffer + " = " + z4.getNumerator()+ "/" +z4.getDenominator());
                                  goodCount++;
                             else if(op.equals("/"))
                                  RationalNumber z5 = z.div(z1);
                                  if(screenOutput)
                                       System.out.println(buffer + " = " + z5.getNumerator()+ "/" +z5.getDenominator());
                                  if(fileOutput || fileOutput && screenOutput)
                                       outfile.println(buffer + " = " + z5.getNumerator()+ "/" +z5.getDenominator());
                                  goodCount++;
                             else if(op.equals("<"))
                                  lt=z.lt(z1);
                                  if(screenOutput)
                                       System.out.println(buffer + " is " + lt);
                                  if(fileOutput || fileOutput && screenOutput)
                                       outfile.println(buffer + " is " + lt);
                                  goodCount++;
                             else if(op.equals(">"))
                                  gt=z.gt(z1);
                                  if(screenOutput)
                                       System.out.println(buffer + " is " + gt);
                                  if(fileOutput || fileOutput && screenOutput)
                                       outfile.println(buffer + " is " + gt);
                                  goodCount++;
                             else if(op.equals("="))
                                  eq=z.eq(z1);
                                  if(screenOutput)
                                       System.out.println(buffer + " is " +  eq);
                                  if(fileOutput || fileOutput && screenOutput)
                                       outfile.println(buffer + " is " +  eq);
                                  goodCount++;
                             else if(op.equals("<="))
                                  le=z.le(z1);
                                  if(screenOutput)
                                       System.out.println(buffer + " is " + le);
                                  if(fileOutput || fileOutput && screenOutput)
                                       outfile.println(buffer + " is " + le);
                                  goodCount++;
                             else if(op.equals(">="))
                                  ge=z.ge(z1);
                                  if(screenOutput)
                                       System.out.println(buffer + " is " + ge);
                                  if(fileOutput || fileOutput && screenOutput)
                                       outfile.println(buffer + " is " + ge);
                                  goodCount++;
                             else
                                  if(op==null)
                                       if(screenOutput)
                                            System.out.println("Invalid expression: " + buffer);
                                       if(fileOutput || fileOutput && screenOutput)
                                            outfile.println("Invalid Expression: " + buffer);
                                       badCount++;
                             else
                                  if(screenOutput)
                                       System.out.println("Invalid expression: " + buffer );
                                  if(fileOutput || fileOutput && screenOutput)
                                       outfile.println("Invalid expression: " + buffer);
                                  badCount++;
                        else
                             if(screenOutput)
                                  System.out.println("Invalid operand: " + buffer);
                             if(fileOutput || fileOutput && screenOutput)
                                  outfile.println("Invalid operand: " + buffer);
                   else
                        if(screenOutput)
                             System.out.println("Invalid operand: " + buffer);
                        if(fileOutput || fileOutput && screenOutput)
                             outfile.println("Invalid operand: " + buffer);
                        badCount++;
                   buffer = br.readLine();
         Prints the banner for the program
         private static void printBanner()
              System.out.println("+++++++++++++++++++++++++++++++++++++++++"+"\n"+"+Welcome to the expression connection   +"+"\n"+"+++++++++++++++++++++++++++++++++++++++++");
         Prints the total number of expressions, total number of valid expressions, and total number of bad expressions.
         private static void printSummary(int goodCount, int badCount, int totCount)
              totCount = goodCount + badCount;
              System.out.println("\n");
              System.out.println("+++++++++++++++++++++++++++++++++++++++++");
              System.out.println("+ Total Expressions:        "+totCount);
              System.out.println("+ Total Valid Expressions   "+goodCount);
              System.out.println("+ Total Bad Expressions     "+badCount);
              System.out.println("+++++++++++++++++++++++++++++++++++++++++");
         Prints the error message if there is no output file specified
         private static void noOut(String errorString)
              System.out.println("\n");
              System.out.println("Proj1: " + errorString);
         Prints the error message if there is an invalid option input by the user
         private static void invalidOption(String errorString)
              System.out.println("\n");
              System.out.println("Proj1: " + errorString);
              System.out.println("Proj1: Usage is: java proj1 [-fob] [input] [output]");
              System.exit(0);
         Prints the error message if there is a bad option input by the user
         private static void badOption(String errorString)
              System.out.println("\n");
              System.out.println("Proj1: " + errorString);
              System.out.println("Proj1: Usage is: java proj1 [-fob] [input] [output]");
              System.exit(0);
         Prints the error message if the input file does not exist
         private static void nonExist(String errorString)
              System.out.println("\n");
              System.out.println("Proj1: " +errorString);
              System.out.println("Proj1: Usage is: java proj1 [-fob] [input] [output]");
              System.exit(0);
         Closes the files used by the user
         private static void closeFiles( )
              if(fileOutput && !screenOutput)
                   outfile.close();
              System.exit(0);
    }

    Well working is good...
    The code itself is less than spectacular I'm afraid. There is very little
    OOness to this. For your future reference when you complete a program
    and it consists of nothing but static methods you have done something
    incorrectly.
    As far as the code you do have goes some refactoring would be nice.
    The two main methods you have (proj1 but especially processData) are
    too long and unwieldy. processData seems to be a program in an of
    itself. It's complicated and hard to follow.
    My recommendation to you would be to read this http://java.sun.com/docs/books/tutorial/java/index.html
    Especially focus on the sections dealing with explanation of Object
    programming. These terms and concepts can certainly be confusing to
    new programmers so you may also want to consider finding yourself a
    tutor to help you get a better grasp of these concepts.
    In short if it works that's good. And it's also good to see that you put the
    effort and time in that you have. However if I was grading your project
    I'd give it a C- at best because this is a Java program in syntax only.

Maybe you are looking for

  • Ethernet to USB adaptor no longer being recognized by my mbp

    I have an older macbook pro, which is running mac os x 10.5.8. The ethernet port is broken so I have been using a mac Ethernet to USB cable because there is no wifi at my college. I got the cable to work for a while, then I unplugged it and my comput

  • How to increase the salary based on the percentage value

    Hi All, Could you please let me know which API need to be used to implement the hike in salary based on the percentage value. And what all the parameters to be used. Appreciate your help... Thanks...

  • Files stored in application data cache

    Recently my weekly virus scans have taken longer and longer. The number of files scanned increased by tens of thousands every week. A carefully crafted search shows that files in the directory C:/Documents and Settings/userxxx/application data/Mozill

  • Credit Limit of Customers

    In SAP Business By Design , in a customer account we can see two balances: 1. Open item Totals in Transaction Currency 2.Valuated Balance in Company Currency Why in some cases the two balances differ ?? Further for credit limit of Customer the balanc

  • Reg : JMS Clustering

              Hai,           I am facing one problem in JMS Clustering. can any one throws a light on that?           it will be very helpful to           me.           i configured WebLogic Cluster with node1 and node 1 as Managed Servers.           i c