How to check with 3 values of segment data

Hi all

The description has 4 segments separated with spaces, so I need to check if all the lines are there since the 3 combinations of the value of 'ABC100 (1). CCC (2). 5418 (3) .AR (3)'

create table sample_test(cross_number varchar2 (15), item_id issue, description varchar2 (20));

insert into sample_test values (12 345 100,'ABC100.) CCC.5418.AR');

insert into sample_test values (12 346 101,'ABC100.) DDD.5418.AR');

insert into sample_test values (12347,'ABC101.) DDD.5418.AR');

insert into sample_test values (12347,'ABC102.) DDD.5418.AR');

CROSS_NUMBERITEM_IDDESCRIPTION
12345100ABC100. CCC.5418.AR
12346101ABC100. DDD.5418.AR
12347102ABC101. DDD.5418.AR
12347103ABC102. DDD.5418.AR

Expected results

CROSS_NUMBERITEM_IDDESCRIPTION
12345100ABC100. CCC.5418.AR
12346101ABC100. DDD.5418.AR

Thank you

Post edited by: Rajesh123 added test additional to understand business

Have you run my query... I get the expected result. See below...

SQL > SELECT * FROM sample_test;

CROSS_NUMBER ITEM_ID DESCRIPTION

--------------- ------- --------------------

12345 100 ABC100. CCC.5418.AR

12346 101 ABC100. DDD.5418.AR

12347 102 ABC101. DDD.5418.AR

12347 103 ABC102. DDD.5418.AR

SQL > WITH qry1 LIKE

2 (SELECT cross_number,

item_id 3,.

REGEXP_SUBSTR 4 (DESCRIPTION,'[^.] +', 1, 1) col1,.

5 REGEXP_SUBSTR (DESCRIPTION,'[^.] +', 1, 1) col2.

6 REGEXP_SUBSTR (DESCRIPTION,'[^.] +' 1, 3) col3.

7 REGEXP_SUBSTR (DESCRIPTION,'[^.] +' 1, 4) col4

8 OF THE sample_test)

9. SELECT *.

Qry1 q1 10

11. WHERE EXISTS (SELECT NULL

Qry1 T2 12

13 WHERE q1.col1 = q2.col1

14 AND q1.col3 = q2.col3

15 AND q1.col4 = q2.col4

16 AND q1.cross_number <> q2.cross_number);

CROSS_NUMBER ITEM_ID COL1 COL2 COL3 COL4

--------------- ------- ---------- ---------- ---------- ----------

12345 100 ABC100 ABC100 5418 AR

12346 101 ABC100 ABC100 5418 AR

Thank you

Ann

Tags: Database

Similar Questions

  • How to check if a value exists in a column

    Hello Experts,

    version: 10.1.0.5

    I am a novice in pl/sql programming. I am trying to create a procedure that checks if a value exists in a column and if it is not it inserts. Here's the procedure and errors,

    SQL > CREATE OR REPLACE PACKAGE BODY manr.audit_pkg

    2 PROCEDURE audit_proc (number of p_sessionid, p_username VARCHAR2, date of the p_date) IS

    3 BEGIN

    4 If p_sessionid not in (select manr.audit_history sessionid)

    5. can

    6 INSERT INTO manr.audit_history VALUES (p_sessionid, p_username, p_date);

    7 validation;

    8 end if;

    9 END;

    10 END audit_pkg;

    11.

    WARNING: The body of a Package created with compilation errors.

    SQL > show error

    PACKAGE BODY HÉLÈNE errors. AUDIT_PKG:

    LINE/COL ERROR

    -------- -----------------------------------------------------------------

    4/1 PL/SQL: statement ignored

    4/22 PLS-00405: subquery not allowed in this context

    Could you please tell me where I'm wrong. Thanks for your help.

    Rocky

    Hello

    If p_sessionid not in (select manr.audit_history sessionid)

    Try:

    .....

    Select count (*) in the v_sessionid of manr.audit_history

    where sessionid = p_sessionid;

    If v_sessionid > 0 then

    .....

    on the other

    ....

    end if;

    Ziut

  • How to check if the value is NULL in the script

    Please, tell which function should I use to check if the value is NULL
    as: If some_member = NULL then...

    Thank you very much

    If you mean #missing:

    Commission (IF (sales <> #MISSING))
    Commission = sales *. 1;
    Another Commission = #MISSING;
    ENDIF ;);

    This example is from the SER60

    PLEASE NOTE: For some reason, the not equals sign does not appear on the first line of the IF statement. (i.e. IF (SALES does not #MISSING))

  • Satellite L50t-A-145 drivers - how to check that they are up to date

    I would like to know how to check the driver updates. My Office Help does not work. Is this something that happens in the background after I recorded my laptop?

    What do you mean with injection of funds? Can you please what application does not work exactly?

  • How to check the slider back row contains data or not

    Hi all


    How to check whether or not the cursor returned row contains data in one of its field.


    Thank you and best regards,
    Prakash P

    Use ROWCOUNT %
    Use % NOTFOUND

    example of

    DECLARE
    
       id    number;
       desc varchar2(10);
       CURSOR cursor_one IS
          SELECT
              id, desc
          FROM
              table;
    BEGIN
       OPEN cursor_one;
       LOOP
          FETCH cursor_one INTO id, desc;
          EXIT WHEN cursor_one%ROWCOUNT > 20 OR cursor_one%NOTFOUND;
       ...
       END LOOP;
       CLOSE cursor_one;
    END;
    
  • How to check if the value of text is in a view accessor? How can I check for validation?

    Hi Experts ADF,

    JDeveloper 12.1.1.3.0

    I have a VO with a Segment1 column. And I have an accessor in my VO as SegmentVA which contains all the numbers.

    So in the user interface, I'm having a Segment1 as an inputText. The user should then enter values in inputText.  How can I check to validate that the value you enter must be valid within the ViewAccessor.

    Thank you

    Animesh

    You can use a declarative approach and define the Validation rule on EO attribute.

    Or you can create the method in your ViewObjectImpl class, expose this method as a customer interface, create custom for your input field validator and invoke the VO method from there.

    Dario

  • How to check an ascii value of the character in the string

    Hi all
    I have a string that contain alphanumeric values.
    I want only numeric values in this string.
    FRO this purpose.
    I created a varry
    TYPE tab IS VARRAY(10) OF VARCHAR2(10) ;
       var tab
    ;
    variable var of type varray contain this string

    and now I want to check each character in this string at end of validation

    How can I check this particular string

    can I use loop?

    Hello

    If str is a string, then

    REGEXP_LIKE ( str
                , '^[[:digit:]]+$'
                )
    

    Returns TRUE if and only if str contains digits (0 ith 9) and nothing else.
    Here's a way you can use REGEXP_LIKE in PL/SQL:

    SET     SERVEROUTPUT     ON
    
    DECLARE
        str          VARCHAR2 (10)     := '123.4';
    BEGIN
        IF  REGEXP_LIKE ( str
                      , '^[[:digit:]]+$'
                  )
        THEN
         dbms_output.put_line (  str
                        || ' is all digits.'
                        );
        ELSE
         dbms_output.put_line (  str
                        || ' contains something besides digits, or is NULL'
                        );
        END IF;
    END;
    /
    

    Published by: Frank Kulash, December 12, 2011 09:13
    Added PL/SQL example

  • How to check the current values of COMMIT_WAIT and COMMMIT_LOGGING

    Is it possible that you can check in a session to determine the current settings for COMMIT_WAIT and COMMMIT_LOGGING? I am not referring to a situation where they are defined via ALTER SYSTEM and changed the world, but changed using ALTER SESSION and locally defined. I'm currently testing a trigger to do it for a very specific batch user and just need to be able to log on and check if the adjustment was established successfully or not.

    >
    Is it possible that you can check in a session to determine the current settings for COMMIT_WAIT and COMMMIT_LOGGING?
    >
    Well, since these are the initialization parameters, you can check the PARAMETER V view $

    select name, value from v$parameter
    where name like 'commit%'
    
    NAME,VALUE
    commit_point_strength,1
    commit_write,
    commit_wait,
    commit_logging,
    

    And after changing their

    alter session set commit_logging = 'IMMEDIATE';
    alter session set commit_wait = 'FORCE_WAIT' ;
    
    NAME,VALUE
    commit_point_strength,1
    commit_write,
    commit_wait,FORCE_WAIT
    commit_logging,IMMEDIATE
    
  • How to check the previous value of the element in a multi-record block

    Oracle Version: 10 g
    Forms Version: 10 g

    Hi all
    Hello everyone, I have a multi-dossier block in a form where one of the values of elements is of LOV.user can select the value of LOV.

    If once the user selects the value of LOV and moves to the next of the multi-file record, and selects the value of LOV again, I shouldn't allow users to select the previous value of the user in order to avoid duplication of records.

    and important remark is that I should get there before you save it in the database because once registered in the database I can compare the values and hide the previous value.


    Any help will be appreciated.


    Thanks and greetings

    This is a question frequently asked in the forum! There are several different solutions. Take a look at the following articles. Both will perform the necessary verification of duplicates.
    Forms - registration of treatment group (value in double check...
    or
    Avoid records duplicated in a block

    If none of these solutions don't work for you, search the forum for other options.

    Hope this helps,
    Craig B-)

    If someone useful or appropriate, please mark accordingly.

  • How to deal with NULL values in regexp_substr?

    DECLARE
       TYPE t_rec IS TABLE OF VARCHAR2(200);
    
    /* case 1 */
       l_input    varchar2(100) := '28/09/2009 00:00:00|AFRISB|FC|773|7|17|512|76|60|U|';
    /* case 2 */
    --   l_input    VARCHAR2(100) := '06/10/2009 00:00:00|PDIERR|PS|999|0|1|0|0||U|';
       l_bars     PLS_INTEGER;
       l_fields   PLS_INTEGER;
       l_rec      t_rec := t_rec();
    BEGIN
       l_bars     := regexp_count(l_input, '\|', 1, 'i');
       l_fields   := l_bars + 1;
    
       FOR fld IN 1 .. l_fields
       LOOP
          l_rec.EXTEND();
    
          l_rec(fld)   := REGEXP_SUBSTR(l_input, '[^|]+', 1, fld);
          dbms_output.put_line('Fld ' || fld || ': ' || l_rec(fld));
       END LOOP;
    END;
    

    The above code is that I break a string of pipe delimited into individual elements.

    Looking at the case 1 in the code, the output displays each field correctly. However in case 2, the 9th field is null (nothing between the two tubes) so the regexp_substr 19 online is assigning the 'U' in the box 10 as a field 9.

    What should I do to get the line 19 to correctly assign a NULL value to field 9?

    Information about the version of the database are:

    BANNER

    --------------------------------------------------------------------------------

    12 c Oracle database Release 12.1.0.1.0 - 64 bit Production
    PL/SQL Release 12.1.0.1.0 - Production
    CORE Production 12.1.0.1.0
    AMT for 64-bit Windows: Version 12.1.0.1.0 - Production

    NLSRTL Version 12.1.0.1.0 - Production

    Thank you

    Steve

    Hello

    If you want to use regexes, so instead of

    REGEXP_SUBSTR (l_input, "[^ |]") +', 1, fld);

    use

    REGEXP_SUBSTR (l_input

    , '([^|] *)(\|| $)'

    -P

    fld

    NULL

    -P

    );

    . The 6th argument to REGEXP_SUBSTR is a new feature of Oracle 11.1.  It's kind of a back reference. Normally, REGEXP_SUBSTR returns the substring that matches the pattern in the 2nd argument.  If the 6th argument is 1, however, REGEXP_SUBSTR returns only the part of the pattern between the 1st on the left '(' et sa correspondance)."

  • How to check the decimal value in the number field

    Is it possible to find the number of decimal digit is used.

    999.444
    444.45
    344.23
    33.666666666666

    Query provide rusult after the decimal value.

    Thank you.

    user-Keen wrote:
    Query provide rusult after the decimal value.

    Thank you.

    your_col - trunc(your_col)
    

    You have negative numbers?

    For negative values that you want to display?

    If only the decimal part, you can use ABS (col) - trunc (ABS (col))

    Published by: JAC on 4 April 2013 15:29

  • How to check the size of the actual data to TS?

    Hi all

    11.2.0.1

    My 'USERS' table space is now 32 GB in size. I want to reorg this tablespace fragmentation to release.
    What is the command to check what is the actual data are occupied?

    I just take the primitive path. I expdp data base and the size of the discharge will be the actual size of the data used.
    Is this correct?

    Thank you very much
    Kinz

    KinsaKaUy? wrote:
    Hey Sb,

    There is in fact no problem. My boss want to just an excel report for all our fifty 50 development databases regarding the TS_SIZE TOTAL and ACTUAL SPACE USED.
    So I just wondering what script should I run, because there are many of them.

    Then select a few, run them, check if their results are similar or not and if yes, choose one that runs more quickly :). on another thought, why you don't use EM to declare the same thing for you?

    Aman...

  • How to get the empty values for common data for a column?

    Hello
    I have a table whose data is like this:
    DEPT_ID     STATUS     USER_ID     ART_ID
    
    7     R     1234     0000001
    7     P     2411     0000002
    7     Q     1231     0000003
    7     S     7676     0000004
    3     R     6776     0000005
    3     S     7869     0000006
    6     Q     787     0000007
    6     W     5656     0000008
    .......more data like this
    How can we get this are data in this format:
    7     R     1234     0000001
         P     2411     0000002
         Q     1231     0000003
         S     7676     0000004
    3     R     6776     0000005
         S     7869     0000006
    6     Q     787     0000007
         W     5656     0000008

    In SQL * Plus, you can use the PAUSE command

    SQL> break on deptno;
    SQL> ed
    Wrote file afiedt.buf
    
      1  select deptno, ename
      2    from emp
      3*  order by deptno
    SQL> /
    
        DEPTNO ENAME
    ---------- ----------
            10 CLARK
               MILLER
               KING
            20 FORD
               smith
               ADAMS
               SCOTT
               JONES
            30 SM0
               TURNER
               BLAKE
               MARTIN
               ALLEN
               WARD
               PAV
               BAR
    
    16 rows selected.
    

    In SQL, you must use an analytic function

    SQL> ed
    Wrote file afiedt.buf
    
      1  select (case when deptno = prior_deptno
      2               then null
      3               else deptno
      4            end) deptno,
      5         ename
      6    from (select deptno,
      7                 lag(deptno) over (order by deptno, ename) prior_deptno,
      8                 ename
      9            from emp
     10*          order by deptno, ename)
    SQL> /
    
        DEPTNO ENAME
    ---------- ----------
            10 CLARK
               KING
               MILLER
            20 ADAMS
               FORD
               JONES
               SCOTT
               smith
            30 ALLEN
               BLAKE
               MARTIN
               SM0
               TURNER
               WARD
               BAR
               PAV
    
    16 rows selected.
    

    Justin

  • How to assign the text value when the data in the column is null or empty

    Hello guys

    I have a small question

    I have a column A that half of its value is empty, now the condition is that whenever the column is empty, assign "N/a" in the column... So I wrote a code which is:

    <? If: not (column A)? > column a = 'n/a' <? end if? >

    However, when I preview the RTF model, the data in the column still has not changed at all, many lines are still empty and did not show 'n/a '... The column is of type text

    Please advice

    Thank you
    N/A
    
  • How can I change the value of the data provided by the user in ADF form before performing operation CreateInsert in adf 11 g

    Basically, I created an EO, then original Version of it. Then I posted ADF:form of her and the operation of CreateInsert attributed to it. Now, I want to encrypt a user provided data and then store.

    If you want to encrypt the data before saving it in the database, you can:

    Exposes the implementation of EO (EOImpl.java) class, override the method doDML() like this:

    ' Public Sub doDML (operation int, TransactionEvent e) {}

    If (operation is DML_INSERT)

    {

    setPassword (YourEncryptUtility.encrypt (getPassword ()));

    super.doDML (operation, e);

    }

    }

Maybe you are looking for