Please help me to avoid this Exception.

I have a JTextField which will accept only non-negative integer. To get the Document roll_doc for the constructor of JTextField
I have a class maxLengthText which will make sure that the JTextfield accepts only non-negative integer.
I have a problem while resetting the content of the JTextField. As I have made sure that only integers are allowed in my text field.
So while using setText(" "). The code executes the exception in my actionListener. I don't want this exceptuion to get executed when I reset the content of my JTextField using setText(String).
Please help. Suggest any workaround for this. Thanks in advance
The code is as follows:
package marksheet;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.BorderFactory;
import javax.swing.*;
import javax.swing.text.*;
public class SpringApplet1 extends JApplet implements ActionListener {
     JLabel l_instruction1;
     JLabel l_instruction2;
     JLabel l_instruction3;
     JLabel l_instruction4;
     JLabel l_instruction5;
     JLabel l_instruction6;
     JLabel l_instruction7;
     JLabel l_instruction8;
     JLabel l_space;
     JLabel label1;
     JLabel label2;
     JLabel label3;
     JLabel label4;
     JTextField text1;
     JTextField text2;
     JTextField text3;
     JTextField text4;
     JLabel l_name;
     JLabel l_fname;     
     JLabel l_course;
     JLabel l_specialization;
     JLabel l_batch;
     JLabel l_semester;
     JLabel l_rollno;
     JLabel l_enrolno;
     JTextField t_name;
     JTextField t_fname;
     JTextField t_rollno;
     JTextField t_enrollno;
     JComboBox cb_course;
     JComboBox cb_branch;
     JComboBox cb_batch;
     JComboBox cb_semester;
     JCheckBox c_parttime;
     JCheckBox c_fulltime;
     JButton Submit;
     JButton enterMarks;
     JButton reset;
     JTextField txtInt;
     JPanel p;
     JPanel p1;
     JPanel p2;
     JPanel p3;
     public void init () {
     l_space = new JLabel(" ");
     Document roll_doc = new maxLengthText(5); // set maximum length to 5
     Document enroll_doc = new maxLengthText(6); // set maximum length to 6
     t_rollno= new JTextField(roll_doc, "", 6);
     t_enrollno= new JTextField(enroll_doc, "", 7);
     Document name_doc = new maxLengthAlpha(15); // set maximum length to 15
     t_name = new JTextField(name_doc, "", 7);
     l_instruction1 = new JLabel("All names should be alphabets",JLabel.LEFT);
     l_instruction1.setForeground(Color.blue);
     l_instruction1.setVisible(false);
     l_instruction1.setVisible(true);
     l_instruction2 = new JLabel("Name can not be greater than 15 characters",JLabel.LEFT);
     l_instruction2.setForeground(Color.blue);
     l_instruction2.setVisible(false);
     l_instruction2.setVisible(true);
     l_instruction3 = new JLabel("Seperate firstname and last name with a 'space'",JLabel.LEFT);
     l_instruction3.setForeground(Color.blue);
     l_instruction3.setVisible(false);
     l_instruction3.setVisible(true);
     l_instruction4 = new JLabel("All marks are out of 100, Marks obtained are non-negative integers",JLabel.LEFT);
     l_instruction4.setForeground(Color.blue);
     l_instruction4.setVisible(false);
     l_instruction4.setVisible(true);
     l_instruction8 = new JLabel("Marks obtained can not be greater than 100 ",JLabel.LEFT);
     l_instruction8.setForeground(Color.blue);
     l_instruction8.setVisible(false);
     l_instruction8.setVisible(true);
     l_instruction5 = new JLabel("Roll number should be of length 5 and only numeric",JLabel.LEFT);
     l_instruction5.setForeground(Color.blue);
     l_instruction5.setVisible(false);
     l_instruction5.setVisible(true);
     l_instruction6 = new JLabel("Enrolment number should be of length 6 and only numeric",JLabel.LEFT);
     l_instruction6.setForeground(Color.blue);
     l_instruction6.setVisible(false);
     l_instruction6.setVisible(true);
     l_instruction7 = new JLabel("All fields are Mandatory",JLabel.LEFT);
     l_instruction7.setForeground(Color.blue);
     l_instruction7.setVisible(false);
     l_instruction7.setVisible(true);
     l_name = new JLabel("Name",JLabel.LEFT);
     l_name.setForeground(Color.blue);
     l_fname = new JLabel("Father's Name",JLabel.LEFT);
     l_fname.setForeground(Color.blue);
     l_course = new JLabel("Course",JLabel.LEFT);
     l_course.setForeground(Color.blue);
     l_specialization = new JLabel("Specialization",JLabel.LEFT);
     l_specialization.setForeground(Color.blue);
     l_batch = new JLabel("Batch",JLabel.LEFT);
     l_batch.setForeground(Color.blue);
     l_semester = new JLabel("Semester",JLabel.LEFT);
     l_semester.setForeground(Color.blue);
     l_rollno = new JLabel("Roll Number",JLabel.LEFT);
     l_rollno.setForeground(Color.blue);
     l_enrolno = new JLabel("Enrolment Number",JLabel.LEFT);
     l_enrolno.setForeground(Color.blue);
     //t_name = new JTextField(20);
     t_name.setEditable(true);
//     t_name.setBackground(Color.YELLOW);
     t_fname = new JTextField(20);
     t_fname.setEditable(true);
//     t_fname.setBackground(Color.YELLOW);
     //t_rollno = new JTextField(20);
     t_rollno.setEditable(true);
//     t_rollno.setBackground(Color.YELLOW);
     //t_enrollno = new JTextField(20);
     t_enrollno.setEditable(true);
//     t_enrollno.setBackground(Color.YELLOW);
     label1 = new JLabel("Data Structures",JLabel.LEFT);
     label1.setForeground(Color.blue);
     label1.setVisible(true);
     label2 = new JLabel("Compiler Design",JLabel.LEFT);
     label2.setForeground(Color.blue);
     label2.setVisible(true);
     label3 = new JLabel("Numerical Analysis",JLabel.LEFT);
     label3.setForeground(Color.blue);
     label3.setVisible(true);
     label4 = new JLabel("Discrete Matehmatics",JLabel.LEFT);
     label4.setForeground(Color.blue);
     label4.setVisible(true);
     text1 = new JTextField(20);
     text1.setEditable(false);
//     text1.setBackground(Color.green);
     text1.setVisible(true);
     text2 = new JTextField(20);
     text2.setEditable(false);
//     text2.setBackground(Color.green);
     text2.setVisible(true);
     text3 = new JTextField(20);
     text3.setEditable(false);
//     text3.setBackground(Color.green);
     text3.setVisible(true);
     text4 = new JTextField(20);
     text4.setEditable(false);
//     text4.setBackground(Color.green);
     text4.setVisible(true);
     String a_course[] =
          {" ","BE","MCA"};
     String a_branch[] =
          {" ","Computer Science","Electronics"};
     String a_batch[] =
          {" ","2000-2001","2001-2002","2002-2003","2003-2004","2004-2005"};
     String a_semester[] =
          {" ","I","II","III","IV","V","VI","VII","VIII"};
     cb_course = new JComboBox(a_course);
     cb_branch = new JComboBox(a_branch);
     cb_batch = new JComboBox(a_batch);
     cb_semester = new JComboBox(a_semester);
     c_parttime = new JCheckBox("Part Time");
     c_fulltime = new JCheckBox("Full Time");
     Submit = new JButton ("Generate Marksheet");
     Submit.setVisible(true);
//     Submit.addActionListener(this);
     enterMarks = new JButton ("Enter Marks");
     enterMarks.setVisible(true);
// enterMarks.addActionListener(this);
     reset= new JButton ("Reset");
     reset.setVisible(true);
//reset.addActionListener(this);
     p = new JPanel(new GridLayout(5,2,2,2));
p.setBorder(BorderFactory.createTitledBorder("Student Details"));
     p.add(l_name);
     p.add(t_name);
p.add(l_fname);
     p.add(t_fname);
p.add(l_rollno);
     p.add(t_rollno);
p.add(l_enrolno);
     p.add(t_enrollno);
     p.add(l_space);
     p.add(l_space);
     p1 = new JPanel(new GridLayout(0,2,2,2));
     p1.setBorder(BorderFactory.createTitledBorder("Course Details"));
     p1.add(l_course);
     p1.add(cb_course);
     p1.add(l_specialization);
     p1.add(cb_branch);
     p1.add(l_batch);
     p1.add(cb_batch);
     p1.add(l_semester);
     p1.add(cb_semester);
     p1.add(c_parttime);
     p1.add(c_fulltime);
     p1.add(reset);
     p1.add(enterMarks);
     p2 = new JPanel(new GridLayout(0,2,2,2));
     p2.setBorder(BorderFactory.createTitledBorder("Marks Details"));
     p2.add(label1);
     p2.add(text1);
     p2.add(label2);
     p2.add(text2);
     p2.add(label3);
     p2.add(text3);
     p2.add(label4);
     p2.add(text4);
     p2.add(Submit);
     p2.setVisible(true);
     p3 = new JPanel(new GridLayout(0,1,2,2));
     p3.setBorder(BorderFactory.createTitledBorder("Instructions"));
     p3.add(l_instruction1);
     p3.add(l_instruction2);
     p3.add(l_instruction3);
     p3.add(l_instruction4);
     p3.add(l_instruction8);
     p3.add(l_instruction5);
     p3.add(l_instruction6);
     p3.add(l_instruction7);
     JFrame f = new JFrame("Student Marksheet System");
f.getContentPane().setLayout(new GridLayout(2,2,3,3));
f.getContentPane().add(p3);
     f.getContentPane().add(p);
f.getContentPane().add(p1);
     f.getContentPane().add(p2);
     enterMarks.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
               String message = "Are you sure all information is correct";
               String get_text1;
               String title = "Confirmation";
               int getcourseindex;
               int getbranchindex;
               int getsemesterindex;
               int getbatchindex;
               getcourseindex = cb_course.getSelectedIndex();
               getbranchindex = cb_branch.getSelectedIndex();
               getsemesterindex = cb_semester.getSelectedIndex();
               getbatchindex = cb_branch.getSelectedIndex();
               if (c_fulltime.isSelected() == false && c_parttime.isSelected() == false)
                    JOptionPane.showMessageDialog(null,"Atleast one mandatory field is missing","TextField",1);
                         return;
               if(getcourseindex == 0)
                         JOptionPane.showMessageDialog(null,"Atleast one mandatory field is missing","TextField",1);
                         return;
               if(getbranchindex == 0)
                         JOptionPane.showMessageDialog(null,"Atleast one mandatory field is missing","TextField",1);
                         return;
               if(getsemesterindex == 0)
                         JOptionPane.showMessageDialog(null,"Atleast one mandatory field is missing","TextField",1);
                         return;
               if(getbatchindex == 0)
                         JOptionPane.showMessageDialog(null,"Atleast one mandatory field is missing","TextField",1);
                         return;
               int n = JOptionPane.showConfirmDialog(null,message,title, JOptionPane.YES_NO_OPTION);
               if(n==0)
                    get_text1 = t_name.getText();
                    t_name.setEditable(false);
                    t_fname.setEditable(false);
                    t_rollno.setEditable(false);
                    t_enrollno.setEditable(false);     
                    cb_course.setEnabled(false);     
                    cb_branch.setEnabled(false);     
                    cb_batch.setEnabled(false);     
                    cb_semester.setEnabled(false);
                    reset.setEnabled(false);
     reset.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
               String message = "Are you sure to reset the fields";
               String title = "Confirmation";
               int n = JOptionPane.showConfirmDialog(null,message,title, JOptionPane.YES_NO_OPTION);
               if(n==0)
                    Submit.setEnabled(true);
                    cb_course.setSelectedIndex(0);
                    cb_branch.setSelectedIndex(0);
                    cb_batch.setSelectedIndex(0);
                    cb_semester.setSelectedIndex(0);
                    t_rollno.setText("");
     Submit.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
               String message = "Confirmation will generate the marksheet";
               String title = "Confirmation";
               int n = JOptionPane.showConfirmDialog(null,message,title, JOptionPane.YES_NO_OPTION);
               if(n==0)
                    Submit.setEnabled(true);
     c_parttime.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
               if (c_fulltime.isSelected() == true)
                    c_fulltime.setSelected(false);
     c_fulltime.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
               if (c_parttime.isSelected() == true)
                    c_parttime.setSelected(false);
f.pack();
f.setVisible(true);
     public void paint(Graphics g) {
     //Draw a Rectangle around the applet's display area.
g.drawRect(0, 0, size().width - 1, size().height - 1);
     public void actionPerformed(ActionEvent event){
     package marksheet;
     import javax.swing.*;
     import javax.swing.text.*;
     import java.awt.*;
     public class maxLengthText extends PlainDocument
          int maxVal=0;
          public maxLengthText(int maxLength)
               maxVal = maxLength;
          publ1ic void insertString(int offset, String str, AttributeSet a) throws BadLocationException
               if (getLength() + str.length() > maxVal)
                    return;
               else
                    try
                         if(!Double.isNaN(Double.parseDouble(str)))
                              super.insertString(offset, str, a);
                    catch(Exception e)
                         JOptionPane.showMessageDialog(null,"Numbers Only","TextField",1);
                         offset=0;
     }

When you post code, please use the [co[i]de][co[i]de] tags. There is a code button above the message textfield.

Similar Messages

  • Always an alert on opening firefox, please help me to avoid this. And i can find help in french. thanks

    this message appears at the opening:
    Adobe® Flash® Player has stopped a potentially unsafe operation. The following local application on your computer or network:
    /jar/file/:::Users:soniasnoussi:Library:Application Support:Firefox:Profiles:ydjvyvnz.default:extensions:{ef4e370e-d9f0-4e00-b93e-a4f274cfdd5a}.xpi!:chrome:content:foxTab_flash10.swf?v1_4_1
    is trying to communicate with this Internet-enabled location:
    null
    To let this application communicate with the Internet, click Settings.
    You must restart this application after changing your settings.
    Thank you for your help. In french if possible
    Sonia

    hello sonja, please install version 1.4.10 of the foxtab extension that is available at https://addons.mozilla.org/firefox/addon/foxtab/versions/ and which should fix the issue you're describing.

  • My iPhone 6 ear speaker is not working properly I couldn't able to hear any thing from ear speaker to lissen I had to put on loud speaker or to use handsfree please help me out with this problem if some body have answer?

    My iPhone 6 ear speaker is not working properly I couldn't able to hear any thing from ear speaker to listen I had to put on loud speaker or to use hands free please help me out with this problem if some body have answer?

    Hi Venkata from NZ,
    If you are having an issue with the speaker on your iPhone, I would suggest that you troubleshoot using the steps in this article - 
    If you hear no sound or distorted sound from your iPhone, iPad, or iPod touch speaker - Apple Support
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • I have problem with account that i can't make update or buy from app store There is massage appear in my payment page that i must contact with i tunes support to complete this transaction Please help me to fixe this problem as soon possible Hany hassan 00

    I have problem with account that i can't make update or buy from app store
    There is massage appear in my payment page that i must contact with i tunes support to complete this transaction
    Please help me to fixe this problem as soon possible
    Hany hassan
    0096597617317
    0096596677186
    Thank you

    You need to Contact iTunes Support...
    Apple  Support  iTunes Store  Contact Us

  • I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4

    I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4

    I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4

  • Hello i have a unusual problem,anyway my iphone 4 wont turn on and when someone calls they hear ringing,but my phone doesent ring,so i open cimcas now ring off. Screen is just black,because it's turned off..Please help me to solve this problem..Thanks

    Hello i have a unusual problem,anyway my iphone 4 wont turn on and when  someone calls they hear ringing,but my phone doesent ring.So i poen simcase and now ring off. Screen is just  black,because it's turned off..Please help me to solve this  problem..Thanks

    As far as trying to power up your device, make sure it has a good charge and then hold the button on the top of the phone and the home button on the faceplate together until the apple appears on the screen.

  • Hi, when ever I'm using 3G, on my Iphone4 sim stops working and Network is lost, this started after I updated my phone with  6.0.1(10A523)version. Please help how to solve this problem.

    Hi, when ever I'm using 3G, on my Iphone4 sim stops working and network is lost, this started after I updated my phone with  6.0.1(10A523)version. Please help how to solve this problem. Thanks.

    Photos/videos in the Camera Roll are not synced. Photos/videos in the Camera Roll are not touched with the iTunes sync process. Photos/videos in the Camera Roll can be imported by your computer which is not handled by iTunes. Most importing software includes an option to delete the photos/videos from the Camera Roll after the import process is complete. If is my understanding that some Windows import software supports importing photos from the Camera Roll, but not videos. Regardless, the import software should not delete the photos/videos from the Camera Roll unless you set the app to do so.
    Photos/videos in the Camera Roll are included with your iPhone's backup. If you synced your iPhone with iTunes before the videos on the Camera Roll went missing and you haven't synced your iPhone with iTunes since they went missing, you can try restoring the iPhone with iTunes from the iPhone's backup. Don't sync the iPhone with iTunes again and decline the prompt to update the iPhone's backup after selecting Restore.

  • Please help me to solve this date comparision issue..

    Please help me to solve this issue..
    If i have some data like the following..
    ID           START DATE             END DATE
    1             20080101              20080501
    1             20080502              20080630
    2             20080631              20080801
    2             20080802              20080901
                                                 ---------------> There is a break in date over here
    2             20080930              20081029
    2             20081030              20081130
    I need to compare the End Date with the start date (These data will not be in order)
    and find out if there is any break and should get the output date : *20080930*
    I am trying to do this in SQL or PL/SQL.Please help me .
    Thanks in advance.
    phani

    Hi Frank ,
    Sorry to bug you again. I ran your code on my actual data but not gettting the expected output.Here i am posting the actual code and the output that i got when i ran your code.Please bear with me and help me to solve this..
    /* Formatted on 5/25/2009 2:27:24 PM (QP5 v5.115.810.9015) */
    SELECT   member_nbr,
             aff_nbr,
             ymdeff,
             ymdend,
             gap_before,
             COUNT (gap_after)
                OVER (PARTITION BY member_nbr, aff_nbr ORDER BY ymdend DESC)
                AS gap_cnt
      FROM   (SELECT   member_nbr,
                       aff_nbr,
                       ymdeff,
                       ymdend,
                       CASE
                          WHEN ymdeff >
                                  LEAD(ymdend)
                                     OVER (PARTITION BY member_nbr, aff_nbr
                                           ORDER BY ymdend DESC)
                                  + 1
                          THEN
                             1
                       END
                          AS gap_before,
                       CASE
                          WHEN ymdend <
                                  LAG(ymdeff)
                                     OVER (PARTITION BY member_nbr, aff_nbr
                                           ORDER BY ymdend DESC)
                                  - 1
                          THEN
                             1
                       END
                          AS gap_after
    ------------I need this SQL to filter the whole data to the data that i posted in previous post -----
                FROM   (  SELECT   ms1.member_nbr, 
                                   ms1.aff_nbr,
                                   ms1.ymdeff,
                                   ms1.ymdend,
                                   ms1.void
                            FROM   (SELECT   ms.member_nbr,
                                             ms.aff_nbr,
                                             ms.ymdeff,
                                             ms.ymdend,
                                             ms.void
                                      FROM   MEMBER mb, member_span ms
                                     WHERE   mb.member_nbr = ms.member_nbr
                                             AND (20090523 BETWEEN ms.ymdeff
                                                               AND  ms.ymdend
                                                  AND TRIM (void) IS NULL)
                                             AND mb.member_nbr = 'A1000073000 ')
                                   eff_pcp,
                                   member_span ms1
                           WHERE   ms1.member_nbr = eff_pcp.member_nbr
                                   AND (SUBSTR (eff_pcp.aff_nbr, 1, 6) =
                                           SUBSTR (ms1.aff_nbr, 1, 6))
                        ORDER BY   ms1.ymdeff DESC)
    ---------- end of my part  ----------
                table_x) got_gaps;Outputs that i got when i ran that code for each individual members..
    Sorry to bug you frank and thanks for all the help.I will post here if i get any other data.
    Thanks
    phani

  • HT1212 My iPod touch is disabled after too many attempts and I want to enable it without getting it clear so can you please help me out in this....

    My iPod touch is disabled after too many attempts and I want to enable it without getting it clear so can you please help me out in this....

    A data recovery company MAY be able to do it for a price. The Disabled is a very good security feature.
    JWhy not just restore from the last backup you have?
    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up     
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
      Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • TS1363 My iPod Nano 7th Generation couldn't be detected by iTunes when I plugged in. I tried resolving the issue by uninstalling the iTunes and then install it back again but yet still the same problem exist. Can you please help me to solve this issue?

    My iPod Nano 7th Generation couldn't be detected by iTunes when I plugged in. I tried resolving the issue by uninstalling the iTunes and then install it back again but yet still the same problem exist. Can you please help me to solve this issue? I have already updated to the latest version of iTunes on my Windows 8 and I cannot synchronize my iPod for the time being. Please do help me to solve this problem. Thank You.

    uninstall all iTunes,5 programes,this worked for me after reinstall them

  • Can you please help me how resolved this issue.

    Hi Experts
    I am trying to connect LDAP by R/3 system. R/3 system connected to LDAP but when I am trying to find and pull the fileds in the "Find in the Directolry" option I am getting below error.
    LDAPRC 010 another server is referenced.
    Can you please help me how resolved this issue.
    With Regards,
    Trinadh Bokka

    You may be able to solve by using
    Note 1151329 - Depth of LDAP search is only one level below the base entry
    Markus

  • While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.

    While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.

    I faced the same issue. This solved it for me: Troubleshooting issues with iTunes for Windows updates
    Hope this helps.

  • HT204266 I lost the app "app store" on my iphone. How to get it back? I couldn't find a way neither on the iphone mor on iTunes Could you please help me in restore this app? Thanks

    I lost the app "app store" on my iphone. How to get it back? I couldn't find a way neither on the iphone mor on iTunes Could you please help me in restore this app? Thanks

    The App store is a iOS function and cannot be deleted. Try checking other home screens/folders and see if you can locate it. If not, go into Settings>General>Reset>Reset Home Screen Layout.

  • I click on one song and another one starts playing.  Cover art for one artist shows up on another album.  All of my music isn't showing up.  Please help.  Why is this happening?  How can I fix it?

    I click on one song and another one starts playing.  Cover art for one artist shows up on another album.  All of my music isn't showing up.  Please help.  Why is this happening?  How can I fix it?

    Sorry for not getting back with you...
    That moves only the iTunes media, not the iTunes library (which is really kinda nebulous).
    iTunes library = iTunes folder and all the media, wherever it is located.
    The /Music/iTunes/ folder contains the iTunes library.itl file, which keeps track of everything in iTunes.
    I do however still have the original MAIN startup drive still in the computer, it's just not the startup.
    This is good you still have it.
    Try this...
    Hold Option and launch iTunes.
    Select Choose library... and select the /iTunes/ folder on the original drive. It should be in /Users/your_user_name/Music/.
    Don't mess with anything. We can get it cleared up.
    Does everything work okay?

  • Please help to re-write this query using exists or with

    Hi please help to re-write this query using exists or with, i need to write same code for 45 day , 90 days and so on but sub query condition is same for all
    SELECT SUM (DECODE (t_one_mon_c_paid_us, 0, 0, 1)) t_two_y_m_mul_ca_
    FROM (SELECT SUM (one_mon_c_paid_us) t_one_mon_c_paid_us
    FROM (
    SELECT a.individual_id individual_id,
    CASE
    WHEN NVL
    (b.ship_dt,
    TO_DATE ('05-MAY-1955')
    ) >= SYSDATE - 45
    AND a.country_cd = 'US'
    AND b.individual_id in (
    SELECT UNIQUE c.individual_id
    FROM order c
    WHERE c.prod_cd = 'A'
    AND NVL (c.last_payment_dt,
    TO_DATE ('05-MAY-1955')
    ) >= SYSDATE - 745)
    THEN 1
    ELSE 0
    END AS one_mon_c_paid_us
    FROM items b, addr a, product d
    WHERE b.prod_id = d.prod_id
    AND d.affinity_1_cd = 'ADH'
    AND b.individual_id = a.individual_id)
    GROUP BY individual_id)
    Edited by: user4522368 on Aug 23, 2010 9:11 AM

    Please try and place \ before and after you code \Could you not remove the inline column select with the following?
    SELECT a.individual_id individual_id
         ,CASE
            when b.Ship_dt is null then
              3
            WHEN b.ship_dt >= SYSDATE - 90
              3
            WHEN b.ship_dt >= SYSDATE - 45
              2
            WHEN b.ship_dt >= SYSDATE - 30
              1
          END AS one_mon_c_paid_us
    FROM  items           b
         ,addr            a
         ,product         d
         ,order           o
    WHERE b.prod_id       = d.prod_id
    AND   d.affinity_1_cd = 'ADH'
    AND   b.individual_id = a.individual_id
    AND   b.Individual_ID = o.Individual_ID
    and   o.Prod_CD       = 'A'             
    and   NVL (o.last_payment_dt,TO_DATE ('05-MAY-1955') ) >= SYSDATE - 745
    and   a.Country_CD    = 'US'

Maybe you are looking for

  • Is there a way to find and replace prices in an Indesign document from a CSV file?

    Is there a way to find and replace prices in an Indesign document from a CSV file. Currenty I have a catalog with codes and prices in tables. I need to find a way to look up the code (and new price) in the CSV file and overwrite the price in the curr

  • Graphic inspector color swatch corner darkned ...means what?

    in the inspector, graphic, fill color, the color swatch will sometimes have a upper right corner darkened (like to grab it and turn a page), and other times not. What does this mean? thanks bob

  • Re: ASSISTANCE PLEASE HDMI problem with Humax DTRT...

     Hi starting this new thread as the one I have posted on has not been replied to yet and do not know how to flag it up for a reply!? Hi have just found this thread.  I had problems last October when my youview box which was installed in May the sound

  • Servlet not available exception

    Hi i am running a server in J2EE(JSP,Servlets) etc. it was working fine but suddenly when i tried to add some servlet and linked some thing with it. It says "Requested resource not found". I am using netbeans 5.5 and adding these from IDE same as the

  • Deleting a Business System and related/assigned objects

    I am PI newbie (as will soon become apparent) so first I apologise for my "simple" question. In PI one business system has been replaced with another e.g. BS_US_1CLNT is replaced by BS_US_2CLNT. I want to delete the first business system and all its