Values of combination using substr

Hi team,

I have the script below to get all combinations of values of position to end the starting position

The format of the input string can be "AB CD" or "ABCD".

Start

FOR SELECT fir "AB CD" NM FROM DUAL

LOOP

S IN 1.length (fir.nm)

LOOP

dbms_output.put_line (' value of substr is ': substr (fir.nm, 1, s));

END LOOP;

END LOOP;

end;

Here is the output of the above script.

value of substr is A

value of substr is AB

value of substr is AB

value of substr is AB C

value of substr is AB CD

I need now below also values as output.

B

B AND C

B CD

C

CD

How can I get the above values also and output.

Pretty much the same as suggestion of Roger, just filtering strings with spaces attack/crawling.

Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing options

SQL > VARIABLE letters VARCHAR2 (30);
SQL > EXEC: letters: = "AB CD;

PL/SQL procedure successfully completed.

SQL > SELECT letters
2 (SELECT REPLACE (sys_connect_by_path (letter, '.'), '.') letters)
3. FROM (SELECT LEVEL l, substr (: letters, LEVEL 1) letter)
4 DOUBLE
5. CONNECT BY LEVEL<=>
6 CONNECT BY l = l + 1 PREREQUISITE)
7. WHERE letters NOT LIKE '% '.
8 AND letters NOT LIKE '% ';

LETTERS
--------------------------------------------------------------------------------
A
AB
AB C
AB CD
B
B AND C
B CD
C
CD
D

10 selected lines.

SQL > EXEC: letters: = "ABCD";

PL/SQL procedure successfully completed.

SQL > /.

LETTERS
--------------------------------------------------------------------------------
A
AB
ABC
ABCD
B
BRITISH COLUMBIA
BCD
C
CD
D

10 selected lines.

SQL >

Tags: Database

Similar Questions

  • Combination of substring and instring in RTF - dynamic signature images url

    I am unable to use a combination of substring and instring in RTF model.

    I have a BUYER_LAST_NAME column, which has a Jean Dupont value. I like to shoot 'john' on this channel.

    I tried to create a variable using <? xdoxslt:set_variable($_XDOCTX,_'new_name',_'')? >

    So I want to do a get variable using substr and InStr.

    <? xdoxslt:get_variable (substring _XDOCTX, BUYER_LAST_NAME, $(DOCUMENT_BUYER_LAST_NAME, 1, instring(BUYER_LAST_NAME,' ')-1))? >

    The command above does not work as a substring and instring aren't xdoxslt operations.

    I tried to do this using xdofx: <? xdofx:substr (BUYER_LAST_NAME, 1, Instr(BUYER_LAST_NAME,' ')-1)? >

    The above work, but I don't know how to make a variable defined using xdofx. Please help me on this.

    Published:

    I want to use this field in a dynamic signature display. But I can't call substring-before command as part of the url.

    URL: {(concat('${OA_MEDIA}','/purchase_order/signatures/',.//BUYER_FIRST_NAME,'_',.//BUYER_LAST_NAME,'.jpg')}

    I want to change the BUYER_LAST_NAME here.

    I'm working on

    URL: {concat (' ${OA_MEDIA} ',' / purchase_order/signatures /',. / / DOCUMENT_BUYER_FIRST_NAME, "_",. / /, '.jpg')}

    But it does not work.

    ->

    URL: {concat (' ${OA_MEDIA} ','/ purchase_order/signatures /',. / / DOCUMENT_BUYER_FIRST_NAME, '_', substring-before(.//DOCUMENT_BUYER_LAST_NAME, ' '), '.jpg')}

    who is working for me

  • How to use substr and instr, where the line of input Multi text

    Hi all

    with

    data in the form of)

    Select ' Mary America.1234 Southridge Park Dr... Samna Lorie.MO.31234..' double val

    Union of all the

    Select 'Bill Johnson.Apartment 3 b. Sterling.VA.20166.3 Plaza Falke' of the double

    )

    Select

    regexp_substr (shipping_instructions, "[^ #] +' 1, 1") name

    , regexp_substr (shipping_instructions, "[^ #] +' 1, 2") address

    , regexp_substr (shipping_instructions, "[^ #] +' 1, 3") city

    , regexp_substr (shipping_instructions, "[^ #] +' 1, 4") State

    , regexp_substr (shipping_instructions, "[^ #] +' 1, 5") zip

    , regexp_substr (shipping_instructions, "[^ #] +' 1, 6") County

    FROM (select REGEXP_REPLACE (val, ' \.)) () [^.])', ' #\1 ") data shipping_instructions)

    (1)'Mary America.1234 Southridge Park Dr... Samna Lorie.MO.31234..'

    (2)'Bill Johnson.Apartment 3 b. Sterling.VA.20166.3 Falke Plaza. »

    "Mary America. 1234 Southridge Park Dr. Samna Lorie. MO.31234..'

    NAME ADDRESS CITY ZIP County SATE

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

    Married America 1234 Southridge Park Dr.    Samna Lorie MO 31234  NULL VALUE

    "Bill Johnson. Apartment 3B. Sterling. VA. 20166. Falke Plaza 3... "

    NAME ADDRESS CITY ZIP County SATE

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

    Bill Johnson apartment 3B Sterling, WILL 20166 3 Falke Plaza.

    Problem

    ---------

    (1) if the value, if the County (if null) value then it shows the ZIP with dot's (.) value, in the 31234 above..,.

    How to solve this problem?

    (2) another possible to fix the code, I want to use substr and InStr.

    (3) who is the best approach?

    Conditions:

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

    (1) shipping_instructions column has the value with "Mary America.1234 Southridge Park Dr... Samna Lorie.MO.31234... »

    This means it combined all the similar name, address, city, State, zip

    (2) we insreted in the table separately.

    =========================

    / * Use Substr and Instr * /.

    =========================

    I used substr and instr, but I'm getting the money results (no point in the address).

    "America Mary. 1234 Southridge Park Dr. Samna Lorie.MO.31234..'


    NAME ADDRESS CITY ZIP County SATE

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

    Mary America 1234 Southridge Park Dr. Samna Lorie MO 31234  NULL VALUE

    But I need the results (no point in the address)

    NAME ADDRESS CITY ZIP County SATE

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

    Mary America 1234 Southridge Park Dr.    Samna Lorie MO 31234  NULL VALUE

    Hello

    994122 wrote:

    Hello

    (1) how do to do this, use the substr and instr functions?

    Thank you

    You can't do all the work with SUBSTR and INSTR; you need regular expressions to obtain a string delimited by a #.

    Once you have such a string, then you can use SUBSTR and INSTR (instead of REGEXP_SUBSTR) to get the separate secondary strings:

    WITH got_delimited_string AS

    (

    SELECT REGEXP_REPLACE (val

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

    , '#\1'

    ) AS delimited_string

    FROM the data

    )

    got_pos AS

    (

    SELECT delimited_string

    , INSTR (delimited_string, "#", 1, 1) AS pos_1

    , INSTR (delimited_string, "#", 1, 2), pos_2

    , INSTR (delimited_string, "#", 1, 3) AS pos_3

    , INSTR (delimited_string, "#", 1, 4) AS pos_4

    , INSTR (delimited_string, "#", 1, 5) AS pos_5

    , INSTR (delimited_string, "#", 1, 6) AS pos_6

    OF got_delimited_string

    )

    SELECT SUBSTR (delimited_string, 1, pos_1 - 1) AS the name

    SUBSTR (delimited_string, pos_1 + 1, pos_2 - (pos_1 + 1)) AS address

    SUBSTR (delimited_string, pos_2 + 1, pos_3 - (pos_2 + 1)) AS city

    SUBSTR (delimited_string, pos_3 + 1, pos_4 - (pos_3 + 1)) AS State

    REPLACE (SUBSTR (delimited_string, pos_4 + 1, pos_5 - (pos_4 + 1))

    , '.'

    )                                                           AS zip

    SUBSTR (delimited_string, pos_5 + 1, pos_6 - (pos_5 + 1)) AS the County

    OF got_pos

    ORDER BY delimited_string

    ;

  • How to use substr to search and show as an ouput in oracle 11g

    Hi all

    Suppose I have oracle.india.com1.1234 in my value line so I need not to show the India as output. I need to display in the .csv (Excel)

    Thank you

    You can use SUBSTR + INSTR:

    with t as)

    Select 'oracle.india.com1.1234' union str double all the

    Select "oracle.England.com1.1234" from double

    )

    Select str,

    substr (STR, InStr(STR,'.') + 1, instr(str,'.',1,2) - instr(str,'.') - 1) new_str

    t

    /

    STR NEW_STR
    ------------------------ ------------------------
    Oracle.India.COM1.1234 India
    oracle.England.com1.1234 England

    SQL >

    Or use regular expressions:

    with t as)

    Select 'oracle.india.com1.1234' union str double all the

    Select "oracle.England.com1.1234" from double

    )

    Select str,

    regexp_substr (str,'[^.] +', 1, 2) new_str

    t

    /

    STR NEW_STR
    ------------------------ ---------------------
    Oracle.India.COM1.1234 India
    oracle.England.com1.1234 England

    SQL >

    SY.

  • data of cutting using substring and instring, and storage in a new table

    Hi all

    I have an emp_address 2tables, address as below:
    ---------------------------------------------------------------
    create the table emp_address (emp_id varchar2 (10), address varchar2 (100));

    Insert into EMP_ADDRESS
    (EMP_ID, ADDRESS)
    Values
    ('101', 'street1 fremont CA 94538');
    Insert into EMP_ADDRESS
    (EMP_ID, ADDRESS)
    Values
    ("102", "Street.2 fremont, CA 94537');
    COMMIT;


    create the address table (emp_id varchar2 (10), street varchar2 (20), city varchar2 (15), State varchar2 (10), zip varchar2 (10));

    -----------------------------------------------------------------------------
    Emp_address data as below:

    emp_id address

    street1 101 fremont CA 94538

    102 fremont, CA 94537 Street.2

    ------------------------------------------------------------------------------
    now I read data emp_address and split the data of the address column and record these data in the address table like as below

    emp_id Street City State Zip Code
    street1 101 fremont, ca 94538
    102 fremont, ca 94537 Street.2

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


    I'm trying to divide these data using substring and instring. Actually my problem was between the data a few times I have 1tab or 2tabs and sometimes 3tab. If the number of tab spaces is not constant.

    So can u help me in this case.

    Thanks in adavnce

    position of reference BluShadow

    WITH emp_address AS (SELECT   '101' emp_id,
                                  'street1 fremont CA 94538' address
                         FROM     DUAL
                         UNION ALL
                         SELECT   '102',
                                  'street2  fremont CA 94537'
                         FROM     DUAL),
        emp_address_list_temp AS
          (SELECT       emp_id,
                        SUBSTR (
                          address,
                          DECODE (LEVEL,
                                  1, 1,
                                  INSTR (address, ' ', 1, LEVEL - 1) + 1
                                 ),
                          DECODE (
                            INSTR (address, ' ', 1, LEVEL),
                            0,
                            LENGTH (address),
                            INSTR (address, ' ', 1, LEVEL)
                            - DECODE (LEVEL,
                                      1, 0,
                                      INSTR (address, ' ', 1, LEVEL - 1)
                                     )
                            - 1
                          )
                        )
                          address,
                        LEVEL rn
           FROM         emp_address
           CONNECT BY   LEVEL <=
                          LENGTH (address) - LENGTH (REPLACE (address, ' ')) + 1
           GROUP BY     emp_id, address, LEVEL),
        emp_address_list AS
          (SELECT   emp_id,
                    address,
                    ROW_NUMBER () OVER (PARTITION BY emp_id ORDER BY rn) rn
           FROM     emp_address_list_temp
           WHERE    TRIM (address) IS NOT NULL)
    SELECT     emp_id,
               (SELECT   address
                FROM     emp_address_list e2
                WHERE    e2.emp_id = e1.emp_id
                     AND rn = 1)
                 street,
               (SELECT   address
                FROM     emp_address_list e2
                WHERE    e2.emp_id = e1.emp_id
                     AND rn = 2)
                 city,
               (SELECT   address
                FROM     emp_address_list e2
                WHERE    e2.emp_id = e1.emp_id
                     AND rn = 3)
                 state,
               (SELECT   address
                FROM     emp_address_list e2
                WHERE    e2.emp_id = e1.emp_id
                     AND rn = 4)
                 zip
    FROM       emp_address_list e1
    GROUP BY   emp_id
    
  • How to change values to text using VBscript

    I have a model that contains the part of text-value 6 and a table. I figured out how to import the string table to the table, but I couldn't find how to change my text values. Below, you can see my table of text values.

    I'll send this table to DIAdem report function. Could you please help me how to change my text values in TDR using VBscript.


  • Why doesent runstate.sequencefile.data.seq.mysequence.mystep.result.numeric contains a measure value when I use it in a reminder of the UUT post?

    Hello

    I want to write that a witch of the csv file contains all the measured values and the limits of my machine. So I try to give the values in post use reminder to a vi. The limits work and the csv file contains all my limits, but the measured values are all 0. I used runstate.sequencefile.data.seq.mysequence.mystep.result.numeric

    I do not want to do with FileGlobals because they are values much.

    Thanks for any advice for this problem.

    There is probably a better way to accomplish what you want.  But to make your life easier, I'll give you the hacky solution:

    Use: Runstate.ProcessModelClient.Data.Seq.MyStep.Result.Numeric

    The funny is that the report must contain all the information you want. Just, I would create an engine to convert your csv look.  If you use 2012 then this seems to be an ideal candidate for a plugin.

    Hope this helps,

  • RegExp_. Using substr

    Hi - I need to extract the string after the last ' / ' and everything before the last ' / '. Possible to do using substr and instr but I would like to know how this can be done using regexp_substr.

    for example: / Merchants/Retail/ShopBrand/Home/Holidays/Bed

    My requirement is to extract 'Reads', which is after the last ' / ' and '' / Merchants/Retail/ShopBrand/Home/Holidays which is before the last ' / '.

    Help, please

    Could you give the explanation as well to '. * /', '' ?

    We receive all the strings until the last ' / ' and substituting null

    And my second (not a Cleaver) option would be:

    SELECT REGEXP_REPLACE(REGEXP_SUBSTR('/Merchants/Retail/ShopBrand/Home/Holidays/Bed', '.*/'), '.$', '') FIRST_REQUIREMENT FROM DUAL;
    

    Here, we remove the last character. Take a look at the documentation to go further: http://docs.oracle.com/database/121/ADFNS/adfns_regexp.htm#ADFNS1003

    Kind regards.

  • WE SHOULD NOT USE SUBSTR FUNCTION...

    Hello

    ex: [email protected] , [email protected] [email protected]

    AS THIS HUNDRED PLATE IS HERE.

    QUERY:

    I DON'T WANT THAT YAHOO, GMAIL LIKE THAT... WE SHOULD NOT USE SUBSTR FUNCTION...

    THIS IS AN INTERVIEW QUESTION

    Thank you

    Try:

    Select regexp_replace (' [email protected]',' ^. * @(.*)-.) (. *)', '\1') twice;

  • using substr and instr

    Hi all

    create table abc (str varchar2 (10))

    insert into abc values ('ABC - DEF')

    Insert into abc values('ABC/DEF')

    Insert into abc values ('ABC DEF')

    Insert into abc values('ABC.) DEF')

    insert into abc values ('ABC DEF')

    I need to put as ABCDEF for all values, if possible using sustr and instr

    Thank you

    Three ways:

    Select replace (str, translate(str,'~ABCDEFGHIJKLMNOPQRSTUVWXYZ','~')) in abc;  -assuming a single character is there in your data...

    -generic way to remove all of the other characters keeping uppercase alphabets

    SELECT TRANSLATE (str, ' ~' |) TRANSLATE (str, ' ~ ABCDEFGHIJKLMNOPQRSTUVWXYZ ',' ~'), ' ~') of ABC;

    -Using regular expressions

    Select regexp_replace(str,'[^[:alpha:]]') in abc;

    See you soon,.

    Manik.

  • Setting a value to variable using an sql and javascript

    Hello

    I'm trying to be a value of variables using javascript and sql. The code is as below:


    < script >
    function getDueDate() {}
    function getVal (item) {}
    If ($x (point) .value! = "")
    Return parseFloat ($x (item) .value);
    on the other
    Returns a null value.
    }
    $x('P26_DUE_DATE').value = select sysdate + $x ('P26_PAY_TERM') of the double
    }
    < /script >

    Can this be achieved?

    Hello

    JS and SQL are 2 different languages, so you can't do what you want to do using this script. The good thing is that you can still do so using JS.

    $x('P26_DUE_DATE').value = select sysdate + $x ('P26_PAY_TERM') of the double

    the "Select Sysdate" try to use the date JS Object (http://www.w3schools.com/jS/js_obj_date.asp) to add dates together.

    Martin
    -----
    [http://apex-smb.blogspot.com/]
    [http://apex.stackexchange.com/]

  • Using SUBSTR to convert part of an IP address to a NUMBER and then sort

    Hello!

    I have a table in APEX that IP numbers and was looking for a way to be able to sort out them.

    I wrote the following script:
    SELECT TO_NUMBER (SUBSTR (IP, 11)) y
    OF NETWORKINFO y
    ORDER BY y

    Which produces the results I'm looking for.

    However, I use the 'FORM ON A TABLE WITH REPORT' by their SUMMIT. It is perfect for what I need, but here's my question:

    How can I go about adding my custom SQL string to be able to use the feature to sort of this 'FORM ON A TABLE WITH REPORT "?

    In the above form, it gives the ability to sort by any column. Is there a way I could do a column hidden, associated with the IP column to sort results?

    Sorry if I'm not in all this that claire here - let me see if I can be more specific.

    I have the IP addresses which of course do not sort numerically. So I wrote the SQL script above to convert a portion of these IP addresses in a number format.

    Is it possible to combine the two in the search function in 'Form on a Table with report' so I can get a user sort by IP number, but behind the scenes it sorts using the SUBSTR value from above?

    Thank you for pointing me in the right direction on this subject!

    -Igor

    Hi Igor,.

    You can get a custom sort order added to your IP column without needing a second column.

    Consider that the sorting is done strictly from left to right across a string in the column. The string can be any content valid HTML. So you can wrap your string in, say, a SPAN tag and add an attribute to the tag that contains the sort order, you need to forward the text that is displayed to the user. As long as the attribute is properly structured (in other words, all instances are the same length, for example), then sort will work correctly. For example:

    SELECT
    '' || IP || '' Y
    FROM ...
    

    Now you must make sure that the PAD_IP_ADDRESS() function returns the correct values. In IP addresses, you have whatever it is "0.0.0.0" to "255.255.255.255". To sort "digitally", you need fill one or two numbers to get three numbers for each value of - so, "0.0.0.0" becomes "000.000.000.000." You can create a function to do this - something like:

    CREATE OR REPLACE FUNCTION PAD_IP_ADDRESS
    (
      pIP IN VARCHAR2
    )
    RETURN VARCHAR2
    IS
      vIP VARCHAR2(15);
      vTEMP APEX_APPLICATION_GLOBAL.VC_ARR2;
      vSEP VARCHAR2(1);
    BEGIN
      vSEP := '';
      vIP := '';
      vTEMP := APEX_UTIL.STRING_TO_TABLE(pIP,'.');
      FOR x IN 1..vTEMP.COUNT
      LOOP
        vIP := vIP || vSEP || TRIM(TO_CHAR(TO_NUMBER(vTEMP(x)),'000'));
        vSEP := '.';
      END LOOP;
      RETURN vIP;
    END;
    

    The result of this would look like:

    <span title="001.001.001.001">1.1.1.1</span>
    <span title="002.255.255.255">2.255.255.255</span>
    <span title="010.001.199.098">10.1.199.098</span>
    

    Andy

  • A string into the text and numbers using SUBSTR and INSTR

    I have the sample data. I know it's terrible database designed for a combination of text and numbers in the same field, but I can't change the business process.

    That's what I have so far:

    set linesize 5000
    
    WITH table_data
         AS (SELECT 'R: JASON BOURNE 12341560' str FROM DUAL UNION ALL
             SELECT 'R: FATS DOMINO 23432342' str FROM DUAL UNION ALL
             SELECT 'R: MARTIN LUTHER KING 3334156' str FROM DUAL UNION ALL
             SELECT 'R: TOM CRUISE 6547123' str FROM DUAL UNION ALL
             SELECT 'R: TOMMY DE GROOT 1212124' str FROM DUAL UNION ALL
             SELECT 'R: GRIM REAPER 1345245' str FROM DUAL UNION ALL
             SELECT 'R: DOCTOR DEATH THE FIRST SMITH 24356178' str FROM DUAL)
    SELECT str
         , TRIM(SUBSTR(str, INSTR(str, ' ', 1, 1), INSTR (str, ' ', 1, 2) - INSTR (str, ' ', 1, 1))) first_name
         , REPLACE(SUBSTR(str, INSTR (str, ' ', 1, 2)+1, 999), SUBSTR(str,LENGTH(str)-6,7), '') last_name
         , SUBSTR(str,LENGTH(str)-6,7) emp_num
      FROM table_data;
    
    STR                                      FIRST_NAME    LAST_NAME                 EMP_NUM
    ---------------------------------------- -----------------------------------------------
    R: JASON BOURNE 12341560                 JASON         BOURNE 1                  2341560
    R: FATS DOMINO 23432342                  FATS          DOMINO 2                  3432342
    R: MARTIN LUTHER KING 3334156            MARTIN        LUTHER KING               3334156
    R: TOM CRUISE 6547123                    TOM           CRUISE                    6547123
    R: TOMMY DE GROOT 1212124                TOMMY         DE GROOT                  1212124
    R: GRIM REAPER 1345245                   GRIM          REAPER                    1345245
    R: DOCTOR DEATH THE FIRST SMITH 24356178 DOCTOR        DEATH THE FIRST SMITH 2   4356178
    
    7 rows selected.
    

    I need to:

    1 extract the first name - which is always the first name after the 'r' - I've got that little works very well.

    2 extract the name - should be the last word before the number, if e.g. for the last night, I wish only that 'SMITH' and 'KING' for the 3rd line and "GROOT" for the 5th line.

    3. remove the number at the end, regardless of the length - some of the examples above are 8 long numbers so my attempt above does not work.

    I can't use any REGEXP or REGEXP_SUBSTR because they are not registered in the EUL I'm using discoverer, I can only use INSTR AND SUBSTR.

    I was wondering if someone might be able to help please?

    Any advice much appreciated.

    Thank you

    AW, go on them, as it's Christmas, I'm feeling generous...

    SQL > ed
    A written file afiedt.buf

    1. WITH table_data (SELECT "r: JASON BOURNE 12341560' DOUBLE UNION ALL STR ')
    2. SELECT "r: FATS DOMINO 23432342' str OF DOUBLE UNION ALL.
    3. SELECT "r: MARTIN LUTHER KING 3334156' str OF DOUBLE UNION ALL.
    4. SELECT "r: TOM CRUISE 6547123' str OF DOUBLE UNION ALL.
    5. SELECT "r: TOMMY GROOT 1212124' str OF DOUBLE UNION ALL.
    6. SELECT "r: GRIM REAPER 1345245' str OF DOUBLE UNION ALL.
    7. SELECT "r: DOCTOR DEATH FIRST SMITH 24356178' FROM DUAL str.
    8                     )
    9 select substr (str, 1, instr(str,' ')-1) as a first name
    10, substr (substr (str, 1, instr(str,' ',-1)-1), instr (substr (str, 1, instr(str,' ',-1)-1),' ', 1) + 1) as last_name
    11, substr (str, instr (str, ' ',-1) + 1) as emp_num
    12 years of (select replace (str,'R: ') as str)
    table_data 13
    14*        )
    SQL > /.

    FIRST_NAME LAST_NAME EMP_NUM
    ---------------------------------------- ---------------------------------------- ----------------------------------------
    JASON BOURNE 12341560
    FATS                                     DOMINO                                   23432342
    MARTIN                                   KING                                     3334156
    TOM                                      CRUISE                                   6547123
    TOMMY                                    GROOT                                    1212124
    GRIM                                     REAPER                                   1345245
    DOCTOR SMITH 24356178

    7 selected lines.

  • using substr in the select statement

    Hi all

    I'll have a column as below from a table values.

    "404-297-9559 UNLISTED."

    "123 211 2345 KGTFE".

    "123 293 2789 GFT.

    OUTPUT should be like below... is it possible in sql oracle and my client uses the 8i version.

    404-297-9559

    123-211-2345

    123-293-2789

    Thank you

    KBS

    2804972 wrote:

    I gave only for three values of the column as an example, there are millions of records... hard coding is not possible. Please suggest me other

    Thank you

    KBS

    Where does show that you need to hard no matter what code?

    The comment in the code indicates that the WITH clause is just used to provide sample data to the query (so I can't create a table in my database).  What keeps you using the same query against your own data table?  Do you really understand the basic concept of a SQL selection in a table?  Did you even try and understand the code?

    Is it really that hard for you to have tried to do:

    Select substr (yourcolumname, 1, instr (yourcolumnname,' ', 1)-1) as txt

    of yourtablename

  • In the Select statement using substring comparison

    Hello

    Based on the requirement of the enterprise, I m trying to get geography_element4 to the hz_geographies table that corresponds to the value of the p_city parameter.

    Here, I take p_city from the 4th character value to 8 characters.

    For under query, I m not getting the correct result. The statement is true?   GE.geography_element4 as substr(:p_city,4,8);

    SELECT UPPER (ge.geography_element4)

    OF apps.hz_geographies ge

    WHERE ge.geography_type = "zip_code".

    AND ge.geography_name = SUBSTR(:postal_code,1,5)

    AND ge.created_by_module = 'EBTAX_CONTENT_UPLOAD. '

    AND ge.country_code = 'en '.

    AND ge.geography_element4 like substr(:p_city,4,8);

    Thank you.

    ef2019c7-080c-4475-9cf4-2cf1b1057a41 wrote:

    Can I use something like '% substr(:p_city,4,5) % '.

    Yes, you should, but using the correct syntax. Do you understand how AS works? It involves wildcards are used in similar Configuration. Otherwise, it's same as equals. Assume that p_city is "FT LAUDERDALE". Then substr(:p_city,4,5) is 'LAUDE '. Then ge.geography_element4 AND as substr(:p_city,4,5) will compare "FT. LAUDERDALE" "LAUDE", of course, without a game. When wrap you it with jokers '% "| substr(:p_city,4,5) | '%' AS get ge.geography_element4 that contains "LAUDE" and "FT LAUDERDALE" will be a game.

    SY.

Maybe you are looking for