String comparision issue

Good morning folks,
I want to take basically month and year of sysdate and compare with month and year of field in database and compare them.
But it is not working.
select case when
(concat(TO_CHAR(sysdate, 'MM'), to_char(sysdate,'YYYY')) >
concat(to_char(max(as_of_date),'MM'), to_char(max(as_of_date),'YYYY'))) then 'Not Archived'
else 'Archived' end from historical_advs_curr_eom
can someone suggest me any other better way of doing?
May be I shouldn't convert sysdate to string?
Thanks much folks.
regards
nathan

user12131044 wrote:
May be I shouldn't convert sysdate to string?Exactly. A string is not a date. Nor a number. So comparisons using strings do not behave like comparisons using dates and numbers.
Always try and use data in its native format - do not convert it into another data type as that data type will often behave differently and not provide the expected answer.
It is also not a good idea from a performance perspective. If you have an index or a number columns, the index value is numeric. If you now do a conversion of the column to a string and compare using that, it renders that index that contains numbers and not strings, useless.
Conversion also is an overhead - especially when it needs to be applied to every single row that the SELECT statement hints.
So rather stick to the native data type of that column. It is a lot more sensible.

Similar Messages

  • String Comparision in XSLT Mapping

    HI All,
    Can any one suggest me to compare the two strings in XSLT mapping.Please let me know is there any string comparision function in xslt?
    Thanks
    Pullarao

    Hi Pullaro!
    It depends what you want to do with the comparison
    E.g. you can use a simple xsl-if Tag to compare a value
    and then take action.
    If your XML looks like this:
    <root>
      <child><b>value1</b></child>
      <child>value2</child>
    </root>
    you can make an expression like this and take action on it:
    <xsl:if test="<b>//child = 'value1'</b>">
        <i>.. Do what you want to do here..</i>
    </xsl:if>
    With kind regards
                 Sebastian

  • String comparision using tokens (challenging question)

    Hello, everyone.
    i am having a problem with string comparision.
    for example, the input file is:
    each line is an input line (string)
    1)a x
    2)b c x
    3)a b x
    4)a b y
    5)a b c x
    in above example a,b,c,x,y are strings(tokens)
    in above example
    line 1 ,3,5 has token "a" common and class "x" is also common
    if this condition is satisfied,
    line 1 should be send to general file (output file 1) and
    line 3 and 5 should be send to specific file (output file 2)
    rest of the lines should be send to third file.
    remember in line 4, token "a" is same when compared with line1
    but it has a different class (y) .this line will go the third file. this is where line 3 and 4 differs.
    i have read this file into an string array.
    how to proceed further.
    i am new to java programming.
    cheers in advance.

    Well, first off, I'm assuming that you keep the first string as the first token and the class name as your last token, then you tokenize everything using StringTokenizer. the code would look something like this. You could also use countTokens() to know how many tokens are in a tokenizer.
    My approach would be the following:
    1. Create an array of Strings to hold each line (you already did that)
    2. Go through the array, one line at a time, tokenize the String, figure out the first and last tokens
    3. Write it to the corresponding file.
    The code would be something as follows
    String ClassToLookFor, StringToLookFor; // holds which class and first string to look for
    String firstToken, lastToken; //used in checking each element with first one
    boolean firstFound = false;  // First instance of Class name and first thread combo found
    public static void main(String args[])
    StringTokenizer tokenizer;
    int tokenizerLength;
    // read in array of Strings, store it into lines or something
    int endOfRun = lines.length;
    for (int i = 0; i<endOfRun; i++)
    tokenizer = new StringTokenizer(lines);
    tokenizerLength = tokenizer.countTokens();
    if(!firstFound)
    // store the information (StringToLookFor and ClassToLookFor) and write the line to the corresponding file
    else
    firstToken = tokenizer.next();
    int runThru;
    while(runThru < (tokenizerLength - 2)) {tokenizer.next();} // going to the last token
    lastToken = tokenizer.next();
    if (firstToken.equals(StringToLookFor) && lastToken.equals(ClassToLookFor))
    {write lines[i] to second file}
    else
    {write lines[i] to third file}
    hope that helps ...

  • Soap adapter: string transformations issues

    I have a difficult issue:
    I want to send a SOAP message to a thirdparty environment ,this environment requieres a special format of the message XML to String; iu2019ll put a sample:
    < SOAP:Body >
    < ns0:application xmlns:ns0=u201Dhttp://xxxxxx/yyyyyyy.com/zzzzu201D >
    < in0>
    < inputMessage >
    < request>name </request >
    < versionMsg>x.0
    u2026u2026u2026u2026..
    < /parameters >
    < /inputMessage>
    This is the meesage that i process with PI. Then when it arrives to the other environment should be as this one, i'll write wrong the chars because the web change it in code...:
    u201C< SOAP:Body >
    < ns0:application xmlns:ns0=u201Dhttp://xxxxxx/yyyyyyy.com/zzzzu201D>
    < in0>
    & lt inputMessage& gt
    & lt request & gt name& lt /request& gt
    & lt versionMsg& gt x.0& lt /versionMsg& gt
    etc etc etcu2026u2026.u201D
    I have changed it in the mapping, it's something easy to map a source structure ot a target whit a string field and mark Return as XML in the source field. that's ok.
    But now is the problem: The SOAP adapter changes all the '&' in differents chars as:&|#|34 (i separate whit |in this sample) or the tag > or < in other ascii chars.
    Some one knows what can i do? i have tried too whit the last post, the module config for SOAP adapter: strictXML2PlainBean but it doesn't work.
    Any help will be appreciated.
    Best regards and thanks in advance.
    Thanks in advance and best regards.

    No, the problem is that the SOAP adapter does the escaping of these chars, so i can't control it. I am trying to deploy a EAR in the server, but i guess that an easiest way should exist for this case.
    The main problem is that the thirdparty system has an filter and this kind of chars are not allowed, this system only understand & lt and & gt in the string field.
    Thanks anyway
    Edited by: Cantabria on Mar 18, 2010 3:07 PM

  • Bind Variables with AND in String causing Issues in XML & Report Outputs

    Hi all,
    I'm creating a BI Publisher report (10.1.3.2) and am experiencing an issue with the interprutation of Bind Variables in the Data Template.
    Here is an example of some of the Data template
    <dataTemplate name="BudgetDataBU" description="BudgetDataBU" dataSourceRef="DLXN">
       <parameters> 
          <parameter name="p_Year" dataType="Integer" include_in_output="true"/>
          <parameter name="p_Measure" dataType="character" include_in_output="true"/>
          <parameter name="p_Currency" dataType="character" include_in_output="true"/>
          <parameter name="p_Version" dataType="character" include_in_output="true"/>
       </parameters>
       <dataQuery>
          <sqlStatement name="BusUnits">
               <![CDATA[SELECT DISTINCT CC.BUSINESS_UNIT as BUSINESS_UNIT
                        FROM   DLXN_FACT_DATA_DET FD,
                               DLXN.COST_CENTRE CC
                        WHERE FD.COST_CENTRE = CC.COST_CENTRE
                        AND FD.CAL_YEAR    = :p_Year
                        AND FD.Currency      = :p_Currency
                        AND FD.Measure      = :p_Measure
                        AND FD.Version        = :p_Version                                
                        AND CC.DLXN_VIEW = 'Delexian' ]]>
               </sqlStatement>
           <sqlStatement name="Details">
               <![CDATA[SELECT DLXN_FACT_DATA_DET.VERSION,
                               DLXN_FACT_DATA_DET.CURRENCY,
                               DLXN_FACT_DATA_DET.CAL_YEAR as CAL_YEAR,
                               SUM(nvl(DLXN_FACT_DATA_DET.JAN_AMT,0)) as JAN_AMT,
            </sqlStatement>
        </dataQuery>The problem is with the :p_Measure Bind Variable but it could just as easily be any of the other character parameters.
    The particular string value that is causing a problem is "Travel and Expenditure". I believe it is due to the "AND" in the string but this string value cannot be changed in the database to say "Travel & Expenditure".
    I have thought about using a REPLACE function in the SELECT statement but see this as an ugly solution.
    Any input greatly appreciated.
    Kind Regards,
    Gary.

    We remove this restriction ,fix included in BI Publisher July 2009 update for 10.1.3.4.x. The patch number is 8704846.

  • Odd String Truncation Issue

    Hello all,
    I am having the strangest problem with a crystal report truncating a text field when reading records from the DB.  Basically, I have a varchar(6) string field in my Oracle database that holds batch numbers for credit card transactions.  The report worked fine until some users started getting into batches numbered higher than 999.  Anytime a 4th character is added (ie, 1004), my report will read the string as '100'.  All of the other fields in the record are being read fine.
    Oddly enough, this only happens on some databases/machines and not others.  For instance, a DB dump of this data to a local machine will work fine and the report reads '1004'.  I have captured the SQL the report is using to obtain records and pasted it in an Oracle client (TOAD) and the record pulls fine with the batch number being '1004'.  The width of the field on the report is long enough to display much more than 4 characters, so that's not the issue.  Anyone seen this type of issue before or have any ideas on how to troubleshoot it?
    We are using Crystal Reports XI R2 to design the report.

    Hi Chuck Reed,
    Can you add that field through Add Command and see all digets are coming in ?
    Go in Datbase expert --Under you datbase connection click on Add Command and write sql like
    Select BatchNumber from Table and link the batchnumber with your table batch number and place command batchnumber in report and check.
    Thanks,
    Sastry

  • IP to string node issue

    Hi,
       In our application we are exchanging data on every 50 ms between client and server systems via UDP.  The data exchange between client and server was happening without any issue except the memory leak. Later we found that the IP to String function with dot notation input as false on the UDP listener creates the memory leak. So we changed the IP to String function with dot notation input as true then the memory leak issue was gone.
    Is anybody experienced such memory leak issue with the IP to String Function and how managed this issue? what would be the reason for the memory leak with the IP to String function with dot notation input as false? 
    Thanks
    Sathiyanarayanan

    If dot notation is false, the function needs to query a DNS server, something I would probably not do every 50ms. Querying a DNS server can be slow, so maybe you get a built-up of DNS lookup requests. Can you open a command window and do a "netstat -n" during run. how many connections are listed?
    What is the purpose of your use of the IP-to-string function. How often does the IP change? Is it the same most of the time?
    What is your LabVIEW version? What is your OS? Can you show us some code on how you are using this?
    The Devil wrote:
    I have myself not faced such a problem but I have used the inplace structure for memory management. ...
    This problem cannot be solved with the in-place structure. Your answer is completely meaningless in this context. Can you explain your thought process that led you to suggest this as a solution? Makes no sense to me!
    Message Edited by altenbach on 01-24-2010 09:57 PM
    LabVIEW Champion . Do more with less code and in less time .

  • String Concatenation issue

    Hi all,
    I have a simple query which concatenates three columns together, separated by a comma. Something like...
    SELECT FK_COMMUNITY||', '||FK_BUILDING_ID ||', '|| FK_ROOM_TYPE AS preference
    FROM preferences;
    The issue is that not all these columns are populated, in some cases they all have data and in some cases the data is missing (NULL).
    The problem is the output leaves the formatting off example:
    PREFERENCE
    Avery Hill, ,
    , TUD,
    , DEV,
    , DEV,
    , CUT,
    , CUT,
    , BIN, BINSTA
    , MMA, MMASTE
    , BIN,
    , MMS, MMSSTU
    Any help would be appreciated. Many thanks

    So in general you need to:I'd prefer to use XMLCAST (where it is supported) - or maybe sometimes EXTRACTVALUE :
    SQL> set define off
    SQL> with prefences as (
    select 0 as row_id, 'Avery & Hill' as fk_community, null as fk_building_id , null as fk_room_type from dual
    union select 1, null, 'TUD', null from dual
    union select 2, null, 'DEV', null from dual
    union select 3, null, 'DEV', null from dual
    union select 4, null, 'CUT', null from dual
    union select 5, null, 'CUT', null from dual
    union select 6, null, 'BIN', 'BINSTA' from dual
    union select 7, null, '<MMA>', 'MMASTE' from dual
    union select 8, null, 'BIN', null from dual
    union select 9, null, 'MMS', 'MMSSTU' from dual
    select xmlcast(xmlquery('string-join(./*,",")' passing xmlforest(fk_community, fk_building_id, fk_room_type) returning content) as varchar2(100)) str
    from prefences
    STR                                                                            
    Avery & Hill                                                                   
    TUD                                                                            
    DEV                                                                            
    DEV                                                                            
    CUT                                                                            
    CUT                                                                            
    BIN,BINSTA                                                                     
    <MMA>,MMASTE                                                                   
    BIN                                                                            
    MMS,MMSSTU                                                                     
    10 rows selected.

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

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

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

  • Using StartsWith for String Comparision in Business rules

    hi,
    I need to compare whether a particular string starts with some pre-defined prefixes. These are bound to change from time to time and hence we wanted to use the business rule engine for this. We declared prefixes using "list of values" vocab and
    defined the set. Now, I hoped to use the String.StartsWith() method but couldn't understand if it can be used.
    As of now, we are creating a method and that will be called with 2 parameters. One the string and other is one of the list of values which we want the string to start with. Is there any better way to do this?
    Praveen Behara
    MCST : BizTalk Server 2006 R2, 2010

    Hi Murugesan,
    I need to match a particular series of numbers... say 12xxx,345xxx,567xxx. I am creating a
    Series as a list and the valid values would be 12, 345, 567. I intend to keep them as prefixes i.e. they are not regular expressions. So, they won't be 12.*, 345.*, 567.*. The idea is to keep the vocab close to requirement
    and away from implementation (typically, for a business user). Now, if I want this setup, how will the implementation with
    Match look like?
    Technically, your above solution would work.. but my way of implementation / thought process is for a different purpose.
    Praveen Behara
    MCST : BizTalk Server 2006 R2, 2010

  • Program for string comparision in ABAP

    Hi,
    I require a program in abap for string comparision

    Comparing Strings
    Similarly to the special statements for processing strings, there are special comparisons that you can apply to strings with types C, D, N, and T. You can use the following operators:
    <operator>
    Meaning
    CO
    Contains Only
    CN
    Contains Not only
    CA
    Contains Any
    NA
    contains Not Any
    CS
    Contains String
    NS
    contains No String
    CP
    Contains Pattern
    NP
    contains No Pattern
    There are no conversions with these comparisons. Instead, the system compares the characters of the string. The operators have the following functions:
    CO (Contains Only)
    The logical expression
    <f1> CO <f2>
    is true if <f1> contains only characters from <f2>. The comparison is case-sensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that does not occur in <f2> .
    CN (Contains Not only)
    The logical expression
    <f1> CN <f2>
    is true if <f1> does also contains characters other than those in <f2>. The comparison is case-sensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS contains the offset of the first character of <f1> that does not also occur in <f2>. If it is false, SY-FDPOS contains the length of <f1>.
    CA (Contains Any)
    The logical expression
    <f1> CA <f2>
    is true if <f1> contains at least one character from <f2>. The comparison is case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of the first character of <f1> that also occurs in <f2> . If it is false, SY-FDPOS contains the length of <f1>.
    NA (contains Not Any)
    The logical expression
    <f1> NA <f2>
    is true if <f1> does not contain any character from <f2>. The comparison is case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that occurs in <f2> .
    CS (Contains String)
    The logical expression
    <f1> CS <f2>
    is true if <f1> contains the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.
    NS (contains No String)
    The logical expression
    <f1> NS <f2>
    is true if <f1> does not contain the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
    CP (Contains Pattern)
    The logical expression
    <f1> CP <f2>
    is true if <f1> contains the pattern <f2>. If <f2> is of type C, you can use the following wildcards in <f2>:
    for any character string *
    for any single character +
    Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.
    If you want to perform a comparison on a particular character in <f2>, place the escape character # in front of it. You can use the escape character # to specify
    characters in upper and lower case
    the wildcard character "" (enter # )
    the wildcard character "" (enter # )
    the escape symbol itself (enter ## )
    blanks at the end of a string (enter #___ )
    NP (contains No Pattern)
    The logical expression
    <f1> NP <f2>
    is true if <f1> does not contain the pattern <f2>. In <f2>, you can use the same wildcards and escape character as for the operator CP.
    Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
    DATA: F1(5) TYPE C VALUE <f1>,
          F2(5) TYPE C VALUE <f2>.
    IF F1 <operator> F2.
       WRITE: / 'Comparison true, SY-FDPOS=', SY-FDPOS.
    ELSE.
       WRITE: / 'Comparison false, SY-FDPOS=', SY-FDPOS.
    ENDIF.
    The following table shows the results of executing this program, depending on which operators and values of F1 and F2.
    <f1>
    <operator>
    <f2>
    Result
    SY-FDPOS
    'BD '
    CO
    'ABCD '
    true
    5
    'BD '
    CO
    'ABCDE'
    false
    2
    'ABC12'
    CN
    'ABCD '
    true
    3
    'ABABC'
    CN
    'ABCD '
    false
    5
    'ABcde'
    CA
    'Bd '
    true
    1
    'ABcde'
    CA
    'bD '
    false
    5
    'ABAB '
    NA
    'AB '
    false
    0
    'ababa'
    NA
    'AB '
    true
    5
    'ABcde'
    CS
    'bC '
    true
    1
    'ABcde'
    CS
    'ce '
    false
    5
    'ABcde'
    NS
    'bC '
    false
    1
    'ABcde'
    NS
    'ce '
    true
    5
    'ABcde'
    CP
    'b'
    true
    1
    'ABcde'
    CP
    '#b'
    false
    5
    'ABcde'
    NP
    'b'
    false
    1
    'ABcde'
    NP
    '#b'
    true
    5
    goto sap library if intsalled in ur system and check the above one....

  • String comparision in fields

    HI All,
         I have a requirement to compare strings.
         Like this:
         parameters:  belnr like bkpf-belnr.
         Select * from swwwihead into table t_swwwihead
            where ( WI_TYPE EQ 'F'   or
                    WI_TYPE EQ 'W' ) AND
                    WI_CD GE l_budat.
         X2 = belnr.
         Loop at t_swwwihead.
           X1 = t_swwwihead-TEXT.
           IF X1 byte-cs X2.
             write :/ t_swwwihead-TEXT.
           Endif.
         Endloop.
         I tried to use 'CP' but i could not compare using fields. I mean i have to compare the values in the fields.
    I tried byte-cs but that i can only compare in terms of bytes and my text doesnot have zeros at the begining. and xstring pads zeros to the string to make it a full byte it seems.
    how can i compare this ?

    Hi,
    Try to concatenate * in the beginning and in the end of the to be compared string before using CP..
    Example
    data: X1 type string.
    X1 = 'Approve Parked document 100638133 initiated by USER123'.
    data: X2 type string.
    X2 = '100638133'.
    CONCATENATE '' X2 '' INTO X2.
    IF X1 CP X2.
      write: / 'True'.
    ELSE.
      write: / 'False'.
    ENDIF.
    Thanks,
    Naren
    Message was edited by: Narendran Muthukumaran

  • String Comparision in pl/sql

    Hi,
    i executed the below code and found that output should be 5 but it shows 7(always else part). it is not comparing string in case. can anybody state the reason.
    declare
    check_in_date date;
    var_day varchar2(11);
    rate_id number;
    begin
    check_in_date := '23-mar-2013';
    select to_char(check_in_date, 'DAY') into var_day from dual;
    dbms_output.put_line(var_day);
    select case
    when VAR_DAY = 'SATURDAY' THEN
    5
    WHEN VAR_DAY = 'SUNDAY' THEN
    6
    ELSE
    7
    END
    into rate_id
    from dual;
    DBMS_OUTPUT.PUT_LINE(rate_id);
    end;
    Thanks.
    Vipin

    Change this
    select to_char(check_in_date, 'DAY') into var_day from dual;as
    select to_char(check_in_date, 'fmDAY') into var_day from dual;You need to use the "fm" (format model) specificaton otherwise the value will be right padded with space for the max size.
    SQL> select '"' || to_char(sysdate+level, 'DAY') || '"' without_fm,
      2         '"' || to_char(sysdate+level, 'fmDAY') || '"' with_fm
      3    from dual
      4  connect by level <= 7;
    WITHOUT_FM  WITH_FM
    "FRIDAY   " "FRIDAY"
    "SATURDAY " "SATURDAY"
    "SUNDAY   " "SUNDAY"
    "MONDAY   " "MONDAY"
    "TUESDAY  " "TUESDAY"
    "WEDNESDAY" "WEDNESDAY"
    "THURSDAY " "THURSDAY"
    7 rows selected.

  • String comparision in reverse order

    Hi all
    i want a logic in plsql which compares string and substring
    and soon from last digit in the number to first digit.
    If condition mets gives out put
    for example my input is
    INPUT = 1234567890
    TO COMPARE WITH a column has list of values like
    1234560000
    1234567000
    1234567800....soon
    so now the condition is
    the input 1234567890 should match with the column value
    1234567890
    if value is not there it should match with
    123456789
    if not 12345678 soon till 1 in reverse comparision

    In SQL:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '123456' col1 FROM dual)
      2  SELECT col1,inp,lvl FROM
      3  (SELECT SUBSTR(:my_num,1,level-1) inp,level - 1 lvl FROM
      4  dual CONNECT BY level <= LENGTH(:my_num)) x,t
      5* WHERE t.col1 = x.inp
    SQL> /
    COL1   INP               LVL
    123456 123456              6
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '1234567890' col1 FROM dual)
      2  SELECT col1,inp,lvl FROM
      3  (SELECT SUBSTR(:my_num,1,level-1) inp,level - 1 lvl FROM
      4  dual CONNECT BY level <= LENGTH(:my_num) + 1) x,t
      5* WHERE t.col1 = x.inp
    SQL> /
    COL1       INP               LVL
    1234567890 1234567890         10
    -- in plsql
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2  my_val VARCHAR2(100) := NULL;
      3  BEGIN
      4  FOR I IN REVERSE 1..LENGTH(:my_num) LOOP
      5  DBMS_OUTPUt.PUT_LINE('substring value:'||SUBSTR(:my_num,1,I));
      6  BEGIN
      7  SELECT '123456' INTO my_Val FROM dual WHERE '123456' = SUBSTR(:my_num,1,I);
      8  EXCEPTION
      9  WHEN NO_DATA_FOUND THEN
    10  NULL;
    11  END;
    12  EXIT WHEN my_Val IS NOT NULL;
    13  END LOOP;
    14  DBMS_OUTPUT.PUT_LINE('matched value:'||my_val);
    15* END;
    SQL> /
    substring value:1234567890
    substring value:123456789
    substring value:12345678
    substring value:1234567
    substring value:123456
    matched value:123456
    PL/SQL procedure successfully completed.
    SQL> print :my_num
    MY_NUM
    1234567890

  • String comparision

    String a = "alpha";
    String b = "xxxxalphayyyyyyy";
    is there any method that returns true, if I had to check if String b contains a, otherwise false.....

    What version of Java are you using?
    edit: never mind, you got spoonfed in the meantime, I see
    Edited by: georgemc on Jul 22, 2008 7:12 PM

Maybe you are looking for

  • How to update sales orders using B1WS in SAP 8.8 PL18

    Hello all. We are having a problem updating sales orders using Sap Business One Web Service ( B1WS ). We are running SBO 8.8 PL18, MS-SQL 2008, and all is fine when using the SBO client. But when it comes to updating sales orders through B1WS we just

  • Trouble opening photos

    I have just made a page on my website for historic weather photos & my weather station info & pics. But when I load the page on my computer, the photos only half open then turn grey. A friend informed me the page is loading fine on their non-mac comp

  • Why can I not create pdf files from MS Word documents?

    I'm using Acrobat Pro XI (11.0.5), and Microsoft Word 2007:  I've noticed just recently that, whenever I try to create a pdf file - from within Microsoft Word - I get a message:  Word has stopped working"....  and then the word program crashes.   The

  • BPM WorkSpace- Action Submit -  HTTP 404  - BPM 11g

    Whenever i click on Submit on a User- Initiator task, i get below error... However Instance gets completed on that step and goes to next step. The webpage cannot be found HTTP 404 Most likely causes: •There might be a typing error in the address. •If

  • Needed - BW data model and list of Dimensions and Fact table from BW

    Dear Friends, Can somebody please share SAP BW DATA MODEL (LOGICAL) and share the list of DIMENSION and FACT tables exist in BW? I don't have access to SAP or SAP BW and I am building data-mart and SAP FI/CO will be the source. Thank you very much in