REGEXP_LIKE -- LIKE

Dear all,
How do I change this statement but using LIKE and not regexp_like
SELECT t.COMPONENT, t.TRANSACTION_ID, t.xml, tho.TRANSACTION_TIMESTAMP, tho.USER_NAME FROM TRANSACTION t, TRANSACTION_HISTORY tho
WHERE tho.TRANSACTION_ID = t.TRANSACTION_ID AND REGEXP_LIKE(t.xml, '.*access_code="UPD".*REQ01_User.*<uid>' || affectedUserId || '.*', 'n')
ORDER BY tho.TRANSACTION_TIMESTAMP;

lower(t.xml) LIKE '%access\_code="upd"%req01\_user%<uid>'||lower(affectedUserId)||'%' Escape '\'regards,
Christian Balz

Similar Messages

  • Regexp Like

    Hi
    I have created this sample data
    with test_data as
    SELECT null as data_str
    FROM dual
    UNION ALL
    SELECT 'A' from dual
    UNION ALL
    select 'A|B' from dual
    UNION ALL
    select '|A|B' from dual
    select * from test_dataBy using regexp_like operator I would like to display the below output
    null
    A
    A|BI tried this
    with test_data as
    SELECT null as data_str
    FROM dual
    UNION ALL
    SELECT 'A' from dual
    UNION ALL
    select 'A|B' from dual
    --UNION ALL
    --select '|A|B' from dual
    select * from test_data
    --where regexp_like like '%|%'
    where regexp_like (data_str,'^[null|||'|'||]*$')   But threw this error
    ORA-00996: the concatenate operator is ||, not |
    00996. 00000 -  "the concatenate operator is ||, not |"
    *Cause:   
    *Action:
    Error at Line: 188 Column: 17Am not able to proceed further. Please help!
    Regards,
    Achyut Kotekal

    Hi, Achyut,
    Achyut K wrote:
    By using regexp_like operator I would like to display the below output
    null
    A
    A|B
    Why just those 2 rows? Explain the rules, so we can find a solution that applies those rules to all data, not just a small sample set. You may want to post a few more rows of sample data, to make it more clear what kinds of strings you want to include or exclude from the results.
    If you want to find strings that contain either just a single non-pipe charachter (such as 'A') or 2 or more such characters, each separated by a pipe (such as 'A|B' or 'A|X|A|Y|A|Z') then you can do this:
    SELECT     *
    FROM     test_data
    WHERE     REGEXP_LIKE ( data_str
                  , '^'          || -- Beginning of string
                    '[^|]'          || -- Exactly 1 non-pipe
                    '('          || -- a group consisiting of ...
                       '\|'          || --     a pipe, followed by
                    '[^|]'          || --       any 1 character except a pipe
                    ')*'          || -- group occurs 0 or more  times
                    '$'             -- end of string
    ; I tried this
    with test_data as
    SELECT null as data_str
    FROM dual
    UNION ALL
    SELECT 'A' from dual
    UNION ALL
    select 'A|B' from dual
    --UNION ALL
    --select '|A|B' from dual
    select * from test_data
    --where regexp_like like '%|%'
    where regexp_like (data_str,'^[null|||'|'||]*$')   But threw this error
    ORA-00996: the concatenate operator is ||, not |
    00996. 00000 -  "the concatenate operator is ||, not |"
    *Cause:   
    *Action:
    Error at Line: 188 Column: 17
    Always format your code, to make it easier to spot the extent of quotes and bracketed expressions.
    For example, this mkae the problem much clearer
    SELECT  *
    FROM      test_data
    --where     regexp_like like '%|%'
    WHERE   REGEXP_LIKE ( data_str
                   , '^[null|||'     -- This is a well-formed string literal
                    |           -- What is this supposed to be?
                    '||]*$'          -- This is another well-formed string literal
    ;Since I don't know what you want, I can't way exactly what you should do instead.

  • Regular Expression Validation

    Hi,
    I'm trying to use a regular expression to validate password.
    I create a validation in my item called P502_PASSWORD. I choose regular expression type. At the Validation Expression 2, I put this expression:
    ^(?=.*\d)(?=.*[a-zA-Z])(?!.*[\W_\x7B-\xFF]).{6,15}$
    So, I tried to enter a valid "string" at this item. For example: abc123
    But it doesn't work and I don't know why. I have another item with a e-mail validation with the expression below, and works:
    ^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$
    So, i really don't know what is happening.
    Can someone help me? :)
    Thanks,
    Vivi

    Hi Vivi,
    I checked your regex with my favourite application and it seems to be correct for a 'liberal' interpreter. But POSIX-implementation in Oracle seems to be quite strict. At least, I get an ORA-12728 ("invalid range in regular expression") when executing your string with "REGEXP_LIKE". I would take the regex apart bit by bit and see when the regex starts to work with REGEXP_LIKE, like in the following example:
    BEGIN
      dbms_output.put_line(case when regexp_like('aBc123','^(((\d)|([[:alpha:]])){6,15})$') then 'hit' else 'miss' end);
    END;
    /This is of course not exactly the expression you wanted, but I guess it's not very far away and produces a 'hit'. ;)
    If anybody finds out what exactly caused the error I'd like to know. My first guess was the asterisk in combination with {6,15}, but just removing it didn't do the trick.
    -Udo

  • SQL (Like /REGEXP_LIKE)

    Can you help me to write a query which returns emp_name with the first name matches with the value in reference table?
    EmployeeTable_*
    Id     Emp_Name
    1     Mark Anthony
    2     Issac Newton
    3     Albert Einstein
    4     Abraham Lincoln
    ReferenceTable_*
    First_Name
    Mark
    Albert
    Output*
    Id     Emp_Name
    1     Mark Anthony
    3     Albert Einstein
    Can we use REGEXP_LIKE here?if yes, please tell me how the query should be.
    Thanks
    Ben

    You can just join the tables with LIKE:
    with emp as
        select 1 as id,     'MARK Anthony' as emp_name from dual union all
        select 2,   'Issac Newton' from dual union all
        select 3,   'Albert Einstein' from dual union all
        select 4,   'Abraham Lincoln' from dual union all
        select 5,   'Markus Aurelius Cesar' from dual
    ), ref as
       select 'Mark' as first_name from dual union all
       select 'Albert' from dual
    select
    emp.id,
    emp.emp_name
    from ref
    join emp
    on emp.emp_name like ref.first_name||'%';But the above will give you Markus Aurelius and not MARK Anthony.
    So you could do it with REGEXP_LIKE:
    with emp as
        select 1 as id,     'MARK Anthony' as emp_name from dual union all
        select 2,   'Issac Newton' from dual union all
        select 3,   'Albert Einstein' from dual union all
        select 4,   'Abraham Lincoln' from dual union all
        select 5,   'Markus Aurelius Cesar' from dual
    ), ref as
       select 'Mark' as first_name from dual union all
       select 'Albert' from dual
    select
    emp.id,
    emp.emp_name
    from ref
    join emp
    on regexp_like(emp.emp_name,'^'||ref.first_name||'([[:space:]]|$)','i')That regexp matches where emp_name begins with first_name followed by either some whitespace or the end of string. The 'i' makes the match case insensitive.

  • REGEXP_LIKE help with literal single-quote

    I'm trying to write a check constraint to validate email addresses that may include an apostrophe in the email address. Such as joe.o'[email protected] Here is my sample setup:
    create table emails
    ( email_address varchar2(150)
    insert into emails values('[email protected]') ;
    insert into emails values('[email protected]') ;
    insert into emails values('joey.o''[email protected]') ;
    commit;
    sql> select * from emails;
    EMAIL_ADDRESS
    [email protected]
    [email protected]
    joey.o'[email protected]
    alter table emails add constraint email_address_format_ck
        CHECK ( REGEXP_LIKE ( email_address, '^[a-z0-9._%-]\'?+@[a-z0-9._%-]+\.mil$','c'));
    ERROR at line 2:
    ORA-00911: invalid characterIt doesn't like *\'?*
    My understanding is this means one or more single-quotes. Anyone know the correct syntax to accept apostrophes?

    Hi,
    jimmyb wrote:
    ... insert into emails values('joey.o''[email protected]') ;
    That's the correct way (actually, that's one correct way) to include a single-quote in a string literal: use 2 single-quotes in a row.
    ... alter table emails add constraint email_address_format_ck
    CHECK ( REGEXP_LIKE ( email_address, '^[a-z0-9._%-]\'?+@[a-z0-9._%-]+\.mil$','c'));Here, the 2nd argument to REGEXP_LIKE is a string literal, just like 'joey.o''[email protected]' was a string literal.
    To include a single-quote in the middle of this string literal, do the same thing you did before: use 2 of them in a row:
    CHECK ( REGEXP_LIKE ( email_address, '^[a-z0-9._%''-]+@[a-z0-9._%-]+\.mil$','c'));There were a couple of other problems, too.
    I'm sure you meant for the apostrophe to be inside the square brackets. Inside square brackets, \ does not function as an escape character. (Actually, single-quote has no special meaning in regular expressions, so there's no need to escape it anyway.)
    I'm not sure what the '?' mark was doing; I left it out.
    Of course, you'll have trouble adding the CHECK constraint if any existing rows violate it.
    Edited by: Frank Kulash on Feb 10, 2012 6:52 PM

  • Can we achieve like functionality with any other way

    Hi experts,
    Can any one explain how to achieve the results we get using like operator in any other alternate way
    looking for response
    regards
    naidu

    REGEXP_SUBSTR
    First, here is my query with LIKE...
    SQL> SELECT * FROM scott.emp
      2  WHERE ename LIKE 'J%ES';
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
    2 rows selected...and here is the same logic with REG_SUBSTR
    SQL> SELECT * FROM scott.emp
      2  WHERE REGEXP_SUBSTR ( ename, '^J.*ES$') IS NOT NULL;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
    2 rows selected.There is a REGEXP_LIKE, too, but I avoided it because it contains the word "LIKE" ;)

  • Looking for a keyword using like query which could contain multiple occurrence in the same column

    I am facing an issue. A bunch of my frontend JSP code has been stored in few tables of my database (65 rows in a table), which I have identified using few like queries. Now I want to update a Href link which is present in all these queries. But since these column entries are very long (50-60 lines long) and it is possible that a few rows may the link (which is to be replaced), multiple times,  I am not sure that if a simple update query using a single like will work for it or not?
    Any suggestion/ideas are welcome.
    Please let me know if you require any more info.

    Hi,
    e5d4d744-cf66-4fe0-8353-bbd8fd826b21 wrote:
    I am facing an issue. A bunch of my frontend JSP code has been stored in few tables of my database (65 rows in a table), which I have identified using few like queries. Now I want to update a Href link which is present in all these queries. But since these column entries are very long (50-60 lines long) and it is possible that a few rows may the link (which is to be replaced), multiple times,  I am not sure that if a simple update query using a single like will work for it or not?
    Any suggestion/ideas are welcome.
    Please let me know if you require any more info.
    Yes; whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), so that the people who want to help you can re-create the problem and test their ideas.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Simplify the problem as much as possible.  For example, if your strings are sometimes up to 4000 characters long, you don't have to post any data that's nearly that long.  You can probably show what you want with strings that are 80 characters long.
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002#9362002
    This statement:
    UPDATE table_x
    SET str  = REPLACE ( str
                       , old_link
                       , new_link
    WHERE   str  LIKE  '%' || old_link || '%'
    will change all occurrences of old_link to new_link.  It will only change the rows where old_link occurs, but, aside from that, it doesn't matter how many times old_link occurs in str:  if it appears 2 times in the same str, then both occurrences will be changed to new_link.
    Watch out for the "mother is in chemotherapy" problem.  If old_link is 'bar.com', the statement above will change 'fubar.com'.  You may need REGEXP_REPLACE and/or REGEXP_LIKE if you need to consider what (if anything) comes immediately before 'bar.com' when deciding whether or not to change it.

  • How to use LIKE Operator with my query requriment

    HI all,
    I have a requirement as follows
    EMPID ENAME JOB SAL
    10 RAJ KAMAL MANAGER 25000
    20 KAMAL RAJ NAYAK CLERK 4000
    30 NARENDAR GUPTA ANALYST 20000
    40 ASHUTOSH GUPTA DEVELOPER 10000
    50 ASHUTOSH NAYAR PROGRAMMER 15000
    i am searching enames such that i need to get the whole name even if i search with just a single LETTER/WORD immaterial of the order they exist in the name for which i need to get the whole name.(INFACT WORD comparision)
    ex:
    1) select * from emp where ename like '%ka%'
    i am getting:
    10 RAJ KAMAL MANAGER 25000
    20 KAMAL RAJ NAYAK CLERK 4000
    This is not what i need i need just word camparision not letters comparision let me tell you...
    select * from emp where ename like '%amal%'
    Even for this query ill get the same output.. this is not my option to go..
    I need just word comparision with starting letter and immaterial of the word position in the name
    If it is possible to do with query please let me know..
    Thanking you
    Narendar Vishwanatham

    Full example:
    SQL> ed
    Wrote file afiedt.buf
      1  with e as (select 10 as empid, 'RAJ KAMAL' as ename, 'MANAGER' as job, 25000 as sal from dual union all
      2             select 20, 'KAMAL RAJ NAYAK', 'CLERK', 4000 from dual union all
      3             select 30, 'NARENDAR GUPTA', 'ANALYST', 20000 from dual union all
      4             select 40, 'ASHUTOSH GUPTA', 'DEVELOPER', 10000 from dual union all
      5             select 50, 'ASHUTOSH NAYAR', 'PROGRAMMER', 15000 from dual)
      6  -- END OF TEST DATA
      7  select *
      8  from e
      9* where regexp_like(ename,'(^| )KA( |$)')
    SQL> /
    no rows selected
    SQL> ed
    Wrote file afiedt.buf
      1  with e as (select 10 as empid, 'RAJ KAMAL' as ename, 'MANAGER' as job, 25000 as sal from dual union all
      2             select 20, 'KAMAL RAJ NAYAK', 'CLERK', 4000 from dual union all
      3             select 30, 'NARENDAR GUPTA', 'ANALYST', 20000 from dual union all
      4             select 40, 'ASHUTOSH GUPTA', 'DEVELOPER', 10000 from dual union all
      5             select 50, 'ASHUTOSH NAYAR', 'PROGRAMMER', 15000 from dual)
      6  -- END OF TEST DATA
      7  select *
      8  from e
      9* where regexp_like(ename,'(^| )KAMAL( |$)')
    SQL> /
         EMPID ENAME           JOB               SAL
            10 RAJ KAMAL       MANAGER         25000
            20 KAMAL RAJ NAYAK CLERK            4000
    SQL>

  • How to use REGEXP_LIKE or REGEXP_INSTR in a query

    Hello All,
    I would like to do a query on a column of a table to see if it has any combination of ALL of up to 5 words. So for example, if I search for (Apple, Banana, Blueberry), I would like to see the following data returned
    Apples are better than Bananas and Blueberrys.
    Blueberry recipes contain apples and bananas.
    Bananas can be baked into bread with Apples but not Blueberrys.
    So the criteria I would like to meet are
    1. All three words are in the data returned
    2. The three words can be in any order
    3. There can be any or no other text in between the three words.
    4. The query is case insensitive.
    So far I have come up with this
        select * from hc_work_items where REGEXP_LIKE(wki_name, '(Apple)', 'i') AND REGEXP_LIKE(wki_name, '(Banana)', 'i') AND REGEXP_LIKE(wki_name, '(Blueberry)', 'i') This does the trick but I am wondering if it looks ok (I am new to REGEXP and also tuning queries for efficiency). I did also try
        select * from hc_work_items where REGEXP_INSTR(wki_name, '(Apples|Blueberrys|Bananas)') > 0 but this was returning only an OR selection of the words, not all three.
    Thank you for any advice !
    Edited by: 991003 on Feb 28, 2013 8:32 AM
    Edited by: 991003 on Feb 28, 2013 8:34 AM

    Hi,
    Welcome to the forum!
    991003 wrote:
    Hello All,
    I would like to do a query on a column of a table to see if it has any combination of ALL of up to 5 words. So for example, if I search for (Apple, Banana, Blueberry), I would like to see the following data returned
    Apples are better than Bananas and Blueberrys.
    Blueberry recipes contain apples and bananas.
    Bananas can be baked into bread with Apples but not Blueberrys.It doesn't seem like you're really looking for words. In most of these cases, the text you are looking for (e.g. 'Apple') is not a separate word, but is a sub-string embedded in a longer word (e.g., 'Apple<b>s</b>').
    What if someone uses the correct plural of 'Blueberry', that is, 'Blueberr<b>ies</b>? You might have to instruct your users to look for only the common part; in this case 'Blueberr'.
    So the criteria I would like to meet are
    1. All three words are in the data returned
    2. The three words can be in any order
    3. There can be any or no other text in between the three words.
    4. The query is case insensitive.
    So far I have come up with this
    select * from hc_work_items where REGEXP_LIKE(wki_name, '(Apple)', 'i') AND REGEXP_LIKE(wki_name, '(Banana)', 'i') AND REGEXP_LIKE(wki_name, '(Blueberry)', 'i')
    Yes, I think you'll have to do separate searches for each of the 3 targets.
    Regular expressions might not be the most efficient way. INSTR or LIKE will probably be faster, e.g.
    WHERE     UPPER (wki_name)   LIKE '%APPLE%'
    AND     UPPER (wki_name)   LIKE '%BANANA%'
    AND     UPPER (wki_name)   LIKE '%BLUEBERRY%'Oracle is smart enough to "short crcuit" compound conditions like this. For example, if if looks for 'Apple' first, and doesn't find it on a given row, then it doesn't waste time looking for the other targets on the same row.
    This does the trick but I am wondering if it looks ok (I am new to REGEXP and also tuning queries for efficiency). I did also try
    select * from hc_work_items where REGEXP_INSTR(wki_name, '(Apples|Blueberrys|Bananas)') > 0 but this was returning only an OR selection of the words, not all three.Exactly. You could look for any of the 6 possible permutations, but that's really ugly, inefficient, and unscalable. (If you ever need 4 targets, there are 24 permutations; with 5 targets there are 120.) You were better off the first time, with 3 separate conditions.
    Oracle Text is a separate product that was designed for jobs like this. It's a separate product, that requires a separate license, and it has Text

  • Regexp_like query

    col1
    ======
    computer a
    computer b
    computer1
    computer 2
    laptop a
    laptopb
    laptop c
    ipad 1
    ipad2
    i want to output where name start with 'computer' and 'laptop' with regexp_like

    SQL> with t as
      2  (select 'computer1' str from dual union all
      3  select 'computer2' str from dual union all
      4  select 'laptop1' str from dual union all
      5  select 'ipad1' str from dual union all
      6  select 'c' str from dual union all
      7  select 'laptop2' str from dual
      8  )
      9  select *
    10  from t
    11  where regexp_like (str,'^computer|laptop');
    STR
    computer1
    computer2
    laptop1
    laptop2However, you can do this without regular expression
    with t as
    (select 'computer1' str from dual union all
    select 'computer2' str from dual union all
    select 'laptop1' str from dual union all
    select 'ipad1' str from dual union all
    select 'c' str from dual union all
    select 'laptop2' str from dual
    select *
    from t
    where str like 'computer%'
       or str like 'laptop%'Edited by: 884476 on Mar 22, 2012 1:31 AM

  • How to achive equivalent of contains in java using Like operator

    Hi,
    Could anyone please enlighten me on this issue.
    I need to achieve through the query to reduce the unnecessary of loop through.
    Lets say:
    I have a table called BLACKLISTPASSWORD with column BPW.
    example record in column (BPW)
    Welcome
    Welcome1
    Welcome123
    I want make a query like
    SELECT BPW
    FROM BLACKLISTPASSWORD
    WHERE lower(BPW) LIKE 'welcome1234%'Expecting a result true if any sequence matches in above case expecting true bcz Welcome123 is there in DB.
    Plz correct me in the query to achieve this.
    Edited by: Deekay on Aug 2, 2012 12:40 AM

    Deekay wrote:
    Hi,
    Could anyone please enlighten me on this issue.
    I need to achieve through the query to reduce the unnecessary of loop through.
    Lets say:
    I have a table called BLACKLISTPASSWORD with column BPW.
    example record in column (BPW)
    Welcome
    Welcome1
    Welcome123
    I want make a query like
    SELECT BPW
    FROM BLACKLISTPASSWORD
    WHERE lower(BPW) LIKE 'welcome1234%'Expecting a result true if any sequence matches in above case expecting true bcz Welcome123 is there in DB.
    Plz correct me in the query to achieve this.
    Edited by: Deekay on Aug 2, 2012 12:40 AMYou can use as
    SELECT BPW
    FROM BLACKLISTPASSWORD
    WHERE lower(BPW) LIKE 'welcome%'This will return
    Welcome
    Welcome1
    Welcome123
    If you want Output as
    >
    Welcome1
    Welcome123
    >
    i.e. Welcome followed by a/more digits; Below works on Oracle 10g or higher.
    SELECT BPW
    FROM BLACKLISTPASSWORD
    WHERE regexp_like(BPW, 'welcome[[:digit]]+', 'i');

  • Select * from tbl where product like ('abc','def','rgh');

    Hi Guys,
    My requirement is I need to filter by providing date value with some of the porduct details and prod_id may differ with product like
    prod_id product date
    01 abc 01/2012
    02 abc 02/2012
    03 def 03/2012
    How can we put multiple text conditions using LIKE operator in where clause of the sql query.
    if we use union to combine all the sql queries, how can we filter by entering date value.
    SQL>select * from tbl where product like ('abc','def','rgh');
    Please provide any ideas on the same.
    Thanks in advance!
    -LK

    select * from tab1 where regexp_like(product,'^abc|def|rgh');

  • REGEXP_LIKE for more of a range of numbers.

    Hi to all.
    It's a pleasure to receive your help.
    I am using Oracle Database 10g Enterprise Edition Release 10.2.0
    I want from a string of pairs of numbers (where each pair is a range) to know if my number parameter is between a of the pairs.
    Something like the following.
    SQL:
    declare
      i     pls_integer := 0;
      s     varchar2(100) := '^([74010000-74019999]|[85990000-85990999])';
      test1 varchar2(8) := '64010000';
      test2 varchar2(8) := '74010000';
    begin
      begin
        select 1 into i from dual where regexp_like(test1, s);
        dbms_output.put_line(i);
      exception
        when no_data_found then
          dbms_output.put_line(0);
      end;
      begin
        select 1 into i from dual where regexp_like(test2, s);
        dbms_output.put_line(i);
      exception
        when no_data_found then
          dbms_output.put_line(0);
      end;
    end;
    With the expected result below.
    Output (It did not happen):
    0
    1
    Actual Output:
    1
    1
    Suggestions?
    I'm looking for the correct literal.
    Thank in advance,
    Filippe

    Hi,
    Don't try to compare numbers to strings; compare numbers  to other numbers.
    If you must get the input as a string (a delimited list of numbers) then use REGEXP_SUBSTR to find numeric sub-strings, and convert them to numbers.
    Here's how you could do it in pure SQL:
    CREATE TABLE  test
    (   n  NUMBER
    INSERT INTO test (n) VALUES (64010000);
    INSERT INTO test (n) VALUES (74010000);
    VARIABLE  str  VARCHAR2 (200)
    EXEC     :str := '(74010000-74019999)|(85990000-85990999)';
    WITH  got_nums AS
        SELECT TO_NUMBER ( RTRIM ( REGEXP_SUBSTR ( :str
                                                 , '\d+-'
                                                 , 1
                                                 , LEVEL
                         )  AS low_num
         ,    -TO_NUMBER ( REGEXP_SUBSTR ( :str
                                         , '-\d+'
                                         , 1
                                         , LEVEL
                         )  AS high_num
         FROM    dual
         CONNECT BY LEVEL <= 1 + LENGTH (:str)
                               - LENGTH (REPLACE (:str, '|'))
    SELECT  n
    ,       CASE
                WHEN  EXISTS (
                                SELECT  1
                                FROM    got_nums
                                WHERE   test.n  BETWEEN  low_num
                                                AND      high_num
                THEN  1
                ELSE  0
            END  AS found
    FROM    test
    In PL/SQL, it's simpler.  You don't have use CONNECT BY to simulate a loop.

  • Validate PO Box  with RegExp_Like

    I'm trying to validate strings with variations of PO BOX, P.O. BOX 3232, Post Office Box 2323. The functions is like so:
    CREATE or REPLACE FUNCTION FN_CHK_PO_BOX (v_str in VARCHAR2)
    RETURN VARCHAR2
    AS
    BEGIN
       IF REGEXP_LIKE (v_str, '^[p|P][\s]*[o|O][\s]*[b|B][\s]*[o|O][\s]*[x|X][\s]*[a-zA-Z0-9]*|\b[P|p]+(OST|ost|o|O)?\.?\s*[O|o|0]+(ffice|FFICE)?\.?\s*[B|b][O|o|0]?[X|x]+\.?\s+[#]?(\d+)*(\D+)*\b$') THEN
              RETURN 'PO BOX Not Permitted';
       ELSE
              RETURN NULL;
       END IF;
    END FN_CHK_PO_BOX;
    select FN_CHK_PO_BOX('P.O. BOX 2323') from dual;For some reason it keeps evaluating to NULL and not returning "PO BOX Not Permitted" as expected. Not sure, any ideas?

    The patterns depends on how flexible you want to be with the string, take a look at those rows that were left out:
    SQL> with t as (
      2  select 1 num, 'P.O. BOX 2323' expr from dual union
      3  select 2, 'POST OFFICE BOX 2323' from dual union
      4  select 3, 'P O BOX 2323' from dual union
      5  select 4, 'P O BOX 2323' from dual union
      6  select 5, 'PO BOX 2323' from dual union
      7  select 6, 'p.o boX 2323' from dual union
      8  select 7, 'pO. BoX 2323' from dual union
      9  select 8, 'P. OFFICE BOX 2323' from dual union
    10  select 9, 'POST O. BOX 2323' from dual union
    11  select 10, 'POST OFF. BOX 2323' from dual union
    12  select 11, 'P.O OFFICE BOX 2323' from dual union
    13  select 12, 'POST OFFICE BOX 2323' from dual union
    14  select 13, 'POST OFFICE BOX ' from dual union
    15  select 13, 'POST OFFICE BOX ABC' from dual
    16  )
    17  select expr
    18    from t
    19  where regexp_like(expr
    20        , '^((P\.?\s*O\.?)|(POST\s+OFFICE))\s*B\s*O\s*X\s*\d+$','i')
    21  /
    EXPR
    P.O. BOX 2323
    POST OFFICE BOX 2323
    P O BOX 2323
    P O BOX 2323
    PO BOX 2323
    p.o boX 2323
    pO. BoX 2323
    POST OFFICE BOX 2323
    8 rows selected
    SQL>

  • Multiple like statements in a query

    Hi,
    I wonder if it's possible to have multiple like statements in a query.
    suppose instead of
    select * from someTable where remarks like '%ab%'
    I want to search for many string patterns such as '%edi%' '%odi%' '%di%' '%gf%' '%od%' '%podi%' etc. in one query.
    BTW, the table contains many millions of records.
    Regards
    Crusoe
    Edited by: Crusoe on 19-Jan-2009 00:25

    Crusoe wrote:
    This regexp_like function does not work with the development server to which I have rights to create tables etc. I guess it only works in 10g or greater. However i tried a quick test in the production server and it worked. It returned rows where the values between the | characters were found anywhere in the field ( I must learn this regex syntax sometime). Yes, regular expressions are 10g upwards. (You really should have your development server reflect your production server)
    There was a thread a while back giving an introduction to regular expressions...
    Introduction to regular expressions ...

Maybe you are looking for

  • Message Driven Bean: problem with @RunAs annotation

    I am having a problem using the @RunAs annotation in a message driven bean. I would like the code in my onMessage() method to be executed with a specific role/user, so I want to use the @RunAs annotation to achieve this. I am running weblogic 10.0. I

  • Was I charged twice for my song purchase today

    I purchased a song today for .99 cents, I had over $32.00 showing as my balance to use to buy products in Apple Store, and I did see the balance go down after the purchase, so why is there a $1.00 pending charge on my credit card?  I don't ever remem

  • Drag and Drop as an Assessment in Captivate 7

    Hello- I am having an extreme amount of difficulty when it comes to using this function in Captivate 7. The following is a list of questions that I cannot seem to find the answer to anywhere online. After assigning the answers (as in which box gets d

  • SRM 5.0 as an Add on with ECC 6.0

    Even i have the same question on how we would manage the distibution model when the SRM System is installed as an add on with ECC. Since being on the same client here are some of the Questions. I have also opened a new thread on this. 1.) How would t

  • Do you know where is the rules of engagement ? How often do you read It ?

    Hi, Do you know where is the [rules of engagement|https://wiki.sdn.sap.com/wiki/x/FgQ] ? Many people know exactaly where it is, but i noted that major of SCN never read this document. Today i noted this document link in: Left box menu in [Community G