Problem with Case statement

I friends,
I am using a case statement for a number field like this
case when (customer_no is null or customer_no ='') then t.customer_no else gv.customer_no end as customer_no
When i complie this i get an errror ORa-00932 inconsistent data types expected char got number....
when i remove the case statement the query runs fine so i am sure its the case statement thats wrong here..Am i checking it the wrong way...
Thank you in advance

874167 wrote:
I friends,
I am using a case statement for a number field like this
case when (customer_no is null or customer_no ='') then t.customer_no else gv.customer_no end as customer_no
When i complie this i get an errror ORa-00932 inconsistent data types expected char got number....
when i remove the case statement the query runs fine so i am sure its the case statement thats wrong here..Am i checking it the wrong way...
Thank you in advancewith Oracle strings are enclosed in single quote marks
so Oracle is confused & unhappy with line below
customer_no =''
since CUSTOMEER_NO is a NUMBER
why do you compare number to a string?

Similar Messages

  • 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.

  • 11g outer join with case statement - strange results.

    Hello All,
    I am experiencing a strange issues in 11g while using case statement.
    I am not able to reproduce this using sample data. Not sure what is wrong.
    I am not narrowing it to say the usage of case statemnt is giving wrong results, but that is my observation when I am doing trail and error testing.
    Here are the details.
    My Version
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    SQL> My Query
    SELECT *
      FROM (SELECT DISTINCT mf.schedule,
                            mf.cptcode,
                            NVL (mf.modifier, '00') modifier2,
                            CASE
                               WHEN mf.feetype = 'H'
                                AND mf.multiplier IS NOT NULL THEN
                                  '      0.00'
                               WHEN (mf.feetype != 'H'
                                  OR  mf.feetype IS NULL)
                                AND mf.rbrvsvalue IS NOT NULL
                                AND mf.multiplier IS NOT NULL THEN
                                  LPAD ( TRIM (TO_CHAR ( (mf.rbrvsvalue * mf.multiplier) / 100, 9999999.99)), 10)
                               ELSE
                                  NULL
                            END
                               fee
              FROM provider.mpifee mf, mpi_udffee.udffeeactivecptcodes vld
             WHERE mf.schedule = 'SAPG1'
               AND mf.cptcode = vld.cptcode
               AND NVL (mf.modifier, 'NULL') = NVL (vld.modifier, 'NULL')) inline_fee,
           (SELECT arc.schedule col1, arc.procedurecode col2, NVL (arc.modifier, '00') AS col3
              FROM mpi_udffee.udffeeancfeedata arc
             WHERE monthofextract = '201202'
               AND arc.schedule = 'SAPG1'
               AND TRUNC (SYSDATE - 10) BETWEEN arc.recordeffectivedate AND arc.recordterminationdate) inline_data
    WHERE inline_fee.schedule = inline_data.col1(+)
       AND inline_fee.cptcode = inline_data.col2(+)
       AND inline_fee.modifier2 = inline_data.col3(+);
    In the above query the inline view inline_data returns zero rows. but NVL is still getting applied for col3 and I am getting 00 in the results( strange ).
    Results:
    SCHEDULE        CPTCO MODIFIER2  FEE             COL1  COL2  COL3
    SAPG1           49590 00             667.32                  00
    SAPG1           49611 00             781.03                  00
    SAPG1           49905 00             443.79                  00
    SAPG1           50205 00             883.56                  00
    SAPG1           50220 00            1315.15                  00
    SAPG1           50230 00            1638.74                  00
    SAPG1           50234 00            1666.16                  00
    SAPG1           50250 00            1566.14                  00
    SAPG1           50327 00             262.04                  00
    SAPG1           50541 00            1183.31                  00
    SAPG1           50620 00            1156.88                  00
    SAPG1           50650 00            1321.96                  00
    497 rows selected.
    Just the inline view inline_data,
    SQL> SELECT arc.schedule col1, arc.procedurecode col2, NVL (arc.modifier, '00') AS col3
      2            FROM mpi_udffee.udffeeancfeedata arc
      3           WHERE monthofextract = '201202'
      4             AND arc.schedule = 'SAPG1'
      5             AND TRUNC (SYSDATE - 10) BETWEEN arc.recordeffectivedate AND arc.recordterminationdate;
    no rows selectedMuch unusual thing is when I just remove the case statement from the inline view "inline_fee", I am getting right results,
    SELECT *
      FROM (SELECT DISTINCT mf.schedule,
                            mf.cptcode,
                            NVL (mf.modifier, '00') modifier2          <-- Removed Case statement here
              FROM provider.mpifee mf, mpi_udffee.udffeeactivecptcodes vld
             WHERE mf.schedule = 'SAPG1'
               AND mf.cptcode = vld.cptcode
               AND NVL (mf.modifier, 'NULL') = NVL (vld.modifier, 'NULL')) inline_fee,
           (SELECT arc.schedule col1, arc.procedurecode col2, NVL (arc.modifier, '00') AS col3
              FROM mpi_udffee.udffeeancfeedata arc
             WHERE monthofextract = '201202'
               AND arc.schedule = 'SAPG1'
               AND TRUNC (SYSDATE - 10) BETWEEN arc.recordeffectivedate AND arc.recordterminationdate) inline_data
    WHERE inline_fee.schedule = inline_data.col1(+)
       AND inline_fee.cptcode = inline_data.col2(+)
       AND inline_fee.modifier2 = inline_data.col3(+);
    SCHEDULE        CPTCO MODIFIER2  COL1  COL2  COL3
    SAPG1           46730 00
    SAPG1           46735 00
    SAPG1           46748 00
    SAPG1           46760 00
    SAPG1           46942 00
    SAPG1           46945 00
    SAPG1           47015 00
    SAPG1           47125 00
    SAPG1           47350 00
    SAPG1           47505 00
    SAPG1           47553 00interestingly explain plan for both the statements are exactly same,
    SELECT STATEMENT  ALL_ROWSCost: 138  Bytes: 1,078,274  Cardinality: 11,471                                
         9 HASH JOIN RIGHT OUTER  Cost: 138  Bytes: 1,078,274  Cardinality: 11,471                           
              2 PARTITION RANGE EMPTY  Cost: 2  Bytes: 150  Cardinality: 3                      
                   1 TABLE ACCESS FULL TABLE MPI_UDFFEE.UDFFEEANCFEEDATA Cost: 2  Bytes: 150  Cardinality: 3                 
              8 VIEW MPI_UDFFEE. Cost: 135  Bytes: 504,724  Cardinality: 11,471                      
                   7 HASH UNIQUE  Cost: 135  Bytes: 539,137  Cardinality: 11,471                 
                        6 HASH JOIN  Cost: 134  Bytes: 539,137  Cardinality: 11,471            
                             3 TABLE ACCESS FULL TABLE MPI_UDFFEE.UDFFEEACTIVECPTCODES Cost: 13  Bytes: 177,345  Cardinality: 25,335       
                             5 PARTITION LIST SINGLE  Cost: 120  Bytes: 600,600  Cardinality: 15,015  Partition #: 8       
                                  4 INDEX RANGE SCAN INDEX (UNIQUE) REPRICE.PK_MPIFEE Cost: 120  Bytes: 600,600  Cardinality: 15,015  Partition #: 9  Partitions accessed #11Is there anything wrong with the query? If not have anyone come across this issue or posted it as a bug or is there a patch?
    Update:
    when I set the parameter "_complex_view_merging"=false I am getting the right results even with case statement. But I don want to do some thing unsupported.
    Are there any other viable solutions?
    I appreciate the help.
    Thanks,
    G.
    Edited by: Ganesh Srivatsav on Apr 10, 2012 12:37 PM

    Hi Tubby,
    Right, the query transformation is going wrong. Following is from trace,
    SELECT "INLINE_FEE"."SCHEDULE" "SCHEDULE",
           "INLINE_FEE"."CPTCODE" "CPTCODE",
           "INLINE_FEE"."MODIFIER2" "MODIFIER2",
           "INLINE_FEE"."FEE" "FEE",
           "ARC"."SCHEDULE" "COL1",
           "ARC"."PROCEDURECODE" "COL2",
           CASE
              WHEN "ARC".ROWID IS NOT NULL THEN NVL ("ARC"."MODIFIER", '00')
              ELSE NULL
           END
              "COL3"
      FROM (SELECT DISTINCT "MF"."SCHEDULE" "SCHEDULE",
                            "MF"."CPTCODE" "CPTCODE",
                            NVL ("MF"."MODIFIER", :B2) "MODIFIER2",
                            CASE
                               WHEN ("MF"."FEETYPE" = :B3
                                 AND "MF"."MULTIPLIER" IS NOT NULL) THEN
                                  :B4
                               WHEN ( ("MF"."FEETYPE" <> :B5
                                    OR  "MF"."FEETYPE" IS NULL)
                                 AND "MF"."RBRVSVALUE" IS NOT NULL
                                 AND "MF"."MULTIPLIER" IS NOT NULL) THEN
                                  LPAD ( TRIM (TO_CHAR ( "MF"."RBRVSVALUE" * "MF"."MULTIPLIER" / :B6, :B7)), :B8)
                               ELSE
                                  NULL
                            END
                               "FEE"
              FROM "PROVIDER"."MPIFEE" "MF", "MPI_UDFFEE"."UDFFEEACTIVECPTCODES" "VLD"
             WHERE "MF"."SCHEDULE" = 'SAPG1'
               AND "MF"."CPTCODE" = "VLD"."CPTCODE"
               AND NVL ("MF"."MODIFIER", 'NULL') = NVL ("VLD"."MODIFIER", 'NULL')) "INLINE_FEE",
           "MPI_UDFFEE"."UDFFEEANCFEEDATA" "ARC"
    WHERE "INLINE_FEE"."SCHEDULE" = "ARC"."SCHEDULE"(+)
       AND "INLINE_FEE"."CPTCODE" = "ARC"."PROCEDURECODE"(+)
       AND "INLINE_FEE"."MODIFIER2" = CASE
                                         WHEN ("ARC".ROWID(+) IS NOT NULL) THEN NVL ("ARC"."MODIFIER"(+), '00')
                                         ELSE NULL
                                      END
       AND "ARC"."MONTHOFEXTRACT"(+) = '201202'
       AND "ARC"."SCHEDULE"(+) = 'SAPG1'
       AND TRUNC (SYSDATE-10) >= "ARC"."RECORDEFFECTIVEDATE"(+)
       AND TRUNC (SYSDATE-10) <= "ARC"."RECORDTERMINATIONDATE"(+)Does this refer to a specific bug?
    Thanks,
    G.

  • Using Presentation variables..along with case statements..

    Hi All.
    I have a issue using presentation variable along with CASE statements. My approach is
    1) I have a dashboard prompt, which is being set as Presentation variable.
    Based on the value selected in prompt, for ex the values of prompt can be 'ABC' and 'DEF'.
    I have a calculated column, the calculation goes this way...
    The forumal is
    CASE WHEN @{Presentation Variable Name} = 'ABC' THEN xxxxxxxxxx ELSE IF @{Presentation Variable Name} = 'DEF' END. It gives error of "no table being referenced"..
    Is this is the right approach??
    Can i get the values of variable in a column formula, so that a column can have values selected in prompt?
    Can anybody pls help me here..
    Thanks in advance...

    Hi
    Thanks for the quick response..
    I agree to ur point..
    But the requirement is
    Based on the value of the prompt I need to switch the calculation in one of the formula area of one column..
    If Prompt value is ABC then one kind of calculation in Fx and If the prompt value is DEF then one kind of calculation in the same Fx..
    How can I acheive this?
    Thanks in advance..

  • Update with case statement problem.

    Hi,
    I have this statement
    update tab_tr set col_rate =
      case
      when col_ern_type in ('031','035','036') then (1.5 * col_rate)
      when col_ern_type in ('041','045','046') then (2 * col_rate)
    end;this statement updated some 2 million rows in the table tab_tr. But the total count of rows for col_ern_type in ('031','035','036', '041','045','046') yeild only around 222642 rows.
    select count(*) from tab_tr where col_ern_type in ('031','035','036', '041','045','046');  --> 222642 rowswhat is the problem with the above update statement.
    Thank you,

    Hi,
    DBA_1976 wrote:
    ... I thought the case statement conditions are counted as the where condition. But ......A CASE expression just takes the place of some other expression, such as a literal, a function, or a column.
    For example, which rows do you think this should update?
    UPDATE  tab_tr
    SET     col_rate  = 100;It would update all rows, of course.
    How about this statement?
    UPDATE  tab_tr
    SET     col_rate  = column_x;Will it only change the rows where column_x are a certain value, or not NULL, or in any way depend on column_x? No, of course not. It will update all rows.
    How about this statement?
    UPDATE  tab_tr
    SET     col_rate  = function_y (col_ern_type);Will it only change the rows where the fucntion returns a certain value? Will it depend on the value in col_ern_type? No, of course not. It calls the function for each row, and whatever the function returns (even if the function returns NULL), that's what goes into col_rate on each row.
    A CASE expression is just something that you can substitute in place of any other expression, such as the literal 100, or the column column_x, or the function function_y in the statements above. Naturally, the value that gets put into col_rate will depend on what the CASE expression returns, but the behavior of the UPDATE statement as a whole will not.

  • Problem with CASE and Object tables.

    Hi guys,
    Have a problem which I am unable to understand how to solve.
    I have the following object
    create type obj_numeric_id_table as table of number(30);
    create type obj_search_rec as object
    ( zones number(4),
      locs obj_numeric_id_table
    create type obj_search_tbl as table of obj_search_rec;
    /Now this object Obj_search_tbl is being passed as an IN parameter to a procedure...actually the object has many more columns but the problem at hand is with the locs column.
    The problem is - if I use the count for the locs column in an IF statement, then all works fine, but if I use it inside a CASE statement in the SELECT clause, it gives me an error.
    create proc proc_1 (abc obj_search_tbl) .....
    L_search obj_search_rec;
    begin
    L_search_rec := abc(1); -- for the moment there is only one record.
    IF L_search_rec.locs.count() > 0 then -- this works perfectly
    END IF;
    select (case when L_search_rec.locs.count() > 0 then 1 end) from some_table;
    -- now this case statement gives me the following error
    "PL/SQL: ORA-00904: "L_SEARCH_REC"."LOCS"."COUNT": invalid identifier"Am I doing something wrong....am unable to understand why this is so...
    Thanks,

    Other possibility:
    select count(t.column_value) from
    (select obj_search_rec(1, obj_numeric_id_table(1,2)) obj_search_rec from dual) l,
    table(l.obj_search_rec.locs) t;

  • Problem In Case Statement

    HI ALL,
    in the program,i need to display description based on condition type.
    so we used CASE statement as below in LOOP. ITS not working .
    could anyone please suggest if anything wrong in the following code.
    LOOP AT gt_mat.
           MOVE gt_mat-type  TO gt_final-type.
      Condition description
    CASE gt_mat-type  .
    when  'N'.
    move  'New'  to gt_final-condes.
    when  'B'.
    move 'Block'   to gt_final4-condes.
    ENDCASE.
    ENDLOOP.
    please let me know whats the problem i above code and how to solve.
    thanks in advance.

    Hi,
    The only solution for this could be to debug the program and check if the coresponding values are populated and available. You could also try to replace the CASE statement with a simple IF statement and check if its working.
    LOOP AT gt_mat.
    MOVE gt_mat-type TO gt_final-type.
    * Condition description
    IF gt_mat-type = 'N'.
    gt_final-condes = 'New'.
    elseif gt_mat-type = 'B'.
    gt_final-condes ='Block'.
    append gt_final.
    clear gt_final.
    ENDIF.
    ENDLOOP.
    Also make sure the case of the value in gt_mat-type matches with the condition
    Regards,
    Vikranth

  • SQL Expression Field - Combine Declared Variable With Case Statement

    Hello All, I have been using Crystal & Business Objects for a few months now and have figured out quite a bit on my own. This is the first real time I have struggled with something and while I could do this as a Formula Field I would like to know how to do this as a SQL Expression. Basically I want to create a SQL Expression that uses a CASE statement but I wanted to make the code a little more efficient and employ a variable to hold a string and then use the variable in the CASE statement. The expression editor accepts the CASE statement OK but I don't know how to declare the variable. Please assist with the syntax?
    This is what I have:
    CASE
       WHEN u201CDatabaseu201D.u201DFieldu201D = u2018Hu2019 THEN u2018Hedgeu2019
       WHEN u201CDatabaseu201D.u201DFieldu201D = u2018Pu2019 THEN u2018PVIu2019
       ELSE u2018Noneu2019
    END
    This is what I want:
    DECLARE strVar AS VARCHAR(25)
    strVar =  u201CDatabaseu201D.u201DFieldu201D
    CASE
       WHEN strVar = u2018Hu2019 THEN u2018Hedgeu2019
       WHEN strVar = u2018Pu2019 THEN u2018PVIu2019
       ELSE u2018Noneu2019
    END

    Hi Todd,
    Please use the following for loop; your problem will be solved.
    Local StringVar str := "";
    Local NumberVar strLen := Length ({Database.Field});
    Local NumberVar i;
    For i := 1 To strLen Do
           if {Database.Field} <i> = "H" then str := "Hedge"
            else if {Database.Field} <i> = "P" then str := "PVI"
            else str := "None"; exit for
    str
    Let me know once done!
    Thank you,
    Ashok

  • 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

  • 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.

  • 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

  • Performance problem with MERGE statement

    Version : 11.1.0.7.0
    I have an insert statement like following which is taking less than 2 secs to complete and inserts around 4000 rows:
    INSERT INTO sch.tab1
              (c1,c2,c3)
    SELECT c1,c2,c3
       FROM sch1.tab1@dblink
      WHERE c1 IN (SELECT c1 FROM sch1.tab2@dblink);I wanted to change it to a MERGE statement just to avoid duplicate data. I changed it to following :
    MERGE INTO sch.tab1 t1
    USING (SELECT c1,c2,c3
       FROM sch1.tab1@dblink
      WHERE c1 IN (SELECT c1 FROM sch1.tab2@dblink) t2
    ON (t1.c1 = t2.c1)
    WHEN NOT MATCHED THEN
    INSERT (t1.c1,t1.c2,t1.c3)
    VALUES (t2.c1,t2.c2,t2.c3);The MERGE statement is taking more than 2 mins (and I stopped the execution after that). I removed the WHERE clause subquery inside the subquery of the USING section and it executed in 1 sec.
    If I execute the same select statement with the WHERE clause outside the MERGE statement, it takes just 1 sec to return the data.
    Is there any known issue with MERGE statement while implementing using above scenario?

    riedelme wrote:
    Are your join columns indexed?
    Yes, the join columns are indexed.
    You are doing a remote query inside the merge; remote queries can slow things down. Do you have to select all thr rows from the remote table? What if you copied them locally using a materialized view?Yes, I agree that remote queries will slow things down. But the same is not happening while select, insert and pl/sql. It happens only when we are using MERGE. I have to test what happens if we use a subquery refering to a local table or materialized view. Even if it works, I think there is still a problem with MERGE in case of remote subqueries (atleast till I test local queries). I wish some one can test similar scenarios so that we can know whether it is a genuine problem or some specific problem from my side.
    >
    BTW, I haven't had great luck with MERGE either :(. Last time I tried to use it I found it faster to use a loop with insert/update logic.
    Edited by: riedelme on Jul 28, 2009 12:12 PM:) I used the same to overcome this situation. I think MERGE needs to be still improved functionally from Oracle side. I personally feel that it is one of the robust features to grace SQL or PL/SQL.

  • Problem with Submit statement into print program for delivery

    Hi all,
    i got a problem with the SUBMIT statement that i put into a print program associated to a delivery output message.
    If i print the message by VL02N or VL71, everything works.
    But if i associate the output with RV56ABST, the SUBMIT instruction isn't accepted and i get the message
    "Processor ABAP: POSTING_ILLEGAL_STATEMENT"
    There is any solution to this situation?
    Why i cannot use the SUBMIT statement in this case?

    Hi Simone,
    you could try to do the operation in a separate task (call a function in starting new task). This will decouple your current process from the new task.
    Cheers,
    Stefan.

  • Problem with case sensitivity 7.3.4

    Hi,
    We are having a problem with JDBC being unable to handle a lower
    case on a SQL statement execution. For eg: Like '%S%' works but
    not '%s%'.
    Any suggestions
    Thanks,
    Ganesh
    null

    Hi Ganesh,
    it's not a jdbc problem. when u try to query
    using matches (%'s), it looks for exact match.
    u can Compare the values by converting them
    to uppercase using to_upper.
    ex: where to_upper(table_field_name) = to_upper('%
    ur_string_value%') ...
    ATB
    MohanE
    Ganesh (guest) wrote:
    : Hi,
    : We are having a problem with JDBC being unable to handle a
    lower
    : case on a SQL statement execution. For eg: Like '%S%' works
    but
    : not '%s%'.
    : Any suggestions
    : Thanks,
    : Ganesh
    null

  • 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

Maybe you are looking for

  • Window 8.1 preview for developer update issu.

    After updating to window 8.1 preview for developer in lumia720 any surity that the major problem will not occurs in device? it is safe for device to update? if i m not comfortable with new update then can i come back to old version of software?

  • Adobe flash player for ios 7on ipad

    adobe flash player for ios 7on ipad?

  • My videos are flipping like waves of water

    Hello! Firefox... My computer crashed and I sent it in to be serviced and the installer installed a different video-card than the one that was in my computer [which is a refurbished computer] and my pages where flipping or overlapping... Therefore, I

  • What size for postcard

    Hi there, I'm a newby here. I was wondering what size to choose if I want to make a (rectangular standard) postcard. Also, how to make a border. Thank you! Samantha

  • Quicktime 3gp conversion?

    i require software to convert .3gp files to .Avi in order to post them on my website. Can anyone tell me if Quicktime 7 (the version you pay for) will do this and will they be able to be viewed using windows media player? Is Quicktime the best soluti