A group of substrings of a string of search and display all records

Hello

I'm using Oracle 11 g.

I store multiple values in a column, separated by delimiter(#@#). I know it's wrong to databases, but since it is used for many years I can't do much.

I need to perform a search operation where I pass multiple values and I should get all records if any of a value match the stored value. I read about regular expressions for this kind of scenario.

Can someone guide me how to proceed with this? Thanks in advance.

Thank you

Hello

How about this? I tried to simplify your function. I don't know if I got your needs just fine.

CREATE OR REPLACE FUNCTION Search_MultiValue (p_Name IN Varchar2, v_Name in Varchar2, p_delimiter IN VARCHAR2 DEFAULT ',') RETURN Number IS
v_delimiter VARCHAR2(3) := '#@#';
BEGIN
    RETURN CASE WHEN REGEXP_INSTR(v_delimiter || p_Name || v_delimiter
                                , REPLACE(v_delimiter ||v_Name || v_delimiter, p_delimiter, '|') )  > 0
                              THEN 1
                              ELSE 0
                  END;
END;
/
SELECT search_multivalue('ABC#@#DEF#@#GHI#@#JKL','ABC,GHI') AS res
FROM dual;

RESULT:

1

Tags: Database

Similar Questions

  • Add a string when the query returns all records

    DB version: 11.2

    create table t (empname varchar2 (25), salary number, varchar2 (20) months, number of over_time);

    insert into values t ('JOHN', 2000, "NOVEMBER2014", 0);

    insert into values t ('KATE', 2000, "NOVEMBER2014", 300);

    insert into values t ('HANS', 5000, "NOVEMBER2014", 100);

    insert into values t ("KRISHNA", 2500, "NOVEMBER2014", 0);

    insert into values t ("SIEW", 3000, "NOVEMBER2014", 0);

    commit;

    SQL > select * from t;

    EMPNAME MONTHS SALARY OVER_TIME

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

    JOHN 2000 NOVEMBER2014 0

    KATE 2000 NOVEMBER2014 300

    HANS 5000 NOVEMBER2014 100

    KRISHNA 2500 NOVEMBER2014 0

    SIEW 3000 NOVEMBER2014 0

    SQL > select * from t where MONTH = 'NOVEMBER2014' and OVER_TIME! = 0 ;

    EMPNAME MONTHS SALARY OVER_TIME

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

    KATE 2000 NOVEMBER2014 300

    HANS 5000 NOVEMBER2014 100

    What I need is:

    If the query above returns at least one record, it should display the line ' Yes. We have one or more employees who worked overtime in November2014'

    before the documents are printed

    Thus, the expected production is

    Yes. We have one or more employees who worked overtime at the November2014

    EMPNAME MONTHS SALARY OVER_TIME

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

    KATE 2000 NOVEMBER2014 300

    HANS 5000 NOVEMBER2014 100

    If the query returns no records then usual 'no rows selected' isn't enough

    Lothar G.f. says:

    In fact, sql * more is no good tool for use considered.

    Really?  It may be a good reporting tool if you learn to use it as such...

    for example

    SQL > ttitle left 'Yes. We have one or more employees who worked overtime in November2014.
    SQL > select * from emp where empno = 1234;

    no selected line

    SQL > select * from emp where empno = 7788;

    Yes. We have one or more employees who worked overtime at the November2014
    EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR
    ---------- ---------- --------- ---------- -------------------- ---------- ---------- ----------
    7788, SCOTT, ANALYST, 7566 19 APRIL 1987 00:00:00 3000 20

    This is just a basic example.  It is possible to get SQL * more to ask for the required criteria and that the title could adjust according to this criterion, as well as the query building on it also.

    However, the OP did not specify SQL * as the reporting tool, so there is little interest providing a complete solution which, until they specify what user interface that they are actually using.

  • How to create a group/list of the variables in the box for display in the text field, in the format in annex

    I need to identify a series of variables single-response checkbox and display links selected (as a group) in a text field in an annex (comma, space) format. Last week, you provided a small script for a similar requirement by using the list box (multiple response) variables. This time, I need to know how to identify the variables of the box officially and, presumably, use a similar script to display the results in a comma, space format.

    You've been a great help.

    Thank you

    Here's the script for this situation. It assumes there are ten boxes named cb1, cb1, cb2,... cb10.

    // Custom Calculate script for text field
    (function () {
    
        // Initialize the string
        var v, s = "";
    
        // Loop through the check boxes to build up a string
        for (var i = 1; i < 11; i++) {
    
            // Get the value of the current check box
            v = getField("cb" + i).value;
    
            if (v !== "Off") {
                if (s) s += ", ";  // Add a comma and a space if needed
                s += v;  // Add the selected value
            }
        }
    
        // Set this field value to the string
        event.value = s;
    
    })();
    

    You will have to change the name of the field and start/end numbers to match your form.

  • I can't seem to make the "search and replace string" works as expected.

    I tried to replace "^ []] +---+ ([^] +).» "$*" with $1 in "create table leq_octave_5min (recorded_time DATETIME CONSTRAINT pk1 PRIMARY KEY, leq5m leq5m of FLOAT CONSTRAINT NOT NULL, min min FLOAT CONSTRAINT NOT NULL, max max FLOAT CONSTRAINT NOT NULL, CONSTRAINT of FLOAT L05 05 NOT NULL, CONSTRAINT of FLOAT L10 10 NOT NULL, L50 FLOAT CONSTRAINT 50 NOT NULL, L90 FLOAT 90 CONSTRAINT NOT NULL. L95 FLOTTER CONSTRAINT 95 NON NULL, us01 us01 FLOAT CONSTRAINT NOT NULL, EN02 EN02 FLOTTER CONSTRAINT NOT NULL, fr03 FR03 FLOTTER CONSTRAINT NOT NULL, fr04 FR04 FLOTTER CONSTRAINT NOT NULL, fr05 FR05 FLOTTER CONSTRAINT NOT NULL, fr06 FR06 FLOTTER CONSTRAINT NOT NULL, fr07 FR07 FLOTTER CONSTRAINT NOT NULL, fr08 FR08 FLOTTER CONSTRAINT NOT NULL, fr09 FR09 FLOTTER CONSTRAINT NOT NULL, fr10 FR10 FLOTTER CONSTRAINT NOT NULL Fr11 FR11 FLOTTER CONSTRAINT NOT NULL, FR12 FLOTTER CONSTRAINT NOT NULL fr12, fr13 FR13 FLOTTER CONSTRAINT NOT NULL, fr14 FR14 FLOTTER CONSTRAINT NOT NULL, fr15 FR15 FLOTTER CONSTRAINT NOT NULL, fr16 FR16 FLOTTER CONSTRAINT NOT NULL, fr17 FR17 FLOTTER CONSTRAINT NOT NULL, fr18 FR18 FLOTTER CONSTRAINT NOT NULL, fr19 FR19 FLOTTER CONSTRAINT NOT NULL, fr20 FR20 FLOTTER CONSTRAINT NOT NULL, fr21 FR21 FLOTTER CONSTRAINT NOT NULL Fr22 FR22 FLOTTER CONSTRAINT NOT NULL "(, e23, e23 FLOTTER CONSTRAINT NOT NULL, fr24 FR24 FLOAT CONSTRAINT NOT NULL, fr25 FR25 FLOTTER CONSTRAINT NOT NULL, fr26 FR26 FLOTTENT CONSTRAINT NOT NULL, fr27 FR27 FLOTTER CONSTRAINT NOT NULL, fr28 FR28 FLOTTER CONSTRAINT NOT NULL, fr29 FR29 FLOTTER CONSTRAINT NOT NULL, fr30 FR30 FLOTTER CONSTRAINT NOT NULL, status TEXT (2) st NOT NULL CONSTRAINT).

    The goal was to get the third token, 'leq_octave_5min '.

    The result string is "leq_octave_5min", but the real result string is the input string itself.

    What is the problem with my method?

    I'm sorry.

    I forgot to turn on 'regular expressions' in "Search and replace the String" VI.

    After having turned it on, it works as expected.

  • Search and replace the string formatting

    Hello

    I try to do a search and replace the formatting of a string.

    In the example, I'm looking for the string 'SUCCESSFUL', but it must also begin by usbflash and some number + PASSED.

    I can't get the format to have a number between 1 and 99. The number of replacements should add up to 6 in this case. I tried with \d for any number, and I also tried [1-99].

    Make a right-click on the function search and replace the string.  There is an option to use regular Expressions.  Then give it a try.

    EDIT: You need to set the entry replace all to TRUE.

  • Analyze and display a text string that has HTML tags on blackberry java screen

    Hello world

    I have a string of text that has some HTML in there. I want to display this text string to the screen of blackberry java by analyzing these HTML tags.

    Here is the text of the string.


    Large bright digital display
    Six output Modes
    Automatic test systems

  • Sound signals

  • Discrete outputs
  • Isolated circuit
  •  
  • Digital error detection
  • Thanks in advance!

    Vinay.


    Hello

    Displag a String with HTML tags problem solved!

    Here is the code snippet.

    BrowserField _bf11 = new BrowserField();
    prodDescManager.add (_bf11);

    String Highlight2 ="
    Seat and head radiolucent
    Manual control for instant CPR
    IV pole;

    _bf11.displaycontent (Highlight2, "http://localhost");

    Vinay.

  • Is if possible to group files by name and display for each letter instead of "A - H"?

    Is if possible to group files by name and display for each letter instead of "A - H"?

    Hello

    I don't think that there is a way to group all the numbers/letters individually.

    Grouping like this would appear likely several empty sections, since not all files will have file names that begin with all 26 letters.

    There are several ways that you can view the files by name, for example, list, details, category, etc.

    Concerning

  • Find and replace all occurrences of a string within the current paragraph.

    I did so much work, and it's my last method to implement.

    I want to get the current active doc the current paragraph and replace all occurrences of a string inside this paragraph with another string.

    For example, say I have the following paragraph in a document:

    «This is a sentence that.» This is another sentence. It is also another sentence. The sentence ".

    If the user opens the document containing the paragraph and goes to this paragraph by clicking in any place in there, I want to replace e.g.g "another punishment" with "phrase.

    But only in the current active paragraph in the active document.

    I found a code with F_ApiFind and F_ApiGetTextRange to get the current text selection, but I can't think of a way to do it.

    Post edited by: Efstathios Chatzikyriakidis

    Problem solved people. Thank you.

  • Is it possible to group objects, which are placed in the project and then hide them with line a single action-script? THX in advance, Philip

    I work in CP 9 and I'm going to try the following: the user must be able to make ALL invisible or visible to highlight boxes by clicking on the corresponding button on the first page layout. Thus, for example, if the user does not want the highlight boxes appear, click on "Hide the boxes" and boxes are hidden for the rest of the project. I managed to get to this point for help... but it is still a lot of work for me to manually enter all the different names of these boxes in the action-script. So my question is: is it possible to group objects, which are placed in the project and then hide them with line a single action-script? THX in advance, Philip

    Actually... releasing the CpExtra HTML5 widget, it will be possible.

    It has a function called @syntax that allows you to perform an action (for example HIDE) automatically on any object throughout a project of Cp9 simply based on the name of the object.

    So for example, if you named all the boxes to highlight you want hidden this way to have the suffix _HideMe and you say CpExtra you want all of them hidden if a user variable is assigned to a certain value, then that is what will happen.

    That's the good news.  The bad news is that the widget is still in BETA final tests at the moment, so you may need to wait a bit before you can realize your idea.

  • Group by Clause displays all values search

    Hello friends

    I have a simple table with columns named Date, reason, product and County and the sample data are shown below.

    ==========================
    Date reason product count
    ==========================
    08/06/2012 raison1 home 1
    08/07/2012 raison2 motor 1
    08/08/2012 raison1 home 1
    08/09/2012 Reason3 Home 2
    08/10/2012 raison1 home 1
    08/06/2012 Reason5 home 1
    ===========================

    Altogether, I have 5 values of research through Reason5 raison1 reason, but few of them understand the table above.
    I would like to diplay result per day and I will quote an example of August 6, I want to display the result below, i.e. show all reason 5 search and assign zero count if there are no records for this day there.

    =====================================
    DATE REASON HOME_COUNT MOTOR_COUNT
    =====================================
    08/06/2012 raison1 1-0
    08/06/2012 0 1 raison2
    08/06/2012 Reason3 0 0
    08/06/2012 Reason4 0 0
    08/06/2012 Reason5 1 0
    =====================================


    If we write group by clause, missing for reasons such as Reason3 Reason4 will not appear in the result set.
    And I tried to write several UNION ALL queries to get the above result that works very well, but if it 100 search values, I don't want to write 100 Union queries.
    Please let me know if you have analytical functions to display the results of the end?

    Thank you
    Murali.

    Published by: Nathalie b on August 19, 2012 20:17

    If you followed relational design, you should lookup table. If you do not, you need to create a. In addition, date is reserved word, and the County is a key word, to not use as column names. Then, use the outer join:

    SQL> create table tbl as
      2  select to_date('06/08/2012','dd/mm/yyyy') dt,'Reason1' reason,'Home' product,1 qty from dual union all
      3  select to_date('07/08/2012','dd/mm/yyyy'),'Reason2','Motor',1 from dual union all
      4  select to_date('08/08/2012','dd/mm/yyyy'),'Reason1','Home',1 from dual union all
      5  select to_date('09/08/2012','dd/mm/yyyy'),'Reason3','Home',2 from dual union all
      6  select to_date('10/08/2012','dd/mm/yyyy'),'Reason1','Home',1 from dual union all
      7  select to_date('06/08/2012','dd/mm/yyyy'),'Reason5','Home',1 from dual
      8  /
    
    Table created.
    
    SQL> create table reason_list as
      2  select  'Reason' || level reason from dual connect by level <= 5
      3  /
    
    Table created.
    
    SQL> select  d.dt,
      2          r.reason,
      3          nvl(
      4              sum(
      5                  case product
      6                    when 'Home' then qty
      7                  end
      8                 ),
      9              0
     10             ) home_qty,
     11          nvl(
     12              sum(
     13                  case product
     14                    when 'Motor' then qty
     15                  end
     16                 ),
     17              0
     18             ) motor_qty
     19    from      (
     20               select  min_dt + level - 1 dt
     21                 from  (
     22                        select  min(dt) min_dt,
     23                                max(dt) max_dt
     24                          from  tbl
     25                       )
     26                 connect by level <= max_dt - min_dt + 1
     27              ) d
     28          cross join
     29              reason_list r
     30          left join
     31              tbl t
     32            on (
     33                    t.dt = d.dt
     34                and
     35                    t.reason = r.reason
     36               )
     37    group by d.dt,
     38             r.reason
     39    order by d.dt,
     40             r.reason
     41  /
    
    DT        REASON                                           HOME_QTY  MOTOR_QTY
    --------- ---------------------------------------------- ---------- ----------
    06-AUG-12 Reason1                                                 1          0
    06-AUG-12 Reason2                                                 0          0
    06-AUG-12 Reason3                                                 0          0
    06-AUG-12 Reason4                                                 0          0
    06-AUG-12 Reason5                                                 1          0
    07-AUG-12 Reason1                                                 0          0
    07-AUG-12 Reason2                                                 0          1
    07-AUG-12 Reason3                                                 0          0
    07-AUG-12 Reason4                                                 0          0
    07-AUG-12 Reason5                                                 0          0
    08-AUG-12 Reason1                                                 1          0
    
    DT        REASON                                           HOME_QTY  MOTOR_QTY
    --------- ---------------------------------------------- ---------- ----------
    08-AUG-12 Reason2                                                 0          0
    08-AUG-12 Reason3                                                 0          0
    08-AUG-12 Reason4                                                 0          0
    08-AUG-12 Reason5                                                 0          0
    09-AUG-12 Reason1                                                 0          0
    09-AUG-12 Reason2                                                 0          0
    09-AUG-12 Reason3                                                 2          0
    09-AUG-12 Reason4                                                 0          0
    09-AUG-12 Reason5                                                 0          0
    10-AUG-12 Reason1                                                 1          0
    10-AUG-12 Reason2                                                 0          0
    
    DT        REASON                                           HOME_QTY  MOTOR_QTY
    --------- ---------------------------------------------- ---------- ----------
    10-AUG-12 Reason3                                                 0          0
    10-AUG-12 Reason4                                                 0          0
    10-AUG-12 Reason5                                                 0          0
    
    25 rows selected.
    
    SQL> 
    

    SY.

  • String separated by commas as input and display output

    Hello

    I have a requirement that I have to take a string separated by commas as entry (may be in a table?) and display the output.

    For example, executions should be like this:

    Please enter the string separated by commas:

    A, B, C, D (entries of the user)

    Output must be

    You entered:
    A
    B
    C
    D


    How can do us in PL/SQL?

    Thank you
    Pramod
    /* Formatted on 2012/06/12 09:22 (Formatter Plus v4.8.8) */
    SELECT     REGEXP_SUBSTR ('A,B,C,D', '[^,]+', 1, LEVEL) AS re
          FROM DUAL
    CONNECT BY LEVEL <= NVL (LENGTH (REGEXP_REPLACE ('A,B,C,D', '[^,]', NULL)), 0) + 1;
    
  • Table of contents list PDM: group name is an empty string



  • Thunderbird does not allow me to use a group email, that I used for months, why and how to do it please?

    I created a group e-mail for people I have send an email at least once a month, I've updated Thunderbird when the update came and now when I went to send the email he told me that it must be in the form of name@host, not my name of groups. How can I fix this problem without having to set each individual e-mail address each month

    This was reported by several people.
    Please read the entire conversation at this link:

    Please vote for the bug as described in the link.

  • AppleScript set the string to date and add 30 minutes

    I am filling 2 boxes of time on a website in Safari, using Applescript from buttons selected by the user.

    My current Applescript is:

    Value dialog box to display the dialog box buttons ' when did your first departure case? {"07:30, ' 08:00, ' 08:30" "" "}

    definition of the first button returned of the result

    inputByName ("time 1", 0, start)

    the value of test for '07:30 ' - assuming that the user has selected '07:30 ' in the dialog box

    Test date - do not know how to assign 07:30 as an hour

    Finishing to test set + (30 * minutes)

    inputByName ("2", 0, finishing)

    The error return is number 'Invalid date and time date 07:30 < < script > >.' -30720

    Any help would be greatly appreciated!

    Thank you

    s

    You must use a complete date in the date/time of your machine settings.  A simple way is to simply get the current date (which returns a full date object) and manipulate that, for example:

    tell (current date)
      set its time to (7 * hours) + (30 * minutes)
      set someDate to it
    end tell
    return time string of someDate
    
  • The compilation gets error 7 and return all my strings

    Hi, I'm updating of legacy code. It contains references to the paths that don't exist any more (mainly drives on the network).

    So I go through the program, and I Exchange each defective path (from the old M:\ or P:\ to the my laptop C:\).

    When I run the labview program, it works very well.

    However, when I compile the program restores the old paths and gives error 7 when I run the *.exe.

    The paths are strings in text boxes (controls).

    I tried to check the "include files as library" option in the build specification.

    Any ideas? IM using Labview 2012 and the original program comes from an earlier version.

    Hey,.

    you set the values in the default controls or just change the values?

    So just changed, mark the new default values with a right-click on the control-> data operations-> default font of the current value

    Kind regards

    CMW

Maybe you are looking for

  • Why is my Apple remote desktop not send software upgrades as it should?

    Apple Remote Desktop Help? In apple remote desktop there is command-line unix where I can send the command softwareupdate - install - all, and I do as user root on an administrator account. My problem arises when I send the software update and ARD ne

  • Licenses required to access VNC

    Hi all I'm sorry to have potentially posted this in the wrong forum first! I am trying to wrap my head around the following question: I have a tool that I want to give access ratings to. It is a piece of software to interface with a telephone system

  • Windows 8 on Acer Aspire ES1-131-C1NL

    Hello! I bought mu new Acer Aspire ES1-131-C1NL. There Windows 10 aboard, but I want to install Windows 8, not 8.1. And the question: will be Windows 8 on this machine work propely? Windows 8 support 8.1 for Windows drivers aspire es1-131-c1nl? Becau

  • Make all folders have the same icons

    How can I do for example, all files and folders in my music tab alike - all those images look the same and all documents are similar, but I want all three to have a different look.

  • BlackBerry Smartphones outlook express email to work

    I can't see the images that come to my blackberry to my express email account of prospects for work, any suggestions?