Explanation of the instr function

Hello

I have been helped with a query and received the following code. The code does what I wanted to do, but I don't really understand how it works. I tried Googling, but examples are different in this one and do not contain the value > 0 or | (Which I guess makes reference to a column. Could someone please explain it to me.
 SET Financial_Review = ( case when instr(Debt_Review||Judgement||Liquidation||under_admin,'Y') > 0 then  'Y' else 'N' end) 
Banner:
Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production."
AMT for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

Debt_Review||Judgement||Liquidation||under_admin 

You concatenate 4 columns. then


instr(Debt_Review||Judgement||Liquidation||under_admin,'Y') 

You check if the letter there exist in the concatenated string. INSTR returns the position of the character of research. So if the position is greater than 0 that means that the search string exists.

So eventually, if it exists, you define Y n else.

Tags: Database

Similar Questions

  • I need a little help with the INSTR function

    Hello everyone,

    im still new to pl sql and experienced an issue with the INSTR function. I need to analyze some values of a CLOB containing the xml code and use INSTR to determine the beginning and end of the value, I would like to analyze.

    the data I need is in a <!-[CDATA [[Some Text]]]-> block. up to this point, I managed to take the start of the word, but I can't seem to capture the end of the CDATA block. I use this statement:

    POS: = INSTR (TO_CHAR (input_clob) [,'] ', pos2 + 6, 1);

    but it doesn't have the desired effect. [It seems to sort of go back to the length of the string, while the]-sign is actually in the xml file. my result would look to "Some Text]]--> < xmlxml >... < / xmlxml >...» ». [I tried to escape by writing ' \] "but if I do, the function returns zero and my parsed string is left blank.

    Unfortunately I can't use regular expressions, because I work with oracle 9.2i. Anyone know what I'm doing wrong?

    Thank you

    Edited by: user8719779 the 25.08.2009 02:23
    with my_tab as (select ''||chr(10)||
                           '  '||chr(10)||
                           '   '||chr(10)||
                           '  '||chr(10)||
                           '' col1 from dual)
    -- end of mimicking your data; USE SQL below:
    select substr(col1, instr(col1, '', 1, 1) - instr(col1, 'Hi all


    I have a querry as
        Select * from Tab1 Where Instr(Tab1.Col1,'XX') >0 ;
    Is simple index on column Col1. If we use the index will be used or full table scan will happen in this scenario?

    Please give me explanatory answer because I have doubts


    Dhabas

    Hello

    You must use the index function if you want to avoid the full table scan. Check this box

    SQL> create table tab1(col1 varchar(20))
      2  /
    
    Table created.
    
    SQL> insert into tab1 values ('XXAB')
      2  /
    
    1 row created.
    
    SQL> create index col1_idx on tab1(col1);
    
    Index created.
    
    SQL> explain plan for Select * from Tab1 Where Instr(Tab1.Col1,'XX') >0;
    
    Explained.
    
    SQL> set autotrace on
    SQL> Select * from Tab1 Where Instr(Tab1.Col1,'XX') >0;
    XXAB
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=5 Card=1 Bytes=12)
       1    0   TABLE ACCESS (FULL) OF 'TAB1' (TABLE) (Cost=5 Card=1 Bytes
              =12)
    
    Statistics
    ----------------------------------------------------------
              4  recursive calls
              0  db block gets
             32  consistent gets
              0  physical reads
              0  redo size
            234  bytes sent via SQL*Net to client
            280  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    
    SQL>  create index col1_idx2 on tab1(Instr(Col1,'XX'));
    
    Index created.
    
    SQL> Select * from Tab1 Where Instr(Tab1.Col1,'XX') >0;
    XXAB
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=1 Bytes=12)
       1    0   TABLE ACCESS (BY INDEX ROWID) OF 'TAB1' (TABLE) (Cost=2 Ca
              rd=1 Bytes=12)
    
       2    1     INDEX (RANGE SCAN) OF 'COL1_IDX2' (INDEX) (Cost=1 Card=1
              )
    
    Statistics
    ----------------------------------------------------------
             28  recursive calls
              0  db block gets
             22  consistent gets
              0  physical reads
              0  redo size
            234  bytes sent via SQL*Net to client
            280  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    
    SQL> 
    

    Thank you
    AJ

  • Need help with the INSTR function

    I try to use SUBSTR and INSTR function to parse a variable without breaking to the top of the variable. As you can see that the problem is space, negotiating
     
    DECLARE
         blank_space NUMBER(2);
         full_name VARCHAR2(30) := 'Robert P. Simmons');
         first_name VARCHAR2(30);
         last_name VARCHAR2(30);
         
    BEGIN 
         blank_space := INSTR(full_name, ' ');
         first_name := SUBSTR(full_name, 1, (blank_space -1));
         DBMS_OUTPUT.PUT_LINE( 'Your first name is ' || first_name);
         last_name := SUBSTR(full_name, (blank_space + 1),
         (LENGTH(full_name) - blank_space));                
         DBMS_OUTPUT.PUT_LINE( 'You have ' || 
         LENGTH(last_name) || ' characters in your last name!');
         
    END;     
    How can I enter the number of characters in name only? It lists just to the right of the 1st blank_space.

    Thank you
    SQL> declare
       blank_space   number (2);
       full_name     varchar2 (30) := 'Robert P. Simmons';
       first_name    varchar2 (30);
       last_name     varchar2 (30);
    begin
       blank_space := instr (full_name, ' ');
       first_name := substr (full_name, 1, (blank_space - 1));
       dbms_output.put_line ('Your first name is ' || first_name);
    
       dbms_output.put_line ('You have ' || length (substr (full_name, instr (full_name, ' ', -1) + 1)) || ' characters in your last name!');
    end;
    /
    Your first name is Robert
    You have 7 characters in your last name!
    PL/SQL procedure successfully completed.
    
  • Problem with Textfield autocomplete--&gt; only use the INSTR function

    Hello team dev,

    I use the new "textfield autocomplete" item type APEX and you have a crazy problem with it.

    I have a table with an index on the same column I want to search with AutoComplete field.

    Index:
    CREATE BITMAP INDEX TEST.GEO_DATA_IDX1 ON TEST.GEO_DATA (postcode)
    NOLOGGING TABLESPACE TS_INDEX;
    Select which is automatically generated by APEX 4:
    SELECT   a.*
      FROM   (  SELECT   DISTINCT postcode AS RV
                  FROM   TEST.GEO_DATA
                 WHERE   country_id = :P1_COUNTRY
              ORDER BY   1) a
     WHERE   INSTR ("RV", :p$_search_string) > 0 AND ROWNUM <= :p$_max_rows;
    
    -- plan
    Plan
    SELECT STATEMENT  ALL_ROWSCost: 4,308  Bytes: 45,31  Cardinality: 1,97            
         2 SORT UNIQUE  Cost: 4,307  Bytes: 45,31  Cardinality: 1,97       
              1 TABLE ACCESS FULL TABLE #TABLE# Cost: 4,306  Bytes: 47,311  Cardinality: 2,057  
    The APEX 3, I used the addon of Tyler Muth with my own Select:
    SELECT   DISTINCT
                postcode AS DV,
                postcode AS RV
         FROM   TEST.GEO_DATA
         WHERE   country_id = L_COUNTRY
         AND    postcode like l_search||'%'
         ORDER BY 1
    
    -- Plan
    SELECT STATEMENT  ALL_ROWSCost: 840  Bytes: 152,867  Cardinality: 13,897                                
         8 SORT ORDER BY  Cost: 840  Bytes: 152,867  Cardinality: 13,897                           
              7 HASH UNIQUE  Cost: 838  Bytes: 152,867  Cardinality: 13,897                      
                   6 VIEW VIEW index$_join$_001 Cost: 836  Bytes: 232,111  Cardinality: 21,101                 
                        5 HASH JOIN            
                             2 BITMAP CONVERSION TO ROWIDS  Cost: 31  Bytes: 232,111  Cardinality: 21,101       
                                  1 BITMAP INDEX RANGE SCAN INDEX (BITMAP) #INDEX#
                             4 BITMAP CONVERSION TO ROWIDS  Cost: 45  Bytes: 232,111  Cardinality: 21,101       
                                  3 BITMAP INDEX SINGLE VALUE INDEX (BITMAP) #INDEX#
    Is there a chance to get my INDEX used by the new element of the APEX? I do not. But I still want to ask before I just rebuild. :)

    Best regards

    Tobias

    Hi Tobias,.

    I guess that you are currently using "contains and case sensitivity ' to the attribute of"search ". Have you ever tried out "Exact and case sensitivity? Because that internally uses the LIKE operator as does your original query and the % is at the end, she must allow the use of an index. But it might still work, because ORDER BY can be run at a different time in your original example, but it's worth a try.

    Concerning
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • The INSTR function in where clause

    Hello

    I need to check if part of the separate past comma is there in one of the values of table column, if its present, then I need to go looking for this file in the same table.

    Example of
    --------
    Table1:

    col1 col2
    -----------
    01 john
    Raj 02

    and I'm passing '02,04,06' as the value of parameter input and according to this value, I need to check in a table and get a record.

    procedure p1 (v_string varchar2)
    is
    Select col1, col2
    in a, b
    FROM table1
    where instr (v_string, - here I need to apply the logic

    end;

    output
    ------
    Raj 02

    Please help me with this logic

    RDS,
    Naga
    instr(','||v_string||',',','||col1||',') > 0
    

    Nicolas.

  • Discoverer INSTR function does not have a hyphen in the ID Oppty

    I need to identify the IDS that have a number that produces a hyphen. INSTR (opportunity ID,'-', 1, 1) calculation identifies the location of the hyphen for most of ID. However, it does not recognize the hyphen in some. Identifiers that have hyphens that are not recognized, I know that the hyphen is counted as a character because Discover include the hyphen when I use a calculation of LENGTH on the field service ID.

    Example:
    INSTR (field ID,'-', 1, 1) calculation for ID 3 - XXXXX1 = 2; but for ID 3 - XXXXX2 = 0.
    Calculations of LENGTH (ID field) for the two ID = 8.

    Anyone who has ever encountered this problem and found a resolution?

    Any help would be greatly appreciated... Thank you!

    Published by: user740605 on Sep 8, 2010 13:43

    Published by: user740605 on Sep 8, 2010 13:45

    Published by: user740605 on Sep 8, 2010 13:47

    Published by: user740605 on Sep 8, 2010 13:47

    Hello

    I suspect that the character is not hyphenated, but hyphenated "windows". If the text was cut and paste from a windows like word or excel application, then it will probably contain the hyphen of windows which is a different character.

    You can use the lengthB function to check if there are 2-byte characters or use the dump function to watch the ascii characters in the field.

    Rod West

  • allocation of an array of 2d in labVIEW and move to the DLL function to obtain data

    Hi all!

    I searched a lot about this, but one cannot find any solution. Please find attached the vi that I try to get a unit of 32 channels data,

    100000 samples per channel with 14-bit resolution. And please also find enclosed the header for my dll file. (in the header, it is the GetBuffers function).

    There is not a lot of data, it is a little more then 6 MB in the task of LAbVIEW Manager eats about 30 MB more memory, then it should. Are there explanations why?

    Because there is much more data in a single channel (million samples or more)

    Then I will try to allocate a 2D to data array, but when I try to run my LabVIEW vi crashes.

    Could you please help?

    Best regards

    Tomzi

    Dear Tomzi!

    To allocate the data in a table in LabVIEW, you must always initialize, as in a you must have a valid entry on cell (x-, y - 1) have a size of table of (x, y). It is usually best to use the function Array initialized for this purpose.

    There are ways to pass arrays 2D to DLLs, cand find you examples of both in examples > communicate with external Applications > external Code using the > integrating DLLs > DLL.vi call. Basically, LabVIEW can pass in the form of a big table 1 d 2D tables, so you'll need to spend too much table size index it. If you pass the array 2D handles it is preferable to use the typedef that LabVIEW generates for you, something along the lines of

    / * LabVIEW created typedef * /.
    typedef struct {}
    Int32 dimSizes [2];
    Double elt [1];
    } TD1;
    typedef TD1 * TD1Hdl;

    I hope this helps.

    Best regards:

    Andrew Valko

    NOR Hungary

  • alternatives without using the regexp_replace function

    SELECT

    REGEXP_REPLACE (phone_number,

    "([[: digit:]] {3})------." ([[: digit:]] {3}). ([[: digit:]] {4})',

    "\2-\3 (\1)") "REGEXP_REPLACE.

    Employees;

    is there another without using the regexp_replace function...

    Another way

    (eliminating instr... function as your problem focuses on one length fixed)

    WITH t AS (SELECT '112.345.6789' FROM DUAL str).

    TT AS (SELECT REPLACE (str, '.') t str)

    SELECT ' (')

    || SUBSTR (str, 1, 3)

    || ') '

    || SUBSTR (str, 4, 3)

    || '-'

    || SUBSTR (str, 7)

    TT;

    See you soon,.

    Manik.

  • How to use the NVL function to a parameter with comma delimited values

    Gurus,

    It is confusing to me.  I am trying to use the NVL function, but the setting that I'm passing in my cursor contains multiple values with commas.  The NVL function is confused when analyzing the values.

    'Where' cursor clause...

    and nvl (sn.c_attribute1,'x@#$%') in nvl (p_desig,'x@#$%'( )

    translated parameter values...

    and nvl (sn.c_attribute1,'x@#$%') in nvl ('SPRT''GOOD' 'BAD' 'x@#$%') -NVL does not parse the value correctly

    Any idea on how to get NVL recognize 'x@#$%' , if p_desig is null?

    Thank you

    Scott

    HI, Scott.

    Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.

    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

    My best guess, based on what you posted bone is present, that your problem is discussed in the following:

    http://tkyte.blogspot.com/2006/06/varying-in-lists.html

    http://www.Oracle-base.com/articles/Misc/DynamicInLists.php

  • County, based on the soundex function

    Hi all

    I a bit confused with request asked of me.
    the query is
    indicate the account number of the last part of each word in the same row according to the soundex function
    for example
    the first line has set out four in the same line
    ACD BCD AAA
    AFD BCF
    BDE AAC AFC
    BCF AAE
    Does it say I have divided the each statement and get soundex for the last part which is located in this example is------.
    AAA
    BCF
    AFC
    AAE 
    So the soundex only for AAA and AAE is same average I've update table b in the column of Gen by two and son on for others.
    create table  a(id number(9), Gen_Value varchar2(200));
    
    insert into a vlaues(1, 'ACD BCD AAA, AFD BCF , BDE AAC AFC,BCF AAE');
    insert into a vlaues(2, 'AVF BCD, BBA BBG BCEV, GACD MNF BCV');
    insert into a vlaues(3, 'AFC ABC, BBG HUH ABCE, JHU KK MNK');
    
    
    create table  b(id number(9), Gen_Value varchar2(200), id number(9));
    insert into b values( 'AAA', '0',1);
    insert into b values ('BCEV  ','0',2);
    insert into b values ('AFC','0',1);
    insert into b values ('BCD','0',2);
    insert into b values ('MNK','0',3);
    insert into b values ('ABCE','0',3);
    The result is
    Gen   count  id 
    AAA    2     1
    BCEV   2     2
    AFC     1     1
    BCD     1     2
    MNK    1     3   
    ABCE  2     3
    see you soon
    Benjamin

    Published by: 973907 on November 29, 2012 12:54 AM

    Published by: 973907 on November 29, 2012 12:55

    973907 wrote:
    We choose one of them. 'AAA' or AAE. or the word that has long term.

    No prob

    with data as (
     select
      id
     ,gen_value||',' gen_value
     from a
    )
    ,r  (id, gen_value, l) as (
     select
      id
     ,substr(gen_value, instr(gen_value, ',') + 1)
     ,substr(
       trim(substr(gen_value,1, instr(gen_value, ',') - 1))
      ,instr(trim(substr(gen_value,1, instr(gen_value, ',') - 1)),' ',-1)
     )
    from data
    union all
     select
      id
     ,substr(gen_value, instr(gen_value, ',') + 1)
     ,substr(
       trim(substr(gen_value,1, instr(gen_value, ',') - 1))
      ,instr(trim(substr(gen_value,1, instr(gen_value, ',') - 1)),' ',-1)
     )
    from r
    where
    length(gen_value) > 0
    )
    
    select
     soundex(l)
    ,count(*) cnt
    ,max(l) keep ( dense_rank last order by length(l), l desc nulls first) v
    from r
    group by
     soundex(l)
    order by
     1
    
    SOUNDEX(L) CNT V
    A000 2 AAA
    A120 3 ABCE
    B210 3 BCEV
    B230 1 BCD
    M200 1 MNK 
    
  • help in the application without using the pivot function

    Hi gurus,

    Can you please help write the query without using the PIVOT function.
     WITH indata AS
             (SELECT 1 sn, '123:456,789,323:456,213,344,345:5454' x
                from dual
              UNION ALL
              SELECT 2, 'abcd:fgrfr,rfrf,rfred,tg:tg,tg:ophhh,op,vdfgbh:poijn' x from dual),
            instr AS
             (SELECT a.SN,
                     rownum RN,
                     B.column_value || CASE
                       WHEN B.column_value NOT LIKE '%:%' THEN
                        ':'
                     END column_value 
                FROM indata a,
                     TABLE(CAST(multiset
                                (SELECT trim(SUBSTR(x,
                                                    (CASE LEVEL
                                                      WHEN 1 THEN
                                                       1
                                                      ELSE
                                                       instr(x, ',', 1, LEVEL - 1) + 1
                                                    END),
                                                    (CASE instr(x, ',', 1, LEVEL)
                                                      WHEN 0 then
                                                       4000
                                                      ELSE
                                                       instr(x, ',', 1, LEVEL) - 1 -
                                                       (CASE LEVEL
                                                          WHEN 1 THEN
                                                           0
                                                          ELSE
                                                           instr(x,
                                                                 ',',
                                                                 1,
                                                                 level - 1)
                                                        END)
                                                    END)))
                                   FROM dual
                                 CONNECT BY level <=
                                            LENGTH(x) -
                                            LENGTH(REPLACE(x, ',', '')) + 1) AS
                                sys.odcivarchar2list)) b)
            SELECT  col1_val2,
                    col1_val1,
                    col2_val2,
                    col2_val1,              
                   systimestamp
              FROM (select SN,
                          ROW_NUMBER() over(partition by SN order by RN) RN,
                           SUBSTR(column_value, INSTR(column_value, ':') + 1) VAL1,
                           substr(column_value, 1, instr(column_value, ':') - 1) val2
                      FROM instr ) PIVOT(MAX(VAL1) VAL1, MAX(VAL2) VAL2 FOR SN IN(1 as col1,2 as col2));
    Thanks in advance!...

    Any help would be appreciated.

    user590978 wrote:

    Can you please help write the query without using the PIVOT function.

    with indata as (
                    select 1 sn,'123:456,789,323:456,213,344,345:5454' x from dual union all
                    select 2, 'abcd:fgrfr,rfrf,rfred,tg:tg,tg:ophhh,op,vdfgbh:poijn' x from dual
                   ),
             t1 as (
                    select  x
                      from  indata
                      where sn = 1
                   ),
             t2 as (
                    select  x
                      from  indata
                      where sn = 2
                   ),
             t3 as (
                    select  level lvl,
                            substr(
                                   x,
                                   instr(',' || x,',',1,level),
                                   instr(x || ',',',',1,level) - instr(',' || x,',',1,level)
                                  ) col1
                      from  t1
                      connect by level <= length(x) - length(translate(x,'A,','A')) + 1
                   ),
             t4 as (
                    select  level lvl,
                            substr(
                                   x,
                                   instr(',' || x,',',1,level),
                                   instr(x || ',',',',1,level) - instr(',' || x,',',1,level)
                                  ) col2
                      from  t2
                      connect by level <= length(x) - length(translate(x,'A,','A')) + 1
                   ),
             t5 as (
                    select  lvl,
                            substr(col1,1,instr(col1 || ':',':') - 1) col1_val1,
                            substr(col1,instr(col1 || ':',':') + 1) col1_val2
                      from  t3
                   ),
             t6 as (
                    select  lvl,
                            substr(col2,1,instr(col2 || ':',':') - 1) col2_val1,
                            substr(col2,instr(col2 || ':',':') + 1) col2_val2
                      from  t4
                   )
    select  col1_val1,
            col1_val2,
            col2_val1,
            col2_val2,
            systimestamp
      from      t5
            full join
                t6
            on (
                t6.lvl = t5.lvl
               )
      order by coalesce(t5.lvl,t6.lvl)
    /
    
    COL1_VAL1  COL1_VAL2  COL2_VAL1  COL2_VAL2  SYSTIMESTAMP
    ---------- ---------- ---------- ---------- -------------------------------------
    123        456        abcd       fgrfr      23-OCT-12 11.50.12.015000 AM -04:00
    789                   rfrf                  23-OCT-12 11.50.12.015000 AM -04:00
    323        456        rfred                 23-OCT-12 11.50.12.015000 AM -04:00
    213                   tg         tg         23-OCT-12 11.50.12.015000 AM -04:00
    344                   tg         ophhh      23-OCT-12 11.50.12.015000 AM -04:00
    345        5454       op                    23-OCT-12 11.50.12.015000 AM -04:00
                          vdfgbh     poijn      23-OCT-12 11.50.12.015000 AM -04:00
    
    7 rows selected.
    
    SQL> 
    

    SY.

  • 101: explanation of the tools in the Panel?

    I'm going through the tutorials but seem to Miss where I can find an explanation of the tool panels and their functions. The tutorials do not necessarily explain it (sometimes they do).

    Hello

    Very well! So let's start with gold playhead in the timeline panel. This is different from the PIN tool, because that's literally what you can use to define where you want keyframes to be manually in your timeline. You can also use this to navigate backwards in the timeline by clicking on the read head gold and drag through the timeline. This is also known as rub. The best way to think of the read head is to be considered as a "bookmark" in your timeline.

    The Pin tool is a great little tool that is unique on board animate. Significantly, it improves your productivity while animating and eliminates the need from keyframe to the hand.

    With the selected PIN tool, you will notice a blue pin in your timeline. You can click and drag this PIN back and forth to set a literal "PIN" in your timeline. When you do so, you will notice that your head stays in place. It is because what makes the tool of corner is literally "remembers" where your head is and then act as a second head for you so that you can keyframe with ease.

    Thus, for example, if you have a rectangle with an opacity of 100% at 0 seconds. If you click on the tool spindle and slide forward in the timeline to 1 second and then change the opacity to 0%, the Pin will be keyframe for you opacity to 0 seconds and 1 second, which makes the task of animating this transition easier. The rectangle fade from 0% to 100% opacity over a second.

    Another point to remember about the PIN tool, it's you will notice little rafters in the blue bar that extends from the time you dragged your corner tool. The rafters help explain where your animation is transient. They stress also everywhere where is your head. You can move the playback cursor in front of the PIN tool to have your key frame be the change of departure.

    As with our example before, if you have your rectangle to 100% opacity and you have selected the tool pin so you move the playback cursor forward. You can change the opacity to 0% and the rectangle now fade from 100% to 0% more than one second.

    I'll explain the image auto key and automatic transition in a second post tools. I hope this helps explain the tool spindle and the read head better!

  • SUBSTR and INSTR function

    Hi gurus,

    I have the data as follows:

    data
    -----------------------------------------------------------------------------------------------------------------------
    ' BIDIE01H / TXT:ZUNE = HA011, CellIndex = 144 /CAI:452 - 01-32201-47001 / CAI:45201F7dc9b79a'
    ' BIDIE01H / TXT:ZUNE = HA111, CellIndex = 124 /CAI:452 - 01-32201-471 / CAI:45201F7dc9b79b'


    and I'm writing a SQL results:

    CAI
    ---------
    452 01-32201-47001
    452 01-32201-471

    Any idea to do? I tried around with SUBSTR and INSTR functions but not yet sucessed.

    Thank you
    Alex

    something like:

    with my_tab as (select 'BIDIE01H/TXT:ZUNE=HA011, CellIndex=144 /CAI:452-01-32201-47001/CAI:45201F7dc9b79a' col1 from dual union all
                    select 'BIDIE01H/TXT:ZUNE=HA111, CellIndex=124 /CAI:452-01-32201-471/CAI:45201F7dc9b79b' col1 from dual)
    -- end of mimicking your data: USE SQL below:
    select substr(col1, instr(col1, '/CAI:', 1) + 5, instr(col1, '/CAI:', 1, 2) - instr(col1, '/CAI:', 1) - 5 ) CAI
    from my_tab
    
    CAI
    --------------------------------------------------------------------------------
    452-01-32201-47001
    452-01-32201-471     
    
  • Use the Trim function in this case?

    Oracle 10.2 g

    I have the following code (thanks to michaels 2):
    SQL> with t as (
     select to_date('11/14/2003 7:39:00 PM','MM/DD/RRRR hh:mi:ss pm') time, 11122 home_team_id,null away_team_id,null home_team_name, 'parks' away_team_name,'Steve' offensive_player_moniker, 'Smith' offensive_player_last_name from dual union all                    
     select to_date('11/14/2003 7:32:00 PM','MM/DD/RRRR hh:mi:ss pm'), null, 24555, null, 'bombers', 'Chris', 'Carter' from dual union all                 
     select to_date('12/14/2008 1:35:00 PM','MM/DD/RRRR hh:mi:ss pm'), null, 33211, null, 'carts', 'Marty', 'Booker' from dual union all   
     select to_date('12/14/2008 1:30:00 PM','MM/DD/RRRR hh:mi:ss pm'), 15555, null, null, 'sharks', 'Bob', 'Sanders' from dual union all
     select to_date('12/14/2008 1:38:00 PM','MM/DD/RRRR hh:mi:ss pm'), 15555, null, null, 'sharks', 'Marvin','Harrison' from dual
    )
    select away_team_name || ': ' || xmlagg(xmlelement(e, offensive_player_moniker || ' ' || offensive_player_last_name || ' (' || to_char(time,'hh:mi') || '), ')).extract('//text()') x from t
    group by  away_team_name
    / 
    X                                                                               
    --------------------------------------------------------------------------------
    bombers: Chris Carter (07:32),                                                  
    carts: Marty Booker (01:35),                                                    
    parks: Steve Smith (07:39),                                                     
    sharks: Bob Sanders (01:30), Marvin Harrison (01:38),
    Desired output:
    bombers: Chris Carter (07:32)                                                 
    carts: Marty Booker (01:35)                                                 
    parks: Steve Smith (07:39)                                                   
    sharks: Bob Sanders (01:30), Marvin Harrison (01:38)
    How can I go about removing the unnecessary extra at the end when coma. I have "guess the TRIM function could do with an if-else clause, well I don't know what would go in the if-else clause

    Hello

    Select substr(x, 1, instr(x, ',', -1) - 1)
      from (select away_team_name || ': ' ||
                   xmlagg(xmlelement(e,
                                     offensive_player_moniker || ' ' ||
                                     offensive_player_last_name || ' (' ||
                                     to_char(time, 'hh:mi') || '), ')) .extract('//text()') x
              from t
             group by away_team_name)
    

    Kind regards

    Christian Balz

Maybe you are looking for