Character Expression

Hi all,
I am currently using expression operator in mapping and i have to give expressions for single field like,
If field a=4,then apply 10 in the target,
if field a=null,then apply 9,
if field length 'a' is not equal to 3,then apply 2.. like this..
This three kind of expression is only for the single field 'a'..
Pls help me out..
Thanks in advance,
Bharath krish.
Edited by: user11342336 on Jul 23, 2009 3:21 AM

You can use the predefined function inside the expression operator and other operators too (joiner, for example).
If you use the case statement, don't forget the else clause. If you don't use that, the expression can result in a null value. The case statement has the same meaning as the decode.

Similar Messages

  • Character.isLetter() error on compile

    Hi all. I'm trying to write a method that does a series of validations on the characters in a String. Here's my code:
       import java.util.*;
       import java.lang.*;
        public class ScratchPad
           public static void main(String args[])
             Scanner kb = new Scanner(System.in);
             System.out.println("Enter PN expression: ");
             String myPN = kb.nextLine();
             int isValid = validate(myPN, 3);
          System.out.println("Came up as: " + isValid);
           public static int validate(String expression, int vVar)
             for (int x = 0; x < expression.length(); x++)
                Character currChar = new Character(expression.charAt(x));
                if (!currChar.isLetter())   //test to see if the Character is a letter, first error
                   return 1;
                else if (currChar.isUpperCase())   //test to see if it's uppercase, second error
                {     String operands = "NKAJEDC";
                   int intStr = operands.indexOf(currChar);
                   if (intStr < 0)
                      return 2;
             return 0;
          }//end validate
       }And here's my errors:
    ScratchPad.java:24: cannot find symbol
    symbol  : method isLetter()
    location: class java.lang.Character
                if (!currChar.isLetter())
                             ^
    ScratchPad.java:26: cannot find symbol
    symbol  : method isUpperCase()
    location: class java.lang.Character
                else if (currChar.isUpperCase())
                                 ^
    2 errorsThe test I'm trying to make is supposed to see if the characters are alphabetic. There's also a limited number of capital letters allowed, hence the crazy String and indexOf. This was originally choking because I had a regular char instead of a Character variable, but when I fixed that I hit this one instead. Could someone please take a peek and let me know if/what I'm using incorrectly?
    Thanks!
    Kate

    Also, you would be wise to enclose all if blocks, for and while loops, try/catch blocks, etc... within curly braces even if it means that it will include only a one line statement (or perhaps especially if it only includes a one line statement). This will prevent you from making a bad mistake later on when you update your program.

  • Substring instr issue in obiee

    Hi,
    I want to use the INSTR function in OBIEE
    POSITION function found in the forum
    INSTR function takes four values:
    INSTR (string1, string2, number, number)
    Eg IP address
    111.222.333.444
    The desired result
    SUBSTR (IP_ADD, 1, INSTR (IP_ADD, '.', 1,3) -1)
    111.222.333
    POSITION function, how should I use?
    Thanks,
    Mino

    1st example '0.0.0.0' will def be a problem here. Unfortunately, I don't think any other OBIEE string function could support this.
    I was assuming for min 2 numbers like 00.00.00.00. Do you have any case like the first one in your table ?
    =========
    As I said, you can't use POSITION function here..Just do help for String Function in RPD)
    Position
    Returns the numerical position of the character_expression1 in a character expression. If the character_expression1 is not found, the function returns 0.
    Syntax:
    POSITION(character_expression1 IN character_expression2)
    where:
    character_expression1
    Any expression that evaluates to a character string. Used to search in the second string.
    character_expression2
    Any expression that evaluates to a character string.
    So, these are the 2 expression, In your case its '.' & IP_ADDR.
    =========
    Hope its helpful

  • What is the Java equivalent of Visual BAsic ASC() and MID() functions

    Hello all! I just would like to ask if you have any idea on how to convert the VB ASC() and MID() functions into java. Where:
    1. ASC( ) Function - Returns the ANSI value for the leftmost character in a character expression.
    2. MID() Function - The Mid method extracts a substring of length nCount characters from a CHString string, starting at position nFirst (zero-based). The method returns a copy of the extracted substring.
    I would really appreciate your help. Thanx!

    ah yeah! sorry typo error. see, I am converting a VB method that encrypts password:
    Function EncryptText(ByVal stDecryptedText As String)
    Dim stText As String, lngCounter As Long
    Dim iTemp As Integer, lngNumber As Long
    lngCounter = 1
    lngNumber = 8
    Do Until lngCounter = Len(stDecryptedText) + 1
    iTemp = Asc(Mid(stDecryptedText, lngCounter, 1))
    If lngCounter Mod 2 = 0 Then
    iTemp = iTemp - lngNumber
    Else
    iTemp = iTemp + lngNumber
    End If
    iTemp = iTemp Xor (10 - lngNumber)
    stText = stText & Chr$(iTemp)
    lngCounter = lngCounter + 1
    Loop
    EncryptText = stText
    End Function
    I converted this function into this:
    public static String encryptPass(String password) {
    String encpwd = "";
    int iTemp = 0;
    final int lngNumber = 8;
    String stText = "";
    for ( int i = 0; i < password.length() ; i++ ) {
         iTemp = Character.getNumericValue(password.charAt(i));
         if ( i % 2 == 0 ) {
         iTemp = iTemp - lngNumber;
         } else {
         iTemp = iTemp + lngNumber;
         iTemp = iTemp ^ (10 - lngNumber);
         char c = Character.forDigit(iTemp,Character.MAX_RADIX);
         encpwd = encpwd + String.valueOf(c);
         return encpwd;
    But I'm having trouble with the encryption because it returns a different set of characters. Did I convert it right? thanx.

  • [OT] User-Defined string Functions  Oracle PL/SQL

    Ladies and Gentlemen,
    I am pleased to offer the following string functions Oracle PL/SQL:
    GETALLWORDS(): Inserts the words from a string into the table.
    GETWORDCOUNT(): Counts the words in a string.
    GETWORDNUM(): Returns a specified word from a string.
    OCCURS(): Returns the number of times a character expression occurs within another character expression (including overlaps).
    OCCURS2(): Returns the number of times a character expression occurs within another character expression (excluding overlaps).
    PADC(): Returns a string from an expression, padded with spaces or characters to a specified length on the both sides.
    STRTRAN(): Searches a character expression for occurrences of a second character expression, and then replaces each occurrence with a third character expression. Unlike a built-in function Replace, STRTRAN has three additional parameters.
    STRFILTER(): Removes all characters from a string except those specified.
    RAT(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string (including overlaps). The search performed by RAT() is case-sensitive. RAT similar to the PL/SQL function INSTR.
    ATC(): Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character (including overlaps). The search performed by ATC() is case-insensitive. ATC similar to the PL/SQL function INSTR.
    RATC(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string (including overlaps). The search performed by RATC() is case-insensitive. RATC similar to the PL/SQL function INSTR.
    AT2(): Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character (excluding overlaps). The search performed by AT2() is case-sensitive. AT2 similar to the PL/SQL function INSTR.
    REPLICATE(): Returns a character string that contains a specified character expression repeated a specified number of times.
    ROMANTOARAB(): Returns the number equivalent of a specified character Roman numeral expression (from I to MMMCMXCIX).
    Plus, there are versions for MS SQL SERVER, SYBASE ASA, DB2, MS SQL SERVER 2005 SQLCLR.
    More than 8000 people have already downloaded my functions. I hope you will find them useful as well.
    For more information about string UDFs Oracle PL/SQL please visit the
    http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,29233
    Please, download the file
    http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,29233
    With the best regards.

    >
    I am using the Oracle Data Provider in vs2012. I am having trouble calling a function that returns an object type defined.
    >
    Returning a collection like that is a bad idea to begin with. That isn't scaleable and wastes memory.
    Either return a REF CURSOR and let the client FETCH the rows or use a PIPELINED function and let the client query it like they would a table.
    Here is an example similar to yours that uses a PIPELINED function.
    create or replace
        package pkg2
          as
            CURSOR emp_cur is (SELECT empno, ename, job, mgr, deptno FROM emp);
            type pkg_emp_table_type is table of emp_cur%rowtype;
            function get_emp(
                             p_deptno number
              return pkg_emp_table_type
              pipelined;
      end;
    create or replace
        package body pkg2
          as
            function get_emp(
                             p_deptno number
              return pkg_emp_table_type
              pipelined
              is
              begin
                  for v_emp_rec in (SELECT empno, ename, job, mgr, deptno
                                    FROM emp where deptno = p_deptno) loop
                    pipe row(v_emp_rec);
                  end loop;
              end;
      end;
    select * from table(pkg2.get_emp(20));
           EMPNO ENAME      JOB              MGR     DEPTNO
            7369 DALLAS     CLERK2          7902         20
            7566 DALLAS     MANAGER         7839         20
            7788 DALLAS     ANALYST         7566         20
            7876 DALLAS     CLERK           7788         20
            7902 DALLAS     ANALYST         7566         20

  • Maximum size of the SSIS String Variable?

    In SSIS, what is the maximum size of the String variable (one that you would define in the Variables dialog box)?

     jwelch wrote:
    4000 is the limit on expressions. I'm not sure what the limit is on strings.
    This is all true.  Technically, I'm not sure there's a limit on the string variables.  Though you can't really use that variable anywhere without the 4000 character expression limit applying.  (Most of the time the variable is used in an expression SOMEWHERE...)

  • Trim Function

    Hi,
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> SELECT TRIM ('OLD' FROM 'OLDMAN') FROM DUAL;
    SELECT TRIM ('OLD' FROM 'OLDMAN') FROM DUAL
    ERROR at line 1:
    ORA-30001: trim set should have only one characterDear All why this error....

    TRIM function
    TRIM is a function that takes a character expression and returns that expression with leading and/or trailing pad characters removed. Optional parameters indicate whether leading, or trailing, or both leading and trailing pad characters should be removed, and specify the pad character that is to be removed.
    Syntax
    TRIM( [ trimOperands ] trimSource)
    trimOperands ::= { trimType [ trimCharacter ] FROM | trimCharacter FROM }
    trimType ::= { LEADING | TRAILING | BOTH }
    trimCharacter ::= CharacterExpression
    trimSource ::= CharacterExpression
    If trimType is not specified, it will default to BOTH. If trimCharacter is not specified, it will default to the space character (' '). Otherwise the trimCharacter expression must evaulate to one of the following:
    a character string whose length is exactly one, or.
    NULL
    If either trimCharacter or trimSource evaluates to NULL, the result of the TRIM function is NULL. Otherwise, the result of the TRIM function is defined as follows:
    If trimType is LEADING, the result will be the trimSource value with all leading occurrences of trimChar removed.
    If trimType is TRAILING, the result will be the trimSource value with all trailing occurrences of trimChar removed.
    If trimType is BOTH, the result will be the trimSource value with all leading and trailing occurrences of trimChar removed.

  • Regular expressions with multi character separator

    I have data like the
    where |`| is the separator for distinguishing two fields of data. I am having trouble writing a regular expression to display the data correctly.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> declare
      2  l_string varchar2 (200) :='123` 456 |`|789 10 here|`||223|`|5434|`}22|`|yes';
      3  v varchar2(40);
      4  begin
      5  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 1);
      6  dbms_output.put_line(v);
      7  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 2);
      8  dbms_output.put_line(v);
      9  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 3);
    10  dbms_output.put_line(v);
    11  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 4);
    12  dbms_output.put_line(v);
    13  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 5);
    14  dbms_output.put_line(v);
    15  end;
    16  /
    123
    456
    789 10 here
    223
    5434I need it to display
    123` 456
    789 10 here
    |223
    5434|`}22
    yesI am not sure how to handle multi character separators in data using reg expressions
    Edited by: Clearance 6`- 8`` on Apr 1, 2011 3:35 PM
    Edited by: Clearance 6`- 8`` on Apr 1, 2011 3:37 PM

    Hi,
    Actually, using non-greedy matching, you can do what you want with regular expressions:
    VARIABLE     l_string     VARCHAR2 (100)
    EXEC  :l_string := '123` 456 |`|789 10 here|`||223|`|5434|`}22|`|yes'
    SELECT     LEVEL
    ,     REPLACE ( REGEXP_SUBSTR ( '|`|' || REPLACE ( :l_string
                                     , '|`|'
                                      , '|`||`|'
                                     ) || '|`|'
                        , '\|`\|.*?\|`\|'
                        , 1
                        , LEVEL
               , '|`|'
               )     AS ITEM
    FROM     dual
    CONNECT BY     LEVEL     <= 7
    ;Output:
    LEVEL ITEM
        1 123` 456
        2 789 10 here
        3 |223
        4 5434|`}22
        5 yes
        6
        7Here's how it works:
    The pattern
    ~.*?~is non-greedy ; it matches the smallest possible string that begins and ends with a '~'. So
    REGEXP_SUBSTR ('~SHALL~I~COMPARE~THEE~', '~.*?~', 1, 1) returns '~SHALL~'. However,
    REGEXP_SUBSTR ('~SHALL~I~COMPARE~THEE~', '~.*?~', 1, 2) returns '~COMPARE~'. Why not '~I~'? Because the '~' between 'SHALL' and 'I' was part of the 1st pattern, so it can't be part of the 2nd pattern. So the first thing we have to do is double the delimiters; that's what the inner REPLACE does. The we add delimiters to the beginning and end of the list. Once we've done prepared the string like that, we can use the non-greedy REGEXP_SUBSTR to bring back the delimited items, with a delimiter at either end. We don't want those delimiters, so the outer REPLACE removes them.
    I'm not sure this is any better than Sri's solution.

  • Regular Expression Character Sets with Pattern and Matcher

    Hi,
    I am a little bit confused about a regular expressions I am writing, it works in other languages but not in Java.
    The regular expressions is to match LaTeX commands from a file, and is as follows:
    \\begin{command}([.|\n\r\s]*)\\end{command}
    This does not work in Java but does in PHP, C, etc...
    The part that is strange is the . character. If placed as .* it works but if placed as [.]* it doesnt. Does this mean that . cannot be placed in a character range in Java?
    Any help very much appreciated.
    Kind Regards
    Paul Bain

    In PHP it seems that the "." still works as a all character operator inside character classes.
    The regular expression posted did not work, but it does if I do:
    \\begin{command}((.|[\n\r\s])*)?\\end{command}
    Basically what I'm trying to match is a block of LaTeX, so the \\begin{command} and \\end{command} in LaTeX, not regex, although the \\ is a single one in LaTeX. I basically want to match any block which starts with one of those and ends in the end command. so really the regular expression that counts is the bit in the middle, ((.|[\n\r\s])*)?
    Am I right it saying that the "?" will prevent the engine matching the first and last \\bein and \\end in the following example:
    \\begin{command}
    some stuff
    \\end{command}
    \\begin{command}
    some stuff
    \\end{command}

  • Weblogic xss vulnerablity : html character entities getting decoded in jsp by ${} expression

    This is from my question at stack overflow java - Weblogic xss vulnerablity : html character entities getting decoded in jsp - Stack Overflow
    I am using a filter to prevent xss by encoding html character of my jsp form parameters.
    I am resolving them in jsp using ${param} expression.
    This is working fine in tomcat as the values are resolved as is, but on weblogic the values are getting decoded, causing the XSS to succeed
    I am using this simple code in jsp to test it
    <c:set var="testing" value="eb011&quot;&gt;&lt;img src=a onerror=confirm(1)&gt;47379"/> <input type="hidden" name="encoding" value="${testing }"/>
    Result in tomcat
    <input type="hidden" onerror="confirm(1)&gt;47379&quot;/" src="a" &gt;&lt;img="" value="eb011" name="encoding">
    Result in weblogic
    <input type="hidden" value="eb011" name="encoding"><img onerror="confirm(1)" src="a">47379"/&gt;
    why is weblogic decoding html codes and what could be done to prevent it.

    It is really handy to learn how to read schema validation errors. It really does say exactly what's wrong there. If you can get access to the XSD that your XML document is prescribing, you should be able to tell what mistake you made. If you learn how to do this, you'll never have to ask questions like this again. :)
    The error refers to the "http://www.bea.com/ns/weblogic/weblogic-web-app" namespace, which I believe is in your "weblogic.xml" file. It's saying that in the "jsp-descriptor" element, it found a "noTryBlocks" element at a point where it was not legal. At that point, it expected to find either a "'precompile-continue" or several other elements, but not that one. Read the XSD to determine the correct order for elements. If you're editing this file in Eclipse, you may not even have to obtain the XSD. If you hover the mouse over the root element of the document, it will give you a popup showing the syntax details of the element, which will tell you what the expected order of elements is.

  • How do I enter my existing 26 character wep network key on my airport express. I have tried using a preceding $ to no avail

    How do I enter my existing 26 character wep network key on my airport express. I have tried using a preceding $ to no avail

    The WEP standard provides support for either:
    A 10 hexidecimal digit or 5 ASCII character key for 40-bit WEP,  OR
    A 26 hexidecimal digit or 13 ASCII character key for 128-bit WEP
    In order to make things easier, vendors use certain algorithms to convert simple alphanumeric passwords (or passphrases) into HEX keys, thus enabling the use of simple easy to remember WEP password rather than lengthy HEX keys. The problem is that different vendors use different algorithms to generate the HEX key and therefore a ASCII password on an AirPort Express will be hashed differently than on a non-Apple client and vice versa.
    In addition, the 802.11n AirPorts do NOT support either 40-bit or 128-bit WEP in the "n" Radio Mode. You will have to switch to one of the non-"n" modes to access these wireless security options.
    When operating in 802.11n, the only WEP option is the WEP (Transitional Network Security) mode. Note: This mode only supports using 13 ASCII character keys. This would be the reason that you are not able to enter a 26 hexidecimal digit key. 
    You may find the following Apple Support article helpful: AirPort: Joining an encrypted WEP  or WPA Wi-Fi Network

  • How to compose an expression to display character array

    I have a non-\0 terminated dynamic character array stored in a custom (legacy company) datastructure that looks like this
    struct Str {
    char* buf;
    int size;
    I am trying to compose a natvis display for this:
    <Type Name="Str">
    <DisplayString> {XXX} </DisplayString>
    </Type>
    It looks quite straightforward, however, I wasn't able to get a clean expression for XXX.  I tried the following:
    {buf,sb} - does not work, as buf is not zero-terminated.
    {buf,size} - does not work since apparently size can not be dynamic
    {(wchar(*)[size])buf} - does not work for the same reason, and also [] produces array visualization (not string)
    Any ideas how to produce a clean string expression out of this stuct?
    Thanks

    Hi slymz,
    If possible, please refer to the following documents here:
    https://msdn.microsoft.com/en-us/library/jj620914.aspx?f=255&MSPPError=-2147217396#BKMK_DisplayString
    http://blogs.msdn.com/b/vcblog/archive/2013/06/28/using-visual-studio-2013-to-write-maintainable-native-visualizations-natvis.aspx
    Which shared us the detailed steps about how to custom views of native objects include the "DisplayString" like these:
    <Type Name="CPoint">
      <DisplayString>{{x={x} y={y}}}</DisplayString>
    </Type>
    Maybe it is related to the real format specifiers:
    https://msdn.microsoft.com/en-us/library/vstudio/75w45ekt.aspx
    Hope it could help.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Replace single character and leave the ones in expressions

    Hi,
    I'm looking for nice and elegant solution to my problem. Let's say I have a string "e+exp(e)". I want to replace all "e" with "1", excepts the one in "exp". I was trying to use regular expressions but I've failed after an hour... The solution should be able to solve things like replace "a" in "rand(a)" without changing rand. Basically I need to replace single character without replacing the ones in words/expressions.
    Any ideas?  
    Certified LabVIEW Developer, Certified TestStand Developer
    Solved!
    Go to Solution.

    No time for elegance right now, just brute force.  I would pad the string with spaces on each end to remove end cases and then search for the character surrounded by non-word characters. 
    Message Edited by Darin.K on 04-14-2010 04:06 PM
    Attachments:
    VariableParsingRegex.png ‏18 KB

  • Regular Expressions Character Class shortcuts

    I have been learning to use regular expressions to modify some of my text files. I noticed that on my ARCH box the Character Class shortcuts do not work e.g. [[:digit:]] in an expression works but \d does not. Is this normal or is my installation broken in some way?

    Bebo wrote:
    There are several regexp "dialects". It's quite painful actually For instance, as far as I know, \d works in perl, but not in sed or grep.
    So, yes, this is normal.
    Yeah -- Henry Spencer's regexp stuff is always generally considered the portable form for sed, awk, since they're all based from it.  Newer versions of grep though do allow for a -P flag for perl-regexps to be used, but this is non-portable, obviously.
    -- Thomas Adam

  • Oracle 10g express - accent character

    Hi,
    We have a problem with the 10g Express database for Windows. If you create a column VARCHAR(2) for example, you can't insert a string like 'éé'. You can only insert one character with accent.
    This problem doesn't exist in Oracle 10g Standard Edition. Is there a mean to change this behaviour ?
    Thank you

    The behavior here doesn't depend on the edition of Oracle (express and standard, in other words, will behave the same), but on the character set and NLS_LENGTH_SEMANTICS initialization parameter.
    By default, when you declare a VARCHAR2(2), you are allocating 2 bytes of storage. If you are using a single-byte character set (i.e. Windows-1252), all characters require one byte of storage. If you are using a variable-length character set (i.e. UTF-8), some characters require 1 byte of storage, some require 2 bytes, and some will require 3 bytes. I'll wager that your XE database is using the UTF-8 character set, so accented characters will generally require 2 bytes of storage, hence you can only add one to a VARCHAR2(2).
    One option you always have is to explicitly specify whether you want character or byte semantics when you create a table. That is, a VARCHAR2(2 BYTE) is equivelent to the default declaration of VARCHAR2(2) but a declaration of VARCHAR2(2 CHAR) allocates space for two characters in the current character set.
    If you want the default when you declare a new column/ variable to be that Oracle should use character semantics rather than byte semantics, you can also set the initialization parameter NLS_LENGTH_SEMANTICS to CHAR from the default of BYTE.
    Justin

Maybe you are looking for