Substr / Instr or Subquery

Hi All,
I have a requirement for which I am looking for solution, kindly do the needful.
CREATE TABLE CO_VENDOR_COMMODITY
(VENDOR_CODE VARCHAR2(240),
COMMODITY_CODE NUMBER);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('25',1);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('25',2);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('25',3);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('25',4);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('20',1);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('20',2);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('20',3);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('20',4);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('20',5);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('30',21);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('30',22);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('30',23);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('30',24);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('30',25);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('40',15);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('40',16);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('40',17);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('40',18);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('35',15);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('35',16);
INSERT INTO CO_VENDOR_COMMODITY VALUES ('35',17);
CREATE OR REPLACE VIEW OV_VENDOR AS
select
VENDOR_CODE,
rtrim (xmlagg (xmlelement (e,COMMODITY_CODE || ',')).extract ('//text()'), ',') commcode
from
CO_VENDOR_COMMODITY
group by
VENDOR_CODE;     
Output should display as below
VENDOR_CODE     COL1 COL2 COL3 COL4 COL5
20 1 2 3 4 5
25 1 2 3 4
30 21 22 23 24 25
35 15 16 17
40 15 16 17 18
as of now I have built the below query further I am not able to proceed.
SELECT VENDOR_CODE,
COMMCODE,
SUBSTR(COMMCODE,1,(INSTR(COMMCODE,',',1,1) -1)) COL1,
SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,1)+1),(LENGTH(SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,1)+1)))-LENGTH(SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,2)))))) COL2,
SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,2)+1),(LENGTH(SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,2)+1)))-LENGTH(SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,3)))))) COL3,
SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,3)+1),(LENGTH(SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,3)+1)))-LENGTH(SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,4)))))) COL4_1,
SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,4)+1)) COL5,
'SUBSTR(COMMCODE,('||INSTR(COMMCODE,',',1,3)||'+1),('||LENGTH(SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,3)+1)))||' - '||LENGTH(SUBSTR(COMMCODE,(INSTR(COMMCODE,',',1,4))))||'))' COL4
FROM OV_VENDOR
To acheive the above output whether I need use substr/instr or should I go for subquery? which one is best? It is possible to acheive the above output by using subquery?
Thanks in advance.
-Satyam

Oh wait, I now see you want the commodity codes in separate columns.
If you have a fixed maximum of possible commodity codes, you can use a subquery:
SQL> select vendor_code
  2  ,      max(case when rn=1 then commodity_code else null end ) col1
  3  ,      max(case when rn=2 then commodity_code else null end ) col2
  4  ,      max(case when rn=3 then commodity_code else null end ) col3
  5  ,      max(case when rn=4 then commodity_code else null end ) col4
  6  ,      max(case when rn=5 then commodity_code else null end ) col5
  7  from ( select vendor_code
  8         ,      commodity_code
  9         ,      row_number() over (partition by vendor_code order by commodity_code) rn
10         from   co_vendor_commodity
11       )
12  group by vendor_code;
VENDO       COL1       COL2       COL3       COL4       COL5
20             1          2          3          4          5
25             1          2          3          4
30            21         22         23         24         25
35            15         16         17
40            15         16         17         18

Similar Messages

  • Dynamic PL/SQL & substr, instr function

    I am having trouble with incorporating the SUBSTR and INSTR functions into my dynamic PL/SQL procedure using Oracle 8i.
    I have data that is packed into one column seperated by a delimiter (':')
    I need to seperate the data to use indicidual pieces.
    If I run my query in general -
    select substr(secondcol, 1, instr(secondcol, ':',1,1)-1) ONE,
    substr(secondcol,instr(secondcol, ':',1,1)+1,instr(secondcol, ':',1,1)-1) TWO,
    substr(secondcol,instr(secondcol, ':',1,2)+1,instr(secondcol, ':',1,1)-1) THREE,
    substr(secondcol,instr(secondcol, ':',1,3)+1,instr(secondcol, ':',1,1)-1) FOUR
    from temp_table where firstcol=100
    This works and gives me the right result.
    e.g
    DATA :
    Firstcol SECONDCOL
    100 1:2:3:4
    Result:
    ONE TWO THREE FOUR
    1 2 3 4
    However to make this generic if I use it in a function passing it a parameter which has ':' delimited data it does not work and gives me errors. All I want is to get the output as a string that looks like my query above so I can use it in my proc.
    create or replace function MYJUNK(TFieldNew IN CHAR)
    RETURN CHAR IS
    UpdateString Varchar2(100);
    BEGIN
    UpdateString := 'First=substr('||TFieldNew||', 1, instr('||TFieldNew||', '':'',1,1)-1) ONE, ';
    UpdateString := UpdateString || ' Second=substr('||TFieldNew||', instr('||TFieldNew||', '':'',1,2)+1, instr('||TFieldNew||', '':'',1,1)-1) TWO, ';
    UpdateString := UpdateString || ' third=substr('||TFieldNew||', instr('||TFieldNew||', '':'',1,3)+1, instr('||TFieldNew||', '':'',1,1)-1) THREE from temp_table';
    return UpdateString;
    END;
    The function compiles but gives me run time errors
    This is what I get -
    SQL> select myjunk('''1:2:3:4''') from dual;
    select myjunk('''1:2:3:4''') from dual
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "SGHDTA.MYJUNK", line 8
    ORA-06512: at line 1

    You are getting an error because updatestring is longer than the 100 characters you defined it as. Try using VARCHAR2(4000). Also, if you are trying to generate the sql statement, you need to get rid of first=, second= and third= when you build the string.
    This is what your function returns. I put in line breaks for clarity:
    First=substr('1:2:3:4', 1, instr('1:2:3:4', ':',1,1)-1) ONE,
    Second=substr('1:2:3:4', instr('1:2:3:4', ':',1,2)+1, instr('1:2:3:4',':',1,1)-1) TWO, 
    third=substr('1:2:3:4', instr('1:2:3:4', ':',1,3)+1,instr('1:2:3:4', ':',1,1)-1) THREE
    from temp_tableIf you are trying to actually parse the column, then you need something more like:
    create or replace procedure MYJUNK(TFieldNew IN VARCHAR2,out1 OUT VARCHAR2,
                                       out2 OUT VARCHAR2, out3 OUT VARCHAR2) is
    BEGIN
       out1 := SUBSTR(TFieldNew,1, INSTR(TFieldNew,':',1,1)-1);
       out2 := SUBSTR(TFieldNew, INSTR(TFieldNew,':',1,2)+1, INSTR(TFieldNew,':',1,1)-1);
       out3 := SUBSTR(, INSTR(TFieldNew,':',1,3)+1, INSTR(TFieldNew,':',1,1)-1);
    END;

  • Substring instr issue in obiee

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

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

  • How to fetch data using Substring & Instring

    Hi ,
    I have data like
    a_76488b_2780c
    a_76488b_2780c_
    a_76488b_c2780
    a_76488b_c2780
    a_31487b_5542
    a_76488b_2780
    i want to fetch data like last 4 numeric digit only
    2780
    2780
    2780
    2780
    5542
    2780

    I don't know what you have against rexexp_replace, but this works if you want all the digits after the second underscore:
    WITH t AS
            (SELECT 'a_76488b_2780c' str FROM DUAL
             UNION ALL
             SELECT 'a_76488b_2780c_' FROM DUAL
             UNION ALL
             SELECT 'a_76488b_c2780' FROM DUAL
             UNION ALL
             SELECT 'a_76488b_c2780' FROM DUAL
             UNION ALL
             SELECT 'a_31487b_5542' FROM DUAL
             UNION ALL
             SELECT 'a_76488b_2780' FROM DUAL
    SELECT replace(after_second_und
                  ,replace(translate(after_second_und
                                    ,'0123456789'
                          ,NULL
                  ,NULL
                  ) your_number
    FROM   (SELECT   SUBSTR(str,instr(str,'_',1,2)+1) after_second_und
            FROM t
    YOUR_NUMBER
    2780
    2780
    2780
    2780
    5542
    2780

  • Substr -instr

    What's the best way to remove a word from a string?
    If I have:
    select 'xyz Dell product' product from dual
    union all
    select 'Intell product' product from dual
    and I want to remove the beginning xyz word from the string so that I get:
    select 'Dell product' product from dual
    union all
    select 'Intell product' product from dual

    Hi,
    Is this what you're looking for?
    CREATE TABLE     table_x
    AS
    select 'xyz Dell product' product from dual
    union all
    select 'Intell product' product from dual
    SELECT     product
    ,     CASE
             WHEN  SUBSTR (product, 1, 4) = 'xyz '
             THEN  SUBSTR (product, 5)
             ELSE  product
         END          AS no_xyz
    FROM     table_x
    ;Output:
    PRODUCT          NO_XYZ
    xyz Dell product Dell product
    Intell product   Intell productIf you really want to use INSTR, here's one way to get the same results:
    SELECT     product
    ,     CASE
             WHEN  INSTR (product, 'xyz ') = 1
             THEN  SUBSTR (product, 5)
             ELSE  product
         END          AS no_xyz
    FROM     table_x
    ;This will not remove 'xyz ' from elsewhere in the string, as you specified:
    Rinne wrote:
    ... and I want to remove the beginning xyz word from the string ...Edited by: Frank Kulash on Oct 28, 2010 9:20 AM

  • Substr/Instr/analytics question

    I have a table like this on 9i (soon to be 10g)
    CREATE TABLE BASELINE_TESTRUN
    RUNID VARCHAR2(42 BYTE) NOT NULL
    with data like this:
    insert into BASELINE_TESTRUN values ('DEV1-XXX-01');
    insert into BASELINE_TESTRUN values ('DEV1-XXX-03');
    insert into BASELINE_TESTRUN values ('DEV2-XXX-01');
    insert into BASELINE_TESTRUN values ('DEV2-XXX-02');
    insert into BASELINE_TESTRUN values ('DEV2-XXX-03');
    insert into BASELINE_TESTRUN values ('DEV2-XXX-05');
    insert into BASELINE_TESTRUN values ('DEV2-XXX-06');
    insert into BASELINE_TESTRUN values ('DEV2-XXX-06');
    The output should be the next higher number of the last substring in runid
    DEV1-XXX 04
    DEV2-XXX 07
    There may be missing no, and/or duplicates.
    This was my Query for this - It works but seems rather clumsy. I would like to have done it in 1 SQL (avoiding the select from (select)):
    select runid , max (next_runno) next_runno
    from
    select substr(runid,1,instr(runid,'-',1,2)-1) runid,
    max(substr(runid,instr(runid,'-',1,2)+1))
    over(partition by substr(runid,1,instr(runid,'-',1,2)-1)) + 1 next_runno
    from baseline_testrun
    where instr(runid,'-',1,2) > 0
    ---where runid like 'whatever%'
    group by runid;
    Alternate solutions would be appreciated ... and NO I did not define that table like this.
    I would have preferred a sequence and a keys that was not composit (Codd/Date, pls. forgive the creators of the table)
    best regards
    Mette

    You are grouping you data. In this case an aggregate function could be more helpful than an analytic function.
    In 9i already you are be able to use the KEEP syntax for aggregates.
    Look at this example
    SQL> select substr(runid,1,instr(runid,'-',1,2)-1) group_run,
      2  to_number(
      3  max(substr(runid, instr(runid,'-',1,2)+1))
      4  keep (dense_rank last order by substr(runid, instr(runid,'-',1,2)))
      5  )+1 max_run
      6  from BASELINE_TESTRUN
      7  group by substr(runid,1,instr(runid,'-',1,2)-1);
    GROUP_RUN                                     MAX_RUN
    DEV1-XXX                                            4
    DEV2-XXX                                            7
    SQL> Dimas Version is better, since it avoids the keep syntax, that is not really needed for this special case.
    Message was edited by:
    Sven W.

  • Replace substr, instr with Reg_exp, is this possible,

    Hi Team,
    I have Small requirement below, i have writen Query For this but was thinking Is there Any better way Of
    doing it, esp With Use To reg_exp,
    i have Some code As shown below
    '23456_TR_ABC_CODE12_JPM-(1)100-(1)150'
    From this code i Only want portion which Is Between 'TR_' And '_CODE12' i.e. ABC,
    given Is my Query And its output
    Select
    substr( substr('23456_TR_ABC_CODE12_JPM-(1)100-(1)150',instr('23456_TR_ABC_CODE12_JPM-(1)100-(1)150','TR_',1,1)+3),
            1,
            instr(
                  substr('23456_TR_ABC_CODE12_JPM-(1)100-(1)150',instr('23456_TR_ABC_CODE12_JPM-(1)100-(1)150','TR_',1,1)+3),
                  '_',1,1
                  -1) "word"
    From dual;
            word
    1     ABC
    kindly let me know If there Is Any better way Of doing it,,,

    Jeneesh, in case there are several TR_ or _CODE12 in the line I'd advice to use non-greedy operators.
    SQL> with t as
      2     (select '23456_TR_ABC_CODE12_JPM_(1)_100_CODE12_ASJ' word from dual)
      3     select regexp_replace(word, '.*TR_<font color="red">(.*)</font>_CODE12.*', '\1') word
      4       from t;
    WORD
    <font color="red">ABC_CODE12_JPM_(1)_100</font>
    SQL>
    It is working with (+) sign.
    SQL> with t as
      2     (select '23456_TR_ABC_CODE12_JPM_(1)_100_CODE12_ASJ' word from dual)
      3     select regexp_replace(word, '.*TR_<font color="blue">(.+?)</font>_CODE12.*', '\1') word
      4       from t;
    WORD
    <font color="blue">ABC</font>
    SQL>
    But I don't understand why it is not working with (*) sign :((
    SQL> with t as
      2     (select '23456_TR_ABC_CODE12_JPM_(1)_100_CODE12_ASJ' word from dual)
      3     select regexp_replace(word, '.*TR_<font color="green">(.*?)</font>_CODE12.*', '\1') word
      4       from t;
    WORD
    <font color="green">ABC_CODE12_JPM_(1)_100</font>Maybe someone can explain?
    Several more examples:
    the first and the last of them are really strange, at least for me:
    SQL> with t as
      2     (select '23456_TR_ABC_CODE12_JPM_(1)_100_CODE12_ASJ' word from dual)
      3     select regexp_replace(word, '^<font color="red">.*</font>TR_<font color="red">(.*?)</font>_CODE12.*$', '\1') word
      4       from t;
    WORD
    <font color="red">ABC_CODE12_JPM_(1)_100</font>
    SQL>
    SQL> with t as
      2     (select '23456_TR_ABC_CODE12_JPM_(1)_100_CODE12_ASJ' word from dual)
      3     select regexp_replace(word, '^<font color="blue">.*?</font>TR_<font color="blue">(.*?)</font>_CODE12.*$', '\1') word
      4       from t;
    WORD
    <font color="blue">ABC</font>
    SQL>
    SQL> with t as
      2     (select '23456_TR_ABC_CODE12_JPM_(1)_100_CODE12_ASJ' word from dual)
      3     select regexp_replace(word, '^<font color="red">.*?</font>TR_<font color="red">(.*)</font>_CODE12.*$', '\1') word
      4       from t;
    WORD
    <font color="red">ABC</font>
    SQL>

  • Using substr / instr to parse a filepath help

    I'm having trouble parsing a string per say using sql. I have a column full of file paths. The file paths are similar to:
    C:\Users\Guest\Pictures\example.jp
    I want to be ablt to grab just the file name of the image. I've been working on several variations of a query using the substr function and the instr function. I've come up with the query below. FILEPATH is the name of the column. So far it gives me the file name, but has the '\' in front of it. Can anyone help me get rid of this. Thanks in advance.
    Select substr(FILEPATH, (instr(FILEPATH,'\',-1,1)))
    from Table_Name
    where ID = '101'

    Hi,
    Here's one way:
    SELECT  SUBSTR ( filepath
                   , INSTR ( filepath
                           , -1
                           , 1
                           ) + 1    -- Note   + 1   at end
                    ) AS file_name_only
    FROM    Table_Name 
    WHERE   id = '101'
    SUBSTR (str, p)        returns the last part of string str, starting at position p.  You were passing the position of the last '\' as p; that's why the '\' was included.  If you add 1 to p, like this:
    SUBSTR (str, p+1)      then you'll be passing the position of the 1st character after the last '\'.

  • How to use Substr & Instr to get data from a file

    hi i have a Scenario
    i am getting a file like this
    1,20,ram,sales
    i am getting a file like this data as a column
    i want to split this data in 4 different column like
    1     20      ram     Sales

    Hi,
    this query will help you.
    select
         SUBSTR(C1,0,INSTR(C1,',')-1),
         SUBSTR(C1,INSTR(C1,',')+1,INSTR(C1,',',1,2)-INSTR(C1,',',1,1)-1),
         SUBSTR(C1,INSTR(C1,',',1,2)+1,INSTR(C1,',',1,3)-INSTR(C1,',',1,2)-1),
         SUBSTR(C1,INSTR(C1,',',1,3)+1,INSTR(C1,',',1,4)-INSTR(C1,',',1,3)-1),
         SUBSTR(C1,INSTR(C1,',',1,3)+1)
    from (
         select '1,20,ram,sales' C1 from dual
    remember that a comma isn't really safe as field separator
    Message was edited by: DecaXD

  • INSTR and SUBQUERY

    Hello
    I have to statements here that I don't understand. Can anyone explain what these two statements do.
    In the first statement I don't know what the 3 and 2 is.
    INSTR:
    SELECT INSTR('CORPORATE FLOOR','OR', 3, 2) "Instring"
    FROM DUAL;
    SUB-SELECT:
    SELECT a.ename, a.sal, a.deptno, b.salavg
    FROM emp a, (SELECT deptno, avg(sal) salavg
    FROM emp
    GROUP BY deptno) b
    WHERE a.deptno = b.deptno
    AND a.sal > b.salavg;

    Hi,
    INSTR - gives the starting position of the occurence of the string that is searched for, starting from the given position and if it is of nth occurrence.
    INSTR('STRING THAT IS SEARCHED' ,'STRING TO SEARCH',
    SEARCH_FROM_POSITION, SEARCH_FOR_Nth_OCCURRENCE)
    STRING THAT IS SEARCHED = 'CORPORATE FLOOR'
    STRING TO SEARCH = 'OR'
    SEARCH_FROM_POSITION = 3 (i.e. from the 3rd char)
    SEARCH_FOR_Nth_OCCURRENCE = 2 (i.e. the second time 'OR'
    occurrs after the 2nd char)
    For the following query would return - 14.
    SELECT INSTR('CORPORATE FLOOR','OR', 3, 2) "Instring"
    FROM DUAL;
    SUBQUERY,
    That is not a subquery that you had qiven, it is an inline view. It is nothing but a query in the FROM clause.
    Regards,
    Bharath

  • Using SELECT MAX(Substr( in a subquery to return specific rows

    Oracle v10
    Here's an example of a query and the output
    SELECT ID, SAMPLEID, COMPOUNDNAME, REQUISITION, SUBSTR(REQUISITION,2,4) FROM SEARCH PL1 WHERE SAMPLEID = 'IA 0005 0166';
    86907     IA 0005 0166     IA 0005     R2004:001160     2004
    98158     IA 0005 0166     IA 0005     R2005:000956     2005I am attempting to only return the newest row of data, in this case the 2005 row.
    I tried
    SELECT ID, SAMPLEID, COMPOUNDNAME, REQUISITION, SUBSTR(REQUISITION,2,4) FROM SEARCH PL1
    WHERE SAMPLEID = 'IA 0005 0166' AND
    REQUISITION IN
    (SELECT MAX(SUBSTR(REQUISITION,2,4)) FROM SEARCH PL2
    WHERE SUBSTR(PL2.REQUISITION,2,4) = SUBSTR(PL1.REQUISITION,2,4));But it returns no results. I feel I am missing something simple.
    TIA

    Hi,
    You're comparing a string to a 4-byte substring from the middle of itself. Those two will never be the same.
    Also, I don't think you want the sub-query to be corellated.
    Try this:
    SELECT      id
    ,     sampleid
    ,     compoundname
    ,     requisition
    ,     SUBSTR (requisition, 2, 4)
    FROM     search      pl1
    WHERE     sampleid = 'IA 0005 0166'
    AND     SUBSTR (requisition, 2, 4)     -- Changed
         IN  (
                 SELECT  MAX (SUBSTR (requisition, 2, 4))
              FROM     search pl2
    --           WHERE      SUBSTR (pl2.requisition, 2, 4) = SUBSTR (pl1.requisition, 2, 4)     -- Lose this, maybe
    ;If different substrings of requisition mean different things, then perhaps they should be stored in different columns. It will be easier to combine the different columns when you want to (e.g., for display) than it will be to split the single string apart every time you need to use only part of it, and it will be much more efficient as well.
    If you need to combine them often, you could create a view, or, starting in Oracle 11, use a virtual column.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Edited by: Frank Kulash on Dec 20, 2010 12:59 PM
    Formatted code

  • Urgent: Need Help with Substring/Instring

    I am taking a user input P_User_Name.
    P_User_Name is firstname/middlename/lastname
    Some examples:
    'James/Earl/Jones'
    '//Madonna'
    'Alec//Baldwin'
    Can someone tell me the code in PL/SQL to extract first name, middlename, lastname for a given P_User_Name.
    I would really appreciate your help.
    Thanks
    Home722

    Duplicate/triplicate posting... pathetic!!
    Urgent: SQL Gurus: Please Help
    Substring

  • Urgent - INSTR() Functions in OBIEE?

    Hi All,
    I just got some very good help from the DB experts on these forums about solving a problem with a table join that I had.
    But now I have this SQL query and I'm trying to figure out how to implement this in OBIEE:
    select *
    from TABLE1,TABLE2
    where instr(TABLE2.USER_ID,TABLE1.USER_ID) > 0
    My question is how do I implement this instr() function on OBIEE? I checked physical and business model mapping layers in the repository and it does not allow me to configure this type of join. Is it possible to configure this type of join function to be invoked automatically everytime a user runs a certain query in OBIEE (as if it was a natural join)?
    Any help would be greatly appreciated.
    Alan

    Hi,
    You can refer the below links,
    Substring instr issue in obiee
    extract a string from a string
    http://108obiee.blogspot.in/2009_10_01_archive.html
    Award points it is useful.
    Thanks,
    satya

  • Substr issue

    I have a column called vehicle desc
    which will have this type of info in it:
    "2007 light blue Kawasakme Eclipse"
    or
    "2006 cream Toyotwa Forerunner"
    I need to pull this data into three separate columns called YEAR, MAKE, and MODEL.
    I can pull out the year with a simple substr, but as you can see the position of the make and model varies.
    Luckily there are only about 12 makes, and the model always follows the make.
    Any ideas? Do I have to make a long "case" statement or "with" clause?

    Here if only the last word in the string is MODEL then you can start cutting the string from end and cut it till first space from end of string.
    If MODEL includes the last two words then pick up the first letters of the words after the space from the end using substr, instr.

  • Chars - subString - String

    Good morning...
    I got a sub sequence of a string... n now I'm trying to use this sub string as a string... but the javac only tells me a warning like incompatible types...
    inputLine.subSequence(tamanho-contador,tamanho-(contador-5))
    I tryed to convert that charSequence (that java says me) and convert to a string.. but it brings me that java.lang.Object cannot be applied to java.lang.charSequence
    How may I do to take that substring n use like another independent string?
    I would like to put more three chars before convert it.
    Like:
    abc123def
    I took c123d using subSequence n I want to put more three chars "jav" to finally my string stay like c123djav
    How may I do to put more chars n convert it to a String? (In start I was suposed that the substring was a string... but it makes me an error....)
    Thanks...

    Ok... I used that
    String anT = inStr.substring(inStr.indexOf('c'), inStr.length()-2)+"jav";
    But it makes a warning like:
    subSequence(int,int) in java.lang.String cannot be applied to (int, java.lang.String)
    I think I need to mix the "jav" after take the string... c123d ... but even only taking that subSequence, and trying to put in a string, I have a warning like:
    incompatible types
    found: java.lang.charSequence
    required: java.lang.String

Maybe you are looking for

  • Convertion of flat file to XML using DOM

    Hi! I need help for convert a flat file to XML using DOM and by taking the validation of a specified DTD. Can any body help me in this regard. Bye, lat

  • Xferring 45gb HD from a regular Lap 'Top to a mini PC laptop

    I wonder if it is possible to transfer a 45GB HD (Windows XP OS) to a minicomputer (Windows XP OS).  My reason is that I have a laptop that I can no longer access because one keyboard letter does not work, and it happens to be one that Is in my log o

  • Airport Extreme- PC users cannot connect to security enabled Wifi

    I have an Airport Express and have setup a security enabled Wifi network.  It works perfectly for me, but my PC user roomates cannot access it.  I don't know much about the difference between WPA and other settings, so maybe I need to change the secu

  • Message waiting with music to download

    I bought music on iTunes through my iPad. When I used iCloud to share the music on my iPhone 5 it is a state of waiting and will not down load. Hope someone. can help

  • Camera Raw custom settings issue on 4.5?

    I updated to CR 4.5 on my new Mac 17 inch powerbook, and now the custom settings choice uder the basic pull down menu no longer seems to do anything. It used to update from the previous change I had done in the open camera raw window. Now I would nee