Problems with switch statement

He everyone,
i tried to built a page with 4 buttons. Each button is a symbol that contains 2 png´2 which are the the button Designs. If you click on  button 1 it should move on the screen. If you click it again it should moves back. and if you click on another button while button1 is active then button1 should move back to starting position and button 2 should move on screen.
i use a switch statement and a variable.
on composition ready i used
sym.setVariable("current","");
to set the Variable
on each button(one of the png inside the symbols) i used:
var current = sym.getComposition.getStage.getVariable("current");
switch (current)
case "" :
sym.play("in");
break;
case button1 :
sym.play("out");
break;
default :
sym.getComposition.getStage.getSymbol(current).play("out");
sym.play("in");
break;
ad each animation of the buttons are labels for the in and out animation. There are also triggers that change the variable current on the stage
sym.getComposition.getStage.setVariable("current","button1");
if i test it inside of a browser and click on one of the button nothing happens.
i´m not sure what´s my mistake.
can anyone help me?
regards
mr.monsen

Hi,
Some syntax errors in red:
var current = sym.getComposition().getStage().getVariable("current");
switch (current)
case "" :
sym.play("in");
break;
case "button1" :
sym.play("out");
break;
default :
sym.getComposition().getStage().getSymbol(current).play("out");
sym.play("in");
sym.getComposition().getStage().setVariable("current","button1");

Similar Messages

  • Problem with switch-statement & ä, ö, ü

    Hi all,
    I am doing this Java online tutorial right now and have a problem with one of the exercises. Hopefully you can help me:
    I have to write a program that determines the number of consonants, vowels, punctuation characters, and spaces in an input line. I found a solution, but have two questions about it:
    •     I’m unable to calculate the amount of umlauts (ä, ö, ü). Somehow the program doesn’t recognize those characters. Why?
    •     In general I’m not very happy with this huge list of “cases”. How would you solve a problem like this? Is there a more convenient/elegant way?
    Thanks in advance!
    Write a program that determines the number of consonants, vowels, punctuation characters, and spaces in an input line.
    Read in the line into a String (in the usual way). Now use the charAt() method in a loop to access the characters one by one.
    Use a switch statement to increment the appropriate variables based on the current character. After processing the line, print out
    the results.
    import java.util.Scanner;
    class Kap43A1
      public static void main ( String[] args )
        String line;
        char letter;
        int total, countV=0, countC=0, countS=0, countU=0, countP=0;
        Scanner scan = new Scanner(System.in);
        System.out.println( "Please write a sentence " );
        line = scan.nextLine();
        total=line.length(); //Gesamtanzahl an Zeichen des Satzes
        for (int counter=0; counter<total; counter++)
          letter = line.charAt(counter); //ermitteln des Buchstabens an einer bestimmten Position des Satzes
          switch (letter)
            case 'A': case 'a':
            case 'E': case 'e':
            case 'I': case 'i':
            case 'O': case 'o':
            case 'U': case 'u':
              countV++;
              break;
            case 'B': case 'b': case 'C': case 'c': case 'D': case 'd': case 'F': case 'f': case 'G': case 'g': case 'H': case 'h':
            case 'J': case 'j': case 'K': case 'k': case 'L': case 'l': case 'M': case 'm': case 'N': case 'n': case 'P': case 'p':
            case 'Q': case 'q': case 'R': case 'r': case 'S': case 's': case 'T': case 't': case 'V': case 'v': case 'W': case 'w':
            case 'X': case 'x': case 'Y': case 'y': case 'Z': case 'z':
              countC++;
              break;
            case ' ':
              countS++;
              break;
            case ',': case '.': case ':': case '!': case '?':
              countP++;
              break;
            case 'Ä': case 'ä': case 'Ö': case 'ö': case 'Ü': case 'ü':
              countU++;
              break;
        System.out.println( "Total amount of characters:\t" + total );
        System.out.println( "Number of consonants:\t\t" + countC );
        System.out.println( "Number of vocals:\t\t" + countV );
        System.out.println( "Number of umlauts:\t\t" + countU );
        System.out.println( "Number of spaces:\t\t" + countS );
        System.out.println( "Number of punctuation chars:\t" + countP );
    }

    WRE wrote:
    •In general I’m not very happy with this huge list of “cases”. How would you solve a problem like this? Is there a more convenient/elegant way?I've been doing this a lot lately myself evaluating documents with 20 or so million words. Few tips:
    1. Regular expressions can vastly reduce the list of cases. For example you can capture all letters from a to z or A to Z as follows [a-zA-Z]. To match a single character in a String you can then make use of the Pattern and Matcher classes, and incorporate the regular expression. e.g.
      //Un-compiled code, may contain errors.
      private Pattern letterPattern = Pattern.compile("[a-zA-Z]");
      public int countNumberOfLettersInString(final String string) {
        int count = 0;
        Matcher letterMatcher = letterPattern.matcher(string);
        while(letterMatcher.find()) {
          count++;
        return count;
      }2. As mentioned above, Sets are an excellent choice. Simply declare a static variable and instantiate it using a static initializer block. Then loop over the String to determine if the character is in the given set. e.g.
      //Un-compiled code, may contain errors.
      private static Set<Character> macrons = new HashSet<Character>();
      static {
        macrons.add('ä');
        macrons.add('ö');
        macrons.add('ü');
      public int countNumberOfMacronsInString(final String string) {
        int count = 0;
        for(char c : string.toCharArray()) {
          if(macrons.contains(c) {
            count++;
        return count;
      }Mel

  • Problem with switch statement

    Here's my dilemma,
    I'm trying to write a program that takes a user input ZIP Code and then outputs the geographical area associated with that code based on the first number. My knowledge of Java is very, very basic but I was thinking that I could do it with the charAt method. I can get the input fine and isolate the the first character but for some reason the charAt method is returning a number like 55 (that's what I get when it starts with 7). Additionally, to use the charAt my input has to be a String and I can't use a String with the switch statement. To use my input with the Switch statement I have to make the variable an int. When I do that however, I can't use the charAt method to grab the first digit. I'm really frustrated and hope someone can point me in the right direction.
    Here's what I have so far:
    import java.util.Scanner;
    public class ZipCode
         public static void main(String[] args)
              // Get ZIP Code
              int zipCodeInput;
              Scanner stdIn = new Scanner(System.in);
              System.out.print("Please enter a ZIP Code: ");
              zipCodeInput = stdIn.nextInt();
              // Determine area of residence
              switch (zipCodeInput)
                   case 0: case 2: case 3:
                        System.out.println(zipCodeInput + " is on the East Coast");
                        break;
                   case 4: case 5: case 6:
                        System.out.println(zipCodeInput + " is in the Central Plains area");
                        break;
                   case 7:
                        System.out.println(zipCodeInput + " is in the South");
                        break;
                   case 8: case 9:
                        System.out.println(zipCodeInput + " is int he West");
                        break;
                   default:
                        System.out.println(zipCodeInput + " is an invalid ZIP Code");
                        break;
    }

    Fmwood123 wrote:
    Alright, I've successfully isolated the first number in the zip code by changing int zipCodeChar1 into char zipCodeChar1. Now however, when I try to run that through the switch I get the default message of <ZIP> is an invalid ZIP Code. I know that you said above that switch statements were bad so assume this is purely academic at this point. I'd just like to know why it's not working.
    import java.util.Scanner;
    public class ZipCode
         public static void main(String[] args)
              // Get ZIP Code
              String zipCodeInput;
              char zipCodeChar1;
              Scanner stdIn = new Scanner(System.in);
              System.out.print("Please enter a ZIP Code: "); // Input of 31093
              zipCodeInput = stdIn.nextLine();
              System.out.println("zipCodeInput is: " + zipCodeInput); // Retuns 31093
              zipCodeChar1 = zipCodeInput.charAt(0);
              System.out.println("zipCodeChar1 is: " + zipCodeChar1); // Returns 3
              // Determine area of residence
              switch (zipCodeChar1)
                   case 0: case 2: case 3:
                        System.out.println(zipCodeInput + " is on the East Coast");
                        break;
                   case 4: case 5: case 6:
                        System.out.println(zipCodeInput + " is in the Central Plains area");
                        break;
                   case 7:
                        System.out.println(zipCodeInput + " is in the South");
                        break;
                   case 8: case 9:
                        System.out.println(zipCodeInput + " is int he West");
                        break;
                   default:
                        System.out.println(zipCodeInput + " is an invalid ZIP Code");
                        break;
    When you print the char '7' as a character you will see the character '7', but char is really a numeric type: think of it as unsigned short. To convert '0'...'9' to the numbers 0...9, do the math:
    char ch = ...
    int digit = ch - '0';edit: or give your cases in terms of char literals:
    case '0': case '2': case '3':

  • Having problem with switch statement..please help

    here my question :
    GUI-based Pay Calculator
    A company pays its employees as executives (who receive a fixed weekly salary) and hourly workers (who receive a fixed hourly salary for the first 40 hours they work in a week, and 1.5 times their hourly wage for overtime worked).
    Each category of employee has its own paycode :
    ?     Paycode 1 for executives
    ?     Paycode 2 for hourly workers
    Write a GUI-based application to compute the weekly pay for each employee. Use switch to compute each employee?s pay based on that employee?s paycode.
    Use CardLayout layout manager to display appropriate GUI components. Obtain the employee name, employee paycode and other necessary facts from the user to calculate the employee?s pay based on the employee paycode:
    ?     For paycode 1, obtain the weekly salary.
    ?     For paycode 2, obtain the hourly salary and the number of hours worked.
    You may obtain other information which you think is necessary from the user.
    Use suitable classes for the GUI elements. (You can use javax.swing package or java.awt package for the GUI elements.)
    here my code so far :
    import java.awt.;*
    import java.awt.event.;*
    import javax.swing.;*
    *public class PayrollSystem implements ItemListener {*
    JPanel cards, JTextField, textField1, JLabel, label1;
    final static String EXECUTIVEPANEL = "1.EXECUTIVE";
    final static String HOURLYPANEL = "2.HOURLY WORKER";
    public void addComponentToPane(Container pane)
    *//Put the JComboBox in a JPanel to get a nicer look.*
    JPanel comboBoxPane = new JPanel(); //use FlowLayout
    JPanel userNameAndPasswordPane = new JPanel();
    *// User Name JLabel and JTextField*
    userNameAndPasswordPane.add(new JLabel("NAME"));
    JTextField textField1 = new JTextField(25);
    userNameAndPasswordPane.add(textField1);
    *String comboBoxItems[] = { EXECUTIVEPANEL, HOURLYPANEL };*
    JComboBox cb = new JComboBox(comboBoxItems);
    cb.setEditable(false);
    cb.addItemListener(this);
    comboBoxPane.add(cb);
    *//Create the "cards".*
    JPanel card1 = new JPanel();
    card1.add(new JLabel("WEEKLY SALARY"));
    card1.add(new JTextField(6));
    card1.add(new JLabel("TOTAL PAY"));
    card1.add(new JTextField(8));
    card1.add(new JButton("CALCULATE"));
    JPanel card2 = new JPanel();
    card2.add(new JLabel("HOURLY SALARY"));
    card2.add(new JTextField(6));
    card2.add(new JLabel("TOTAL HOURS WORK"));
    card2.add(new JTextField(8));
    card2.add(new JButton("CALCULATE"));
    *//Create the panel that contains the "cards".*
    cards= new JPanel(new CardLayout());
    cards.add(card1, EXECUTIVEPANEL);
    cards.add(card2, HOURLYPANEL);
    pane.add(comboBoxPane, BorderLayout.PAGE_START);
    pane.add(userNameAndPasswordPane, BorderLayout.CENTER);
    pane.add(cards, BorderLayout.PAGE_END);
    public void itemStateChanged(ItemEvent evt)
    CardLayout cl = (CardLayout)(cards.getLayout());
    cl.show(cards, (String)evt.getItem());
    ** GUI created*
    *private static void createAndShowGUI() {*
    *//Make sure we have nice window decorations.*
    JFrame.setDefaultLookAndFeelDecorated(true);
    *//Create and set up the window.*
    JFrame frame = new JFrame("GUI PAY CALCULATOR");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    *//Create and set up the content pane.*
    PayrollSystem demo = new PayrollSystem();
    demo.addComponentToPane(frame.getContentPane());
    *//Display the window.*
    frame.pack();
    frame.setVisible(true);
    *public static void main(String[] args) {*
    *//Schedule a job for the event-dispatching thread:*
    *//creating and showing this application's GUI.*
    *javax.swing.SwingUtilities.invokeLater(new Runnable() {*
    *public void run() {*
    createAndShowGUI();
    HOW CAN I PERFORM THE SWITCH STATEMENT INSIDE THIS CODE TO LET IT FULLY FUNCTIONAL..?
    I MUST PERFORM THE SWITCH STATEMENT LIKE IN THE QUESTION..
    PLEASE HELP ME..REALLY APPRECIATED...TQ

    hi
    A switch works with the byte, short, char, and int primitive data types. So you can simply give the
    switch (month) {
                case 1: 
                            System.out.println("January");
                            break;
                case 2:  {
                            System.out.println("February");
                             break;
                case 3: {
                              System.out.println("March");
                              break;
                             }where month controlls the flow
    moreover u can go to http://www.java-samples.com/java/free_calculator_application_in_java.htm
    for reference, just replace the if statement with switch with correct syntax

  • Problem with switching states

    Hello,
    I am currently experiencing a problem in flex 4. I have a main container that was built with catalyst, and now I am adding modules to the application. The main container has about 20 states, and each state displays a different module. At the bottom of the container is are multiple custom components, and its sole purpose is to navigate through each individual state of the main container.. We also have a logout button at the top of the container, which returns the user to the first state of the app, this logout is just a richtext component, which has a click handler. All the click handler does is
    currentState='firstState';
    This works logout text, works until I reach a certain point as the user app(as the user drills further down into the app)
    Example:
    //Each state is a state in the container
    State 1-> State 2-> State 3-> State 4->
    At state 4 the application will spit this stack out in the flash player debugger..
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at flashx.textLayout.factory::TextFlowTextLineFactory/createTextLines()[C:\Vellum\branches\v 1\1.0\dev\output\openSource\textLayout\src\flashx\textLayout\factory\TextFlowTextLineFacto ry.as:109]
        at spark.components::RichText/createTextLines()[E:\dev\4.0.0\frameworks\projects\spark\src\s park\components\RichText.as:1279]
        at spark.components::RichText/http://www.adobe.com/2006/flex/mx/internal::composeTextLines()[E:\dev\4.0.0\frameworks\pro jects\spark\src\spark\components\RichText.as:1170]
        at spark.components.supportClasses::TextBase/updateDisplayList()[E:\dev\4.0.0\frameworks\pro jects\spark\src\spark\components\supportClasses\TextBase.as:684]
        at spark.components::RichText/updateDisplayList()[E:\dev\4.0.0\frameworks\projects\spark\src \spark\components\RichText.as:1128]
        at mx.core::UIComponent/validateDisplayList()[E:\dev\4.0.0\frameworks\projects\framework\src \mx\core\UIComponent.as:8531]
        at mx.managers::LayoutManager/validateDisplayList()[E:\dev\4.0.0\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:663]
        at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:736]
        at mx.managers::LayoutManager/validateNow()[E:\dev\4.0.0\frameworks\projects\framework\src\m x\managers\LayoutManager.as:795]
        at mx.core::UIComponent/commitCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\ mx\core\UIComponent.as:9822]
        at mx.core::UIComponent/setCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\ core\UIComponent.as:9701]
        at mx.core::UIComponent/set currentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:6087 ]
        at Main/logout_Link_clickHandler()[C:\development\Main.mxml:47]
        at Main/___Main_Logout_LinkCustomComponent1_click()[C:\development\src\Main.mxml:1903]

    Please post in the DPS foum.
    http://forums.adobe.com/community/dps
    Bob

  • Problem with READ Statement in the field routine of the Transformation

    Hi,
    I have problem with read statement with binary search in the field routine of the transformation.
    read statement is working well when i was checked in the debugging mode, it's not working properly for the bulk load in the background. below are the steps i have implemented in my requirement.
    1. I selected the record from the lookuo DSO into one internal table for all entried in source_packeage.
    2.i have read same internal table in the field routine for each source_package entry and i am setting the flag for that field .
    Code in the start routine
    select source accno end_dt acctp from zcam_o11
    into table it_zcam
    for all entries in source_package
    where source = source_package-source
         and accno = source_package-accno.
    if sy-subrc = 0.
    delete it_zcam where acctp <> 3.
    delete it_zcam where end_dt initial.
    sort it_zcam by surce accno.
    endif.
    field routine code:
    read table it_zcam with key source = source_package-source
                                                 accno  = source_package-accno
                                                 binary search
                                                 transportin no fields.
    if sy-subrc = 0.
    RESULT  = 'Y'.
    else.
    RESULT = 'N'.
    endif.
    this piece of code exist in the other model there its working fine.when comes to my code it's not working properly, but when i debug the transformation it's working fine for those accno.
    the problem is when i do full load the code is not working properly and populating the wrong value in the RESULT field.
    this field i am using in the report filter.
    please let me know if anybody has the soluton or reason for this strage behaviour.
    thanks,
    Rahim.

    i suppose the below is not the actual code. active table of dso would be /bic/azcam_o1100...
    1. is the key of zcam_o11 source and accno ?
    2. you need to get the sortout of if endif (see code below)
    select source accno end_dt acctp from zcam_o11
    into table it_zcam
    for all entries in source_package
    where source = source_package-source
    and accno = source_package-accno.
    if sy-subrc = 0.
    delete it_zcam where acctp 3.
    delete it_zcam where end_dt initial.
    endif.
    sort it_zcam by surce accno.
    field routine code:
    read table it_zcam with key source = source_package-source
    accno = source_package-accno
    binary search
    transportin no fields.
    if sy-subrc = 0.
    RESULT = 'Y'.
    else.
    RESULT = 'N'.
    endif.

  • Problem with switch

    Hi,
    I have a problem using switch statement.
    I have a class named Resources in which I declare all the final variables.
    I have created an instance of Resources named res in the main class.
    But I cannot use the final variables in the main class in the following way:
    switch (a) {            //a is int
       case res.LEFT:       //LEFT is a final int variable in Resources     //PROBLEM
          //do something
       break;
    }The compiler complained: Constant expression required
    What is the matter?
    Thank you.
    Nelson

    Here is how the Resources class looks like:
    public class Resources {
      public final int LEFT = 0, RIGHT = 1;
    }In my main class, I just used the following to create the object:
    private Resources res = new Resources();

  • Problem with switching tabs in top level navigation for Roles

    Hi,
    I've created two tabs (based on two roles) in the portal top level navigation menu. When clicking the first one it opens as it should. Then when clicking on the second tab it will not open, instead the first tab open up again, it sort of switches back automatically.These  two roles  are  basically consists of worksets and iviews(accessing to r/3).
    Does anyone have any expericene with this type of problem?
    please  suggest me
    Thanks
    Aravinda

    Hi Aravinda
    Please check this link
    Re: Problem with switching tabs in top level navigation
    Regards
    Geogi

  • Cp1700 - Any problems with switching existing printer with stored printer?

    I am having problems reading the LCD panel for my cp1700 (not all the text shows - common problem). I have another cp1700 that I have had stored for about 5 years (saving for parts. I think this "stored" printer squeaked when printing). I considered switching the LCD panels but it looks as if this is a complicated procedure. So I am wondering if I will encounter any problems with switching the printers? I will be putting in new ink cartridges but wondering if the printheads will cause a problem after being stored for so long?

    This don't completely resolve your concerns, but I've had no trouble printing from OS X 10.7 to an Epson Artisan 810 connected to a Mac running OS X 10.6.8.  I may even have been able to print to it wirelessly, but I can't remember.  Apple issued an update to the Epson printer drivers fairly recently, which one would hope would have addressed any issues.  In any case, I'd make a bootable clone of your Mac before you upgrade.  If things aren't as you hope, then you can restore the clone to your main disk drive and be back with OS X 10.6.

  • Help with Switch statements using Enums?

    Hello, i need help with writing switch statements involving enums. Researched a lot but still cant find desired answer so going to ask here. Ok i'll cut story short.
    Im writing a calculator program. The main problem is writing code for controlling the engine of calculator which sequences of sum actions.
    I have enum class on itself. Atm i think thats ok. I have another class - the engine which does the work.
    I planned to have a switch statement which takes in parameter of a string n. This string n is received from the user interface when users press a button say; "1 + 2 = " which each time n should be "1", "+", "2" and "=" respectively.
    My algorithm would be as follows checking if its a operator(+) a case carry out adding etc.. each case producing its own task. ( I know i can do it with many simple if..else but that is bad programming technique hence im not going down that route) So here the problem arises - i cant get the switch to successfully complete its task... How about look at my code to understand it better.
    I have posted below all the relevant code i got so far, not including the swing codes because they are not needed here...
    ValidOperators v;
    public Calculator_Engine(ValidOperators v){
              stack = new Stack(20);
              //The creation of the stack...
              this.v = v;          
    public void main_Engine(String n){
           ValidOperators v = ValidOperators.numbers;
                    *vo = vo.valueOf(n);*
         switch(v){
         case Add: add();  break;
         case Sub: sub(); break;
         case Mul: Mul(); break;
         case Div: Div(); break;
         case Eq:sum = stack.sPop(); System.out.println("Sum= " + sum);
         default: double number = Integer.parseInt(n);
                       numberPressed(number);
                       break;
                      //default meaning its number so pass it to a method to do a job
    public enum ValidOperators {
         Add("+"), Sub("-"), Mul("X"), Div("/"),
         Eq("="), Numbers("?"); }
         Notes*
    It gives out error: "No enum const class ValidOperators.+" when i press button +.
    It has nothing to do with listeners as it highlighted the error is coming from the line:switch(v){
    I think i know where the problem is.. the line "vo = vo.valueOf(n);"
    This line gets the string and store the enum as that value instead of Add, Sub etc... So how would i solve the problem?
    But.. I dont know how to fix it. ANy help would be good
    Need more info please ask!
    Thanks in advance.

    demo:
    import java.util.*;
    public class EnumExample {
        enum E {
            STAR("*"), HASH("#");
            private String symbol;
            private static Map<String, E> map = new HashMap<String, E>();
            static {
                put(STAR);
                put(HASH);
            public String getSymbol() {
                return symbol;
            private E(String symbol) {
                this.symbol = symbol;
            private static void put(E e) {
                map.put(e.getSymbol(), e);
            public static E parse(String symbol) {
                return map.get(symbol);
        public static void main(String[] args) {
            System.out.println(E.valueOf("STAR")); //succeeds
            System.out.println(E.parse("*")); //succeeds
            System.out.println(E.parse("STAR")); //fails: null
            System.out.println(E.valueOf("*")); //fails: IllegalArgumentException
    }

  • Having problem with switching it on

    please am having problem with my iphone 4_the apple logo turning on and off when connected  to my laptop.
    I can't switch it on when disconnected from ma laptop

    Perhaps your battery is bad.
    Have you had problems with decreasing battery life in the past?

  • Problem with PIVOT statement and ORA-56901

    Hi,
    I am having a problem with PIVOT in Oracle.
    I have a view in an oracle 11g database
    that returns me data in the format:- (... indicates left out text)
    DefinitionID ... AttributeValue FieldID
    ============ ============== =======
    ... 3000 X30a9...
    ... JohnN X4674...
    I am then trying to use a PIVOT statement to hopefully give me data
    in the format
    COLUMN1 COLUMN2
    ======= =======
    JohnN 3000
    The PIVOT statement I am trying is
    SELECT X4674... AS Column1,
    X30A9... AS COLUMN2
    FROM (SELECT instanceid, definitionid, attributevalue, FIELDID
    FROM PI_ENTITY_INSTANCE_VIEW) up PIVOT (MAX(ATTRIBUTEVALUE)
    FOR FIELDID IN (X4674...,X30A9... ) )
    where definitionid = hextoraw('7353C67A56C74B5A8234CD16064399E8')
    I have used a very similar VIEW and PIVOT statement for sql server
    (with necessary changes for Oracle applied) and the
    data returns in SQL Server as expected.
    Unfortunately I am getting the Oracle error
    ORA-56901: non-constant expression is not allowed for pivot|unpivot values
    Is there anyway to get a PIVOT working on Oracle where I use the
    fieldid's like I do above or is there some other way to supply the vales to the
    IN clause to overcome this error?
    Thank you for any help you can provide
    John Nugent

    Hi, John,
    Welcome to the forum!
    X4674, X30A9 and os on are the literal values that you're looking for, right?
    In Oracle, string literals need to be enclosed in single-quotes, like this:
    FOR FIELDID IN ('X4674', 'X30A9') You might find it more convenient to assign column aliases in the PIVOT clause, like this:
    PIVOT   (     MAX (attributevalue)
         FOR     fieldid       IN ( 'X4674'     AS column1
                        , 'X30A9'     AS column2
         ) Remember that anything inside quotes is case-sensitive, so 'X30A9' is not equal to 'X30a9'. Use UPPER (or LOWER) to do case-insensitive string comparisons.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, 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 use commonly available tables (such as those in the scott or hr schemas) to show your problem, then you don't have to post any sample data; just the results and explanation.
    Always say which version of Oracle you're using. You did say you were using Oracle 11g, but there's no 11f or 11h, and sometimes the difference between, say 11.1 and 11.2 can be significant. Why not say exactly what you're using, e.g. 11.1.0.7.0?
    You'll get better answers faster if you always supply this information whenever you post a question.
    Edited by: Frank Kulash on Sep 22, 2011 2:09 PM
    Added allliterative alias alternative
    Edited by: Frank Kulash on Sep 22, 2011 4:04 PM

  • Portg R600-11B - Problems with switching displays

    Hi,
    I've a problem with a Portg R600-11B running Windows 7 64bit.
    The computer is nomally plugged in a docking station that is connected with a DVI monitor. Here I can select with <FN> + <F5> between the different display modi "internal" / "internal" + "DVI" / "DVI".
    When I unplug the computer from the docking station and connect it to a beamer via VGA I can't switch the display. I only get "internal". Only after a system-reboot <FN> + <F5> works with an external VGA monitor.
    When switching back to the docking station with the DVI monitor it's the same: I only get the internal display. Only after a system-reboot <FN> + <F5> works.
    What can I do? I have the latest Microsoft Updates for Windows and Office (2003) and the latest "Value added package" from the download page installed.
    Regards,
    Axel Martin

    Try updating:
    * BIOS
    * Display Driver
    * Mobile Extensions / TVAP
    Go to the Toshiba website to download these files.

  • Emergency: problem with update statement!

    hello guys, i have a very serious problem with an update statement in pl/sql.
    i had an application written in sybase, where i had the following update statement:
    update mis_dik_adeia
    set trexon_etos_days = days_per_year
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_dik_adeia.adeia_id between :aapo and :aews
    and mis_dik_adeia.employee_id = :erg
    and mis_dik_adeia.etos = :etos
    and mis_plafon_adeivn.years_yphr = ( select max( a.years_yphr ) from mis_plafon_adeivn a where a.adeia_id = mis_plafon_adeivn.adeia_id and a.years_yphr <= :eth ) using sqlca;
    This is working properly in sybase. When i copied this code in pl/sql it displayed me error and it's impossible to work. Then i thought to make a nested select statement like this:
    update mis_dik_adeia
    set trexon_etos_days = (select days_per_year
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and mis_plafon_adeivn.years_yphr = (
    select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth )
    but as you can understand, it is working, but it doesn't produce the same results as the update statement in Sybase!
    It is very important for me to solve this problem , which is a very big trouble for me for a long time.
    Please if anyone can help me i would appreciate it a lot!
    Regards ,
    Bill...

    Bill,
    folowing the logic of your original query by Sybase
    (it's embedded SQL in Power Builder, isn't it ?):
    update mis_dik_adeia
    set trexon_etos_days = (select days_per_year
    from mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_plafon_adeivn.years_yphr = (
    select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth )
    where
    mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and
    exists (select 1
    from mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_plafon_adeivn.years_yphr = (
    select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth )
    In 9i you can also try the following:
    megre into mis_dik_adeia
    using (
    select
    days_per_year,
    mis_dik_adeia.rowid rid
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and mis_plafon_adeivn.years_yphr =
    (select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth)
    ) src
    on (mis_dik_adeia.rowid = src.rid)
    when matched then
    update set mis_dik_adeia.trexon_etos_days = src.days_per_year
    when not matched then
    insert (mis_dik_adeia.adeia_id) values(0);
    In 10G it can be easily:
    megre into mis_dik_adeia
    using (
    select
    days_per_year,
    mis_dik_adeia.rowid rid
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and mis_plafon_adeivn.years_yphr =
    (select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth)
    ) src
    on (mis_dik_adeia.rowid = src.rid)
    when matched then
    update set mis_dik_adeia.trexon_etos_days = src.days_per_year;
    I have to notice I didn't check it carefully, so I can miss...
    Rgds.
    Corrected a mistake in the table name
    Message was edited by:
    dnikiforov

  • Problem with Decode statement

    Hi
    I am trying to achieve the following in my report:
    If an employee has a surname of . (dot) or a first name of . (dot), the report should not display a dot. An employee's name is made up of surname, first name and middle name which should all be concatenated together. To try to achieve this, I have the following statement in my report:
    decode(e.Surname, '.', ( LTRIM(RTRIM((INITCAP(e.FIRST_NAME)))||' '||INITCAP(e.MIDDLE_NAME)) ) ,
    e.FIRST_NAME, '.', ( LTRIM(RTRIM((INITCAP(e.Surname)))||' '||INITCAP(e.MIDDLE_NAME)) ) ,
    ( LTRIM(RTRIM((INITCAP(e.SURNAME )))||', '||INITCAP(e.FIRST_NAME)||' '||INITCAP(e.MIDDLE_NAME)) ) ) as emp_name
    FROM Employee e
    Problem: The above statement is only working for those employees with surname of . (dot). It's not working for first names of dot. How can I use the decode statement OR is there any other way of doing it without using the CASE statement?
    It seems my decode statement doesn't work with 2 different fields (surname, firstname) being tested within one decode statement.Thanks.

    Thank you so much InoL . I have used the ltrim with Replace but now have a new problem.
    Because I am joining Surname, First name and middle name together and put a comma after the Surname, the name now appears as follows:
    , Maria Ane (if Surname is a dot)
    Boiler, (if first name is a dot)
    I would like to get rid of a comma and only have comma when surname or first name does not have a dot, i.e. for those people with full names e.g. Blake, Anna Marie.
    InoL, how can I achieve this? Thanks.

Maybe you are looking for