Need help with DECODE function

Hello,
I am trying to use default within the decode function and every time I get a missing expression. I have searched everywhere and cant figure out what I'm doing wrong. Thanks
select decode (request_id,0,'No files found', DEFAULT)

Hi,
Welcome to the forum!
When you use a default value, the last argument to DECODE is the actual value you want as a default.
For example:
SELECT       ename
,       deptno
,       DECODE ( deptno
             , 30     , 'Sales'
                  , 'All others'     -- Default value
              )                 AS dname
FROM      scott.emp
ORDER BY  ename
;Output:
ENAME          DEPTNO DNAME
ADAMS              20 All others
ALLEN              30 Sales
BLAKE              30 Sales
CLARK              10 All others
FORD               20 All others
JAMES              30 Sales
JONES              20 All others
KING               10 All others
MARTIN             30 Sales
MILLER             10 All others
SCOTT              20 All others
SMITH              20 All others
TURNER             30 Sales
WARD               30 Sales 
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
If you can show the problem using commonly available tables (such as those in the scott schema) then you don't need to post any sample data; just the results and the explanation.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002}

Similar Messages

  • I need help with Analytic Function

    Hi,
    I have this little problem that I need help with.
    My datafile has thousands of records that look like...
    Client_Id Region Countries
    [1] [1] [USA, Canada]
    [1] [2] [Australia, France, Germany]
    [1] [3] [China, India, Korea]
    [1] [4] [Brazil, Mexico]
    [8] [1] [USA, Canada]
    [9] [1] [USA, Canada]
    [9] [4] [Argentina, Brazil]
    [13] [1] [USA, Canada]
    [15] [1] [USA]
    [15] [4] [Argentina, Brazil]
    etc
    My task is is to create a report with 2 columns - Client_Id and Countries, to look something like...
    Client_Id Countries
    [1] [USA, Canada, Australia, France, Germany, China, India, Korea, Brazil, Mexico]
    [8] [USA, Canada]
    [9] [USA, Canada, Argentina, Brazil]
    [13] [USA, Canada]
    [15] [USA, Argentina, Brazil]
    etc.
    How can I achieve this using Analytic Function(s)?
    Thanks.
    BDF

    Hi,
    That's called String Aggregation , and the following site shows many ways to do it:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    Which one should you use? That depends on which version of Oracle you're using, and your exact requirements.
    For example, is order importatn? You said the results shoudl include:
    CLIENT_ID  COUNTRIES
    1        USA, Canada, Australia, France, Germany, China, India, Korea, Brazil, Mexicobut would you be equally happy with
    CLIENT_ID  COUNTRIES
    1        Australia, France, Germany, China, India, Korea, Brazil, Mexico, USA, Canadaor
    CLIENT_ID  COUNTRIES
    1        Australia, France, Germany, USA, Canada, Brazil, Mexico, China, India, Korea?
    Mwalimu wrote:
    ... How can I achieve this using Analytic Function(s)?The best solution may not involve analytic functions at all. Is that okay?
    If you'd like help, post your best attempt, a little sample data (CREATE TABLE and INSERT statements), the results you want from that data, and an explanation of how you get those results from that data.
    Always say which version of Oracle you're using.
    Edited by: Frank Kulash on Aug 29, 2011 3:05 PM

  • Need help with DECODE

    Hi,
    I need to write a DECODE function to which if I pass 'mystring' and if it has the value 'M' it should output 'M', if it has a value of 'F' it should output 'F' and if mystring is not same as string_coded then it should output string_coded.
    I know the below statement is incorrect.
    decode (mystring, 'M', 'M', 'F', 'F', (mystring <> string_coded), string_coded)
    Is there a way to correct this DECODE? Please suggest.
    Thanks.

    It is not clear of you want it to match the string 'string_coded' or if it is some column name, but with the example below you should be able to figure out what to adjust to make it work in your case.
    SQL> create table mytable
      2  as
      3  select 'M' mystring, 'X' string_coded from dual union all
      4  select 'F', 'X' from dual union all
      5  select 'X', 'X' from dual union all
      6  select 'Z', 'X' from dual
      7  /
    Tabel is aangemaakt.
    SQL> select mystring
      2       , string_coded
      3       , decode(mystring,'M','M','F','F',string_coded,'mystring = string_coded','mystring != string_coded') your_expression
      4    from mytable
      5  /
    M S YOUR_EXPRESSION
    M X M
    F X F
    X X mystring = string_coded
    Z X mystring != string_coded
    4 rijen zijn geselecteerd.Regards,
    Rob.

  • Help with Decode function

    Hello!!
    Can anyone please help me with the decode statement
    Table 1 Table2 Table3
    Id Id Code
    Volume Code
    For each of the codes in Table3 I need to find the corresponding Volume. Can I use decode in the select statement to this,
    Eg Code Volume
    ABC 20
    XYZ 10 etc etc.
    Thankyou all in advance.

    Your table structure is a little unclear from your post. I am assuming that what you posted was:
    Table 1
    Id
    Table2
    Id
    Code
    Table3
    Volume
    Code You can use decode if there are only a few values for table3. For example,
    SELECT table2.code,
    DECODE(table2.code,'ABC',10,'XYZ',20,'UNKNOWN') volume
    FROM table2
    or even
    SELECT code,DECODE(code,null,'NONE',
                      (SELECT volume FROM table3 where code=table2.code)) volume
    FROM table2However, the first will break, or at least be incorrect, if anyone adds a new code/volume pair, and is tedious if you have more than a few values. The second will likely be pretty slow if there are a large number of records in table3. The best solution would be to use a simple join rather than decode. Something like:
    SELECT table1.id, table2.code, table3.volume
    FROM table1, table2, table3
    WHERE table1.id = table2.id and
          table2.code = table3.code

  • Need help with MAX function to return values

    I am trying to create a report to return slow moving inventory data. One of the requests is that it return only the latest date that an item transacted upon. One sheet will show the last receipt date for a part, another will show the last time a part was issued or shipped on a sales order.
    The hiccup is that it is returning every single last time that an item was received, and every single last issuance of the material (on the second sheet) of items on hand.
    Could someone help me to define the max value function? As listed below, and many variations, the sheet comes up with no data or corrupt dates.
    MAX(Transaction Date MAX) OVER(PARTITION BY Material Transactions.Item ORDER BY Material Transactions.Item )
    Still returns both the following when in reality I just want the one with the most recent date (April 2010).
    100034     BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT     A400M     AB01D..     $0.00     WIP component issue     11-Sep-2009     -3
    100034     BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT     A400M     AD01D..     $0.00     WIP component issue     13-Apr-2010     -16
    Thank you for your assistance.
    Becka

    Hi Becka
    It does look correct. When I look at your data I can see 2 different items:
    100034 BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT A400M AB01D.. $0.00 WIP component issue 11-Sep-2009 -3
    100034 BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT A400M AD01D.. $0.00 WIP component issue 13-Apr-2010 -16
    One is AB01D and the other being AD01D. Is this expected?
    To get the right date you might want to PARTITION BY the BNDSCE-105 which might be the Item Number?
    If you can get your calculation to return the correct date then you next need to put in a new condition where the Transaction Date = MAX Transaction Date
    One part of the function that I would question is the use of MAX in both parts like this: MAX(Transaction Date MAX). You might be better just using MAX(Transaction Date) OVER ......
    Does this help?
    Best wishes
    Michael

  • Need help with effect / function stop!

    Hi all!
    I tried to build some kind of custom pop-up-menu with fade
    in/out effect, however the menu sometimes (< very often, but not
    always) disappears while the mouse is still over it.
    So i defined a function to stop/abort the effects, but this
    doesn't work right.
    Could anybody please tell me, how to stop all functions,
    while the mouse is over a link?
    /// This is the container to appear / disappear:
    <div id="navislide" style="height:292px;
    overflow:hidden;">
    <a href="mylink.html" onMouseOver="killall();"
    onMouseOut="hideit();">mylink</a>
    </div>
    /// This is the link to show the container:
    <a href="#"
    onMouseOver="slidefadein.start();">mylink</a>
    <script type="text/javascript">
    function displayblock() {
    var thediv = document.getElementById('navislide');
    thediv.style.display= "block";
    slidetimer = setTimeout('slidefadeout.start();', 2000);
    hideit = function() {
    slidetimer = setTimeout('slidefadeout.start();', 2000);
    function displaynone() {
    var thediv = document.getElementById('navislide');
    thediv.style.display= "none";
    killall = function() {
    clearTimeout(slidetimer);
    slidefadeout.stop();
    slidefadein.stop();
    displayblock();
    slidefadeup.start();
    var slidefadein = new Spry.Effect.Fade("navislide", {from:0,
    to:100, toggle:false, setup:displayblock, finish:hideit});
    var slidefadeout = new Spry.Effect.Fade("navislide",
    {from:100, to:0, toggle:false, finish:displaynone});
    var slidefadeup = new Spry.Effect.Fade("navislide",
    {from:100, to:100, toggle:false});
    </script>
    Probably, its all about the "killall"-function, because when
    the mouse moves over the link, the function to abort all other
    effects, does not take effect.
    Thank you so much vor any kind of help or hint!!
    Cheers,
    idefix

    I would be most interested in a reply to this for I asked
    weeks ago how to use an onClick stop() function for the links in my
    page. I was given the stop function by VFusion (it is to stop
    panels from rotating), but I could never figure out how to actually
    get the function to stop the panels and could not get it no matter
    what I tried, eventually had to take the panel rotation out.

  • Need help with responsibility/ functions query

    hi,
    we are working in oracle applications 11i.
    I have a requirement to extract the responsibility list of functions and menus.
    I need to omit the excluded menus from each responsibility
    this what I have so far (after researching the internet):
    SELECT
    FRTL.RESPONSIBILITY_NAME,
    FFL.USER_FUNCTION_NAME, FFF.FUNCTION_NAME,ft.RESPONSIBILITY_NAME
    FROM
    FND_USER_RESP_GROUPS FURG,
    fnd_responsibility_tl ft ,
    FND_RESPONSIBILITY FR,
    FND_COMPILED_MENU_FUNCTIONS FCMF,
    FND_FORM_FUNCTIONS FFF,
    FND_RESPONSIBILITY_TL FRTL,
    FND_FORM_FUNCTIONS_TL FFL
    WHERE
    FURG.RESPONSIBILITY_ID = FR.RESPONSIBILITY_ID
    and ft.RESPONSIBILITY_ID(+)= fr.RESPONSIBILITY_ID
    AND FURG.RESPONSIBILITY_APPLICATION_ID = FR.APPLICATION_ID
    AND FR.MENU_ID = FCMF.MENU_ID
    AND FCMF.GRANT_FLAG = 'Y'
    AND FCMF.FUNCTION_ID = FFF.FUNCTION_ID
    AND SYSDATE BETWEEN FR.START_DATE AND NVL(FR.END_DATE, SYSDATE+1)
    and fr.CREATION_DATE >= to_date('01-jan-2005','dd-mon-yyyy')
    AND FURG.RESPONSIBILITY_ID = FRTL.RESPONSIBILITY_ID
    AND FR.RESPONSIBILITY_ID = FRTL.RESPONSIBILITY_ID
    AND FRTL.LANGUAGE = 'US'
    AND FFL.LANGUAGE = 'US'
    AND FFF.FUNCTION_ID = FFL.FUNCTION_ID
    AND (FURG.END_DATE > SYSDATE
    OR FURG.END_DATE IS NULL)
    AND FFF.FUNCTION_NAME NOT IN
    SELECT FF.FUNCTION_NAME
    FROM FND_RESPONSIBILITY R, FND_USER_RESP_GROUPS RG
    , FND_RESP_FUNCTIONS RF, FND_FORM_FUNCTIONS FF, FND_RESPONSIBILITY_TL FRTL
    WHERE RG.RESPONSIBILITY_ID = R.RESPONSIBILITY_ID
    AND RF.RESPONSIBILITY_ID = R.RESPONSIBILITY_ID
    AND RF.RULE_TYPE = 'F'
    AND FF.FUNCTION_ID = RF.ACTION_ID
    AND FRTL.RESPONSIBILITY_ID = R.RESPONSIBILITY_ID
    AND FRTL.RESPONSIBILITY_ID = RG.RESPONSIBILITY_ID
    AND FRTL.LANGUAGE = 'US'
    help me please to exclude the menus.

    tried it and had the following error:
    if((tbl_menu_id.FIRST is NULL) or (tbl_menu_id.FIRST 1)) then
    ERROR at line 136:
    ORA-06550: line 136, column 54:
    PLS-00103: Encountered the symbol "1" when expecting one of the following:
    *. ( ) , * @ % & | = - + < / > at in is mod not range rem =>*
    *.. <an exponent (**)> <> or != or ~= >= <= <> and or like*
    between ||
    The symbol "," was substituted for "1" to continue.
    from another perspective, from applications front end, when I press ctrl +L on any responsibility menu, I get the list of the forms names.
    which database tables can I get that from?

  • Need help with Math functions for text-based calculator!!!

    I have the calculator working but I am having trouble figuring out thow to do a square root function, nth factorial, absolute value, and Fibonacci. Basically i got the easy part done. Also I am using the case to do the funtions but I am not sure if there are symbols on the keyboard that are commonly used for these funtions so i just made some up. I am new to java and this is only my second assignment so any help would be appreciated. Thanks
    import java.util.*;
    import java.math.*;
    public class calculator
    static Scanner console=new Scanner(System.in);
    public static void main(String[]args)
    double num1=0,num2=0;
    double result=0;
    char expression;
    char operation;
    String Soperation;
    System.out.println("Enter ? for help or enter the operation in which to be processed");
    Soperation=console.next();
    operation = Soperation.charAt(0);
    switch(operation)
    case '+':
    System.out.println("Please the first number");
    num1=console.nextInt();
    System.out.println("Please enter the second number");
    num2=console.nextInt();
    result=num1+num2;
    break;
    case'-':
    System.out.println("Please the first number");
    num1=console.nextInt();
    System.out.println("Please enter the second number");
    num2=console.nextInt();
    result=num1-num2;
    break;
    case'*':
    System.out.println("Please the first number");
    num1=console.nextInt();
    System.out.println("Please enter the second number");
    num2=console.nextInt();
    result=num1*num2;
    break;
    case'/':
    System.out.println("Please the first number");
    num1=console.nextInt();
    System.out.println("Please enter the second number");
    num2=console.nextInt();
    if(num2==0)
    System.out.println("Cannot Divide by Zero");
    result=num1/num2;
    break;
    //square root
    case'^':
    System.out.println("Please enter a number");
    break;
    //fibonacci     
    case'#':
    System.out.println("Please enter the position of the Fibonacci number");
    break;
    //factorial
    case'!':
    System.out.println("Please enter the number for factoring");
    break;
              //absolute value
    case'&':
    System.out.println("Please enter a number");
    num1=console.nextInt();
    result=num1;
    break;
         // help funtion
    case'?':
    System.out.println("Type + for addition, - for subtraction");
    System.out.println("* for multipliction, / for division,^ for the square root");
    System.out.println(" & for absolute value, # for fibonacci,and ! for factorial");
    break;
    System.out.println("The result is:"+result);     
    }

    rmabrey wrote:
    I have the calculator working but I am having trouble figuring out thow to do a square root function, nth factorial, absolute value, and Fibonacci. java.lang.Math.sqrt()
    nothing for factorial - write your own.
    java.lang.Math.abs()
    nothing for Fibonacci - write your own.
    %

  • Need Help With a Function

    Hope this is the right place to ask.
    I have a field that looks like this: LastName, First Name Middle Name Other Name
    I need to have a Last Name field, and a First Name (and possibly other) field.
    In other words, I need to be able to pull out eveything on either side of the comma.
    I know this should be simple; just don't have the time to figure it out for myself.
    Thanks in advance.

    This will extract the last name. This formula bas based on one that looked for spaces, not commas, so you may not need the TRIM functions in there. Plus it does some other checking.
    =IFERROR(LEFT(TRIM(B2),SEARCH(",",TRIM(B2))-1),IF(ISBLANK(B2),"",TRIM(B2)))
    more basic is
    =LEFT(B2,SEARCH(",",B2)-1)

  • Need help with Timer function

    I am using a timer class for my application such that when i log in, i immediately call the timer.start function from the Timer.java class.
    The problem i am having, is that when this timer expires, it calls an exit function, but i want it to restart the original application. i have tried to create an instance of the old session to kill its timer and a new instance that spawns a new start page, but this doesnt work well because i have both applications running and if i close either one of them, both get killed!!
    Can anyone help me out in this regard?
    Sule.
    public void timeout()
            System.err.println ("terminating");        
            System.exit(1);
                         // instance.getContentPane().add(d2.new StartPage());                     
                         // instance.setVisible(true);
                         // previousInstance.timer.stop();
            }

    hey Uhrand.. thanks for your suggestions. I really appreciate them, however it doesnt completely solve my problem. As I stated before my Timer program runs in its own class file. so i have in one class file
    public class Timer extends thread {
    public static Application dl = new Application();
    public void timeout()
                          System.err.println ("Logging-Off");
            new Application();             
            dl.timer.stop();
            }and then i have another class file for the main program like this...
    import java.awt.*;
    import javax.swing.*;
    public class Application {
        public Application() {
            app = new JFrame("'Application' restarts every 15 seconds");
            app.add(new JLabel("Please watch the Title of this frame"));
            app.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            app.setBounds((screenSize.width-400)/2, (screenSize.height-150)/2, 400, 150);
            app.setVisible(true);
            (new Thread(new Timer(app))).start();
        public static void main(String args[]) {new Application();}
        private JFrame app;
        private JFrame app;
    }when the timer expires, i am not able to create a new Application without the old Application.
    I would appreciate it if you can respond.
    thanks
    salau

  • Need help with search function in my program

    Hello all, some of you may remeber me from my previous inventory programs. Well I am finally on my last one and I need to add a search option to the code. Here is the class that will contain that option.
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class Inventory2 extends JFrame implements ActionListener {
    //Utility class for displaying the picture
    //If we are going to use a class/method/variable inside that class only, we declare it private in that class
    private class MyPanel extends JPanel {
    ImageIcon image = new ImageIcon("Sample.jpg");
    int width = image.getIconWidth();
    int height = image.getIconHeight();
    long angle = 30;
    public MyPanel(){
    super();
    public void paintComponent(Graphics g){
         super.paintComponent(g);
         Graphics2D g2d = (Graphics2D)g;
         g2d.rotate (Math.toRadians(angle), 60+width/2, 60+height/2);
         g2d.drawImage(image.getImage(), 60, 60, this);
         g2d.dispose();
    }//end class MyPanel
    int currentIndex; //Currently displayed Item
    Product[] supplies = new Product[4];
    JLabel name ;
    JLabel number;
    JLabel rating;
    JLabel quantity;
    JLabel price;
    JLabel fee;
    JLabel totalValue;
    JTextField nameField = new JTextField(20);
    JTextField numberField = new JTextField(20);
    JTextField ratingField = new JTextField(20);
    JTextField quantityField = new JTextField(20);
    JTextField priceField = new JTextField(20);
    JPanel display;
    JPanel displayHolder;
    JPanel panel;
    boolean locked = false; //Notice how I've used this flag to keep the interface clean
    public Inventory2() {
    makeTheDataItems();
    setSize(700, 500);
    setTitle("Inventory Program");
    //make the panels
    display = new JPanel();
    JPanel other = new JPanel();
    other.setLayout(new GridLayout(2, 1));
    JPanel picture = new MyPanel();
    JPanel buttons = new JPanel();
    JPanel centerPanel = new JPanel();
    displayHolder = new JPanel();
    display.setLayout(new GridLayout(7, 1));
    //other.setLayout(new GridLayout(1, 1));
    //make the labels
    name = new     JLabel("Name :");
    number = new JLabel("Number :");
    rating = new JLabel("Rating     :");
    quantity = new JLabel("Quantity :");
    price = new JLabel("Price     :");
    fee = new JLabel("Restocking Fee (5%) :");
    totalValue = new JLabel("Total Value :");
    //Use the utility method to make the buttons
    JButton first = makeButton("First");
    JButton next = makeButton("Next");
    JButton previous = makeButton("Previous");
    JButton last = makeButton("Last");
    JButton search = makeButton("Search");
    //Other buttons
    JButton add = makeButton("Add");
    JButton modify = makeButton("Modify");
    JButton delete = makeButton("Delete");
    JButton save = makeButton("Save");
    JButton exit = makeButton("Exit");
    //Add the labels to the display panel
    display.add(name);
    display.add(number);
    display.add(rating);
    display.add(quantity);
    display.add(price);
    display.add(fee);
    //add the buttons to the buttonPanel
    buttons.add(first);
    buttons.add(previous);
    buttons.add(next);
    buttons.add(last);
    buttons.add(search);
    //Add the picture panel and display to the centerPanel
    displayHolder.add(display);
    centerPanel.setLayout(new GridLayout(2, 1));
    centerPanel.add(picture);
    centerPanel.add(displayHolder);
    other.add(buttons);
    JPanel forAdd = new JPanel(); // add the other buttons to this panel
    forAdd.add(add);
    forAdd.add(modify);
    forAdd.add(delete);
    forAdd.add(save);
    forAdd.add(exit);
    other.add(forAdd);
    //Add the panels to the frame
    getContentPane().add(centerPanel, "Center");
    getContentPane().add(other, "South");
    this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setVisible(true);
    private void makeTheDataItems () {
    Product p1 = new DVD("The one", 001, 200, 100, "The one");
    Product p2 = new DVD("Once upon a time in China V", 002, 500, 10000, "Once upon a time in China V");
    Product p3 = new DVD("Rat Race", 003, 100, 3000, "Rat Race");
    Product p4 = new DVD("The Man in the Iron Mask", 004, 3000, 9000, "The Man in the Iron Mask");
    supplies[0] = p1;
    supplies[1] = p2;
    supplies[2] = p3;
    supplies[3] = p4;
    //Utility method for creating and dressing buttons
    private JButton makeButton(String label) {
    JButton button = new JButton(label);
    button.setPreferredSize(new Dimension(100, 25));
    button.setActionCommand(label);
    button.addActionListener(this);
    return button;
    private void addItem() {
    panel = new JPanel();
    JPanel add = new JPanel();
    add.setLayout(new GridLayout(7, 2));
    JButton addIt = makeButton("Add Item");
    JLabel name = new JLabel("Name :");
    JLabel rating = new JLabel("Rating     :");
    JLabel quantity = new JLabel("Quantity :");
    JLabel price = new JLabel("Price     :");
    add.add(name); add.add(nameField);
    add.add(rating); add.add(ratingField);
    add.add(quantity); add.add(quantityField);
    add.add(price); add.add(priceField);
    panel.add(add);
    JPanel forAddIt = new JPanel();
    forAddIt.add(addIt);
    panel.add(forAddIt);
    displayHolder.remove(display);
    displayHolder.add(panel);
    //display = panel;
    this.setVisible(true);
    public static void main( String args[]) {
    new Inventory2().displayFirst(); //The main method should not have too much code
    } // end main method
    public void actionPerformed(ActionEvent event) {
      String command = event.getActionCommand(); //This retrieves the command that we set for the button
      //Always compare strings using the .equals method and not using ==
      if(command.equals("First")) {
       if(!locked) {
         displayFirst();
      else if(command.equals("Next")) {
       if(!locked) {
         displayNext();
      else if(command.equals("Previous")) {
       if(!locked) {
         displayPrevious();
      else if(command.equals("Last")) {
       if(!locked) {
         displayLast();
      else if(command.equals("Exit")) {
       this.dispose();
       System.exit(0);
      else if(command.equals("Add")) {
       if(!locked) {
         addItem();
         locked = true;
      else if(command.equals("Add Item")) {
       addItemToArray();
      else if(command.equals("Modify")) {
       if(!locked) {
         modify();
         locked = true;
      else if(command.equals("Update")) {
          if(!locked) {
         modifyItemInArray();
         locked = true;
      else if(command.equals("Delete")) {
       if(!locked) {
         DVD dvd = (DVD)supplies[currentIndex];
            int confirm = JOptionPane.showConfirmDialog(this, "Are you sure you want to delete item "+dvd.getItemNumber());
                if(confirm == JOptionPane.YES_OPTION) {
          removeItemAt(currentIndex);
          displayFirst();
    private void modify() {
    DVD dvd = (DVD)supplies[currentIndex];
    panel = new JPanel();
    JPanel add = new JPanel();
    add.setLayout(new GridLayout(7, 2));
    JButton update = makeButton("Update");
    JLabel number = new JLabel("Number :");
    JLabel name = new JLabel("Name :");
    JLabel rating = new JLabel("Rating     :");
    JLabel quantity = new JLabel("Quantity :");
    JLabel price = new JLabel("Price     :");
    add.add(number);
    numberField.setText(""+dvd.getItemNumber()); numberField.setEditable(false); add.add(numberField);
    add.add(name);
    nameField.setText(dvd.getItemName()); add.add(nameField);
    ratingField.setText(dvd.getRating()); ratingField.setEditable(false);
    add.add(rating); add.add(ratingField);
    add.add(quantity);
    quantityField.setText(""+dvd.getStockQuantity());
    add.add(quantityField);
    add.add(price);
    add.add(priceField); priceField.setText(""+dvd.getItemPrice());
    panel.add(add);
    JPanel forAddIt = new JPanel();
    forAddIt.add(update);
    panel.add(forAddIt);
    displayHolder.remove(display);
    displayHolder.add(panel);
    //display = panel;
          this.setVisible(true);
    private void addItemToArray() {
    Product p = new DVD(nameField.getText(), supplies.length + 1, Long.parseLong(quantityField.getText()),
    Double.parseDouble(priceField.getText()), ratingField.getText());
    //Extend size of array by one first
    Product[] ps = new Product[supplies.length + 1];
    for(int i = 0; i < ps.length-1; i++) {
    ps[i] = supplies;
    ps[supplies.length] = p;
    supplies = ps;
    displayHolder.remove(panel);
    displayHolder.add(display);
    displayLast();
    this.setVisible(false);
    this.setVisible(true);
    //Utility method to ease the typing and reuse code
    //This method reduces the number of lines of our code
    private void displayItemAt(int index) {
    DVD product = (DVD)supplies[index];
    name.setText("Item Name: "+ product.getItemName());
    number.setText("Item Number: "+ product.getItemNumber());
    rating.setText("Rating: "+ product.getRating());
    quantity.setText("Quantity In Stock: "+ product.getStockQuantity());
    price.setText("Item Price: "+ product.getItemPrice());
    totalValue.setText("Total: " + product.calculateInventoryValue());
    fee.setText("Restocking Fee (5%) :"+product.calculateRestockFee());
    locked = false;
    this.repaint();
    this.setVisible(true);
    private void modifyItemInArray() {
    Product p = new DVD(nameField.getText(), supplies.length + 1, Long.parseLong(quantityField.getText()),
    Double.parseDouble(priceField.getText()), ratingField.getText());
    supplies[currentIndex] = p;
    displayHolder.remove(panel);
    displayHolder.add(display);
         displayItemAt(currentIndex);
    this.setVisible(false);
    this.setVisible(true);
    private void removeItemAt(int index) {
    Product[] temp = new Product[supplies.length-1];
    int counter = 0;
    for(int i = 0; i < supplies.length;i++) {
    if(i == index) { //skip the item to delete
    else {
         temp[counter++] = supplies[i];
    supplies = temp;
    public void displayFirst() {
    displayItemAt(0);
    currentIndex = 0;
    public void displayNext() {
    if(currentIndex == supplies.length-1) {
    displayFirst();
    currentIndex = 0;
    else {
    displayItemAt(currentIndex + 1);
    currentIndex++;
    public void displayPrevious() {
    if(currentIndex == 0) {
    displayLast();
    currentIndex = supplies.length-1;
    else {
    displayItemAt(currentIndex - 1);
    currentIndex--;
    public void displayLast() {
    displayItemAt(supplies.length-1);
    currentIndex = supplies.length-1;
    }//end class Inventory2
    I am not sure where to put it and how to set it up. If you guys need the other two classes let me know. Thanks in advanced.

    Here are the other two classes:
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    class Product implements Comparable {
    String name;
    int number;
    long stockQuantity;
    double price;
    public Product() {
      name = "";
          number = 0;
          stockQuantity = 0L;
          price = 0.0;
    public Product(String name, int number, long stockQuantity, double price) {
      this.name = name;
          this.number = number;
          this.stockQuantity = stockQuantity;
          this.price = price;
         public void setItemName(String name) {
      this.name = name;
    public String getItemName() {
      return name;
    public void setItemNumber(int number) {
      this.number = number;
    public int getItemNumber() {
      return number;
    public void setStockQuantity(long quantity) {
      stockQuantity = quantity;
    public long getStockQuantity() {
      return stockQuantity;
    public void setItemPrice(double price) {
      this.price = price;
    public double getItemPrice() {
      return price;
    public double calculateInventoryValue() {
      return getItemPrice() * getStockQuantity();
    public int compareTo (Object o) {
      Product p = (Product)o;
      return name.compareTo(p.getItemName());
    public String toString() {
      return "Name :"+getItemName() + "\nNumber"+number+"\nPrice"+price+"\nQuantity"+stockQuantity + "\nValue :"+calculateInventoryValue();
    class DVD extends Product implements Comparable {
    private String rating;
    public DVD() {
      super(); //Call the constructor in Product
      rating = ""; //Add the additonal attribute
    public DVD(String name, int number, long stockQuantity, double price, String rating) {
      super(name, number, stockQuantity, price); //Call the constructor in Product
      this.rating = rating; //Add the additonal attribute
         public void setRating(String rating) {
      this.rating = rating;
    public String getRating() {
      return rating;
    public double calculateInventoryValue() {
      return getItemPrice() * getStockQuantity() + getItemPrice()*getStockQuantity()*0.05;
    public double calculateRestockFee() {
      return getItemPrice() * 0.05;
    public int compareTo (Object o) {
      Product p = (Product)o;
      return getItemName().compareTo(p.getItemName());
    public String toString() {
      return "Name :"+getItemName() + "\nNumber"+getItemNumber()+"\nPrice"+getItemPrice()+"\nQuantity"+getStockQuantity() +"\nRating :"+getRating()+"\nValue"+calculateInventoryValue();
    }You should be able to search through these items, and any other items that have been added to the program.

  • [solved] Need Help with bash function

    I would like to have a bash function that lets me create tar.xz archives. I have the following in my bash now:
    mktar() { tar cf "${1%%/}.tar" "${1%%/}/"; }
    mktgz() { tar czf "${1%%/}.tar.gz" "${1%%/}/"; }
    mktbz() { tar cjf "${1%%/}.tar.bz2" "${1%%/}/"; }
    Any advice would be appreciated.
    Last edited by orphius1970 (2010-09-06 11:10:39)

    orphius1970 should learn some shell scripting.
    $FILE is obviously the archive name and is $1 the first argument.
    $* would be the rest of the arguments (only so after the shift command.
    So, archive archive_name list of files to be archived.
    Example: archive stuff.tar.gz stuff/

  • Need help with INSTR function

    I am trying use INSTR and SUBSTR function to parse a variable without breaking up the variable. As you can see the problem arises negotiating the blank space,
    DECLARE
         blank_space NUMBER(2);
         full_name VARCHAR2(30) := 'Robert P. Simmons');
         first_name VARCHAR2(30);
         last_name VARCHAR2(30);
    BEGIN
         blank_space := INSTR(full_name, ' ');
         first_name := SUBSTR(full_name, 1, (blank_space -1));
         DBMS_OUTPUT.PUT_LINE( 'Your first name is ' || first_name);
         last_name := SUBSTR(full_name, (blank_space + 1),
         (LENGTH(full_name) - blank_space));               
         DBMS_OUTPUT.PUT_LINE( 'You have ' ||
         LENGTH(last_name) || ' characters in your last name!');
    END;     How can I list the number of characters in the last_name only? It just list everything to the right side of the 1st blank_space.
    Thanks

    SQL> DECLARE
      2     blank_space NUMBER(2);
      3     full_name VARCHAR2(30) := 'Robert P. Simmons';
      4     first_name VARCHAR2(30);
      5     middle_initial VARCHAR2(30);
      6     last_name VARCHAR2(30);
      7
      8  BEGIN
      9     blank_space := INSTR(full_name, ' ');
    10     first_name := SUBSTR(full_name, 1, (blank_space -1));
    11     DBMS_OUTPUT.PUT_LINE( 'Your first name is ' || first_name);
    12     middle_initial := SUBSTR(full_name, (blank_space +1), INSTR(full_name, ' ',1,2)-blank_space-1);
    13     DBMS_OUTPUT.PUT_LINE( 'Your middle initial is ' || middle_initial);
    14  last_name := SUBSTR(full_name, INSTR(full_name, ' ',1,2)+1);
    15     DBMS_OUTPUT.PUT_LINE( 'You have ' ||
    16     LENGTH(last_name) || ' characters in your last name!');
    17
    18  END;
    19  /
    Your first name is Robert
    Your middle initial is P.
    You have 7 characters in your last name!
    Procedura PL/SQL completata correttamente.Max
    http://oracleitalia.wordpress.com

  • Passwords gone crazy!? Need help with Keychain function

    I recently updated my MacBook Pro and its all of a sudden as for passwords for the "keychain" program. Usually when I start the computer I have about 30 requests. It happens while Im using it as well. Any suggestions?

    It also says a keychain cannot be found for certain items

  • Need Help with Treat Function

    Im currently studying Oracle and SQL im really stuck on this.
    if anyone could give me a hand it would be much appreciated.
    drop table Property_tab force;
    drop table Appointment_tab force;
    drop table Person_tab force;
    drop type view_list_type force;
    drop type Property_type force;
    drop type Appointment_type force;
    drop type SalesPerson_type force;
    drop type Applicant_type force;
    drop type Person_type force;
    create or replace type Person_type;
    create or replace type SalesPerson_type;
    create or replace type Applicant_type;
    create or replace type Appointment_type;
    create or replace type Property_type;
    create type View_list_type as table of ref Appointment_type;
    create type Person_type as object(
    IdNo Number,
    Surname VARCHAR(20),
    Forename VARCHAR(20),
    dateOfBirth date) NOT FINAL;
    create or replace type SalesPerson_type UNDER person_type (
    officeno Number,
    makes View_list_type);
    create type Applicant_type UNDER person_type (
    aAddressLine1 VARCHAR(30),
    aAddressLine2 VARCHAR(30),
    aTown VARCHAR(20),
    contactTel1 Number,
    contactTel2 Number,
    maxPrice Number,
    desiredArea VARCHAR(30),
    attends View_list_type);
    create or replace type Appointment_type as object (
    Appointment# Number,
    AppDate date,
    Time Number,
    appointmentType VarChar(10),
    LevelOfInterest VarChar(10),
    is_Viewed_by ref Property_type
    create type Property_type as object (
    Property# VARCHAR(30),
    dateOfRegistration Date,
    housetype VARCHAR(30),
    bedrooms Number,
    receptionRooms Number,
    bathrooms Number,
    garage Number,
    garden Number,
    regionArea VarChar(30),
    pAddressLine1 VarChar(30),
    pAddressLine2 VarChar(30),
    pCode VarChar(7),
    price INTEGER,
    relatesto View_list_type
    create table Person_tab of Person_type (
    IdNo primary key NOT NULL);
    create table Property_tab of Property_type
    nested table relatesto store as view_Appointment_table;
    create table Appointment_tab of Appointment_type (
    scope for (is_Viewed_by) is Property_tab);
    insert into Property_tab
    values (1,'18-sep-09', 'Detatched', 4, 1, 2, 1, 2, 'Wales', '42 Spooner St', 'Bridgend', 'CF347LS', 120000, View_list_type());
    insert into Property_tab
    values (2,'21-oct-10', 'Semi-Detatched', 4, 1, 2, 1, 2, 'Wales', '44 Spooner St', 'Bridgend', 'CF348LS', 200000, View_list_type());
    insert into Property_tab
    values (3,'1-dec-09', 'Detatched', 4, 1, 2, 1, 2, 'Wales', '42 Roath St', 'Cardiff', 'CF407RQ', 125000, View_list_type());
    INSERT INTO person_tab VALUES (SalesPerson_type(123, 'Steve', 'Jones', '12-JAN-76', 401, View_list_type()));
    INSERT INTO person_tab VALUES (SalesPerson_type(234, 'Brian', 'Williams', '18-oct-85', 401, View_list_type()));
    INSERT INTO person_tab VALUES (SalesPerson_type(345, 'John', 'Johnson', '11-FEB-75', 402, View_list_type()));
    INSERT INTO person_tab VALUES (SalesPerson_type(456, 'Mike', 'Adams', '2-DEC-81', 402, View_list_type()));
    INSERT INTO person_tab VALUES (Applicant_type(111, 'Marie', 'Michaels', '16-DEC-81', '12 Merthyr RD', 'Mid Glam','Bridgend', 0165666123, 0780089623, 250000, 'Bridgend', View_list_type()));
    underneath doesnt work this is what im stuck on
    INSERT INTO Appointment_tab
    SELECT 1,'12-JAN-12', 1203,'Viewing', 'HIGH'
    Treat (REF (C) AS REF Person_type),
    Treat (REF (D) AS REF Person_type),
    REF (E),
    FROM Person_tab C, Person_tab D, Property_tab E
    WHERE Treat (Value (C) AS Person_type).IdNo = 123 AND
    Treat (value (D) AS Person_type).IdNo = 111 AND
    E.Property_type.Property# = 1;

    I would always restrict O-R to your view and packages interfaces.
    It's normally a good idea to stick to orthodox relational modelling when it comes to the table design.
    Is this what you're after?
    SQL> INSERT INTO Appointment_tab
      2  SELECT Appointment_type(
      3        1
      4  ,     TO_DATE('12-JAN-12','DD-MON-RR')
      5  ,     1203
      6  ,     'Viewing'
      7  ,    'HIGH'
      8  ,     REF (E))
      9  FROM  Person_tab C
    10  ,     Person_tab D
    11  ,     Property_tab E
    12  WHERE Treat (Value (C) AS Person_type).IdNo = 123
    13  AND   Treat (value (D) AS Person_type).IdNo = 111
    14  AND   Treat (Value(E) AS Property_type).Property# = 1;
    1 row created.
    Elapsed: 00:00:00.03
    SQL>
    SQL> select * from appointment_tab;
    APPOINTMENT# APPDATE         TIME APPOINTMEN LEVELOFINT
    IS_VIEWED_BY
               1 12-JAN-12       1203 Viewing    HIGH
    0000220208B41108491D309848E040440A5B681B61B41108491D2E9848E040440A5B681B61There must be some mistake somewhere as your appointment type does not have any person/applicant/sales_person attributes (so there's no point in selecting them under the current definition).
    Edited by: Dom Brooks on Dec 15, 2011 4:40 PM

Maybe you are looking for

  • 2LIS_04_P_MATNR - Prob in activating the Datasource in R/3

    Hello, I am trying to activate datasource 2LIS_04_P_MATNR in r/3 in Tcode : rsa6/rsa5  and I am getting a warning that says The even-numbered length of the DEC field I_DLZ_EX can lead to problems I serached and found that note : 641744 is applicable.

  • Adobe AIR 1.5 - Package AIR installer as a native Windows Executable (.EXE)

    Hello Adobe AIR community, Is there any way to package the installer for an Adobe AIR application using Adobe AIR 1.5 as an executable (.EXE) file? I found that this is possible for Adobe AIR 2.0, but it requires an upgrade to Adobe AIR 2.0 runtime.

  • Web fault reporting doesn't work

    My phone line was tested and it came back as working but it isn't. I have removed all extensions and tested with 2 different phones at the master socket and a fault still occurs. The line works after a fashion but doesn't ring properly and also somet

  • My iPod could not be restored

    The other day my iPod stopped working. I went to turn it on the screen flashed white several times and I ended up with it asking me to connect it to iTunes. I connected it to iTunes and it said that my iPod could not be restored (40) I've done all of

  • Mac Mini DVD issues with 3rd party player software

    New to the forum. I have a Late 2012 Mac Mini with 16GB RAM and 256 SSD (Crucial) fitted and the latest version Yosemite OS. I get a slight jerkiness when playing DVDs from an external Panasonic UJ265 USB3 Blu-ray drive using either Aurora or Macgo s