Search for multiple values in a single field

Hello

I have this request to get results when the user doing a search query:

select * from (
select 
"ID",
"ID" ID_DISPLAY,
"SHIFT_DATE",
"SHIFT",
"OFFENSE_ID",
"DESCRIPTION",
"ANALYST",
"STATUS",
"SUBSTATUS"
from "#OWNER#"."IDSIEM_OFFENSES") 
where
OFFENSE_ID IN(:P223_OFFENSES) AND

 (
 instr(upper("DESCRIPTION"),upper(nvl(:P223_DESCRIPTION,"DESCRIPTION"))) > 0 
)
AND
(
 instr(upper("SHIFT"),upper(nvl(:P223_SHIFT,"SHIFT"))) > 0 
)
AND
(
 instr(upper("SUBSTATUS"),upper(nvl(:P223_SUBSTATUS,"SUBSTATUS"))) > 0 
)
AND
(
 instr(upper("ANALYST"),upper(nvl(:P223_ANALYST,"ANALYST"))) > 0 
)
AND
(
 instr(upper("SHIFT_DATE"),upper(nvl(:P223_SHIFTDATE,"SHIFT_DATE"))) > 0 
)
AND
(
 instr(upper("STATUS"),upper(nvl(:P223_STATUS,"STATUS"))) > 0 
)

ORDER BY OFFENSE_ID DESC

The thing I want to do is to set multiple values in the P223_OFFENSES field when I search. For example, an offence is a number, so I want to put in the search box 1111, 3333, 4444, 5555 and the report shows me these 4 offences in the report. The search operation only works when I put only 1 offences, but when I put more than 1, separated by commas, it gives me this error: error report: ORA-01722: invalid number. That is why, because is a number and the character point is not allowed, how can I achieve this? Thank you in advance.

Best regards, Bernardo

I solved a problem like this a few times with a utility function of pipeline for extracting the values from the list:

CREATE or REPLACE TYPE split_tbl AS TABLE OF VARCHAR2 (32767).

/

FUNCTION to CREATE or REPLACE split_list

(

p_list VARCHAR2

p_delimiter VARCHAR2: = ', '.

) Split_tbl RETURN

PIPELINED IS

l_idx PLS_INTEGER;

l_list VARCHAR2 (32767): = p_list;

BEGIN

LOOP

l_idx: = instr (l_list, p_delimiter);

IF l_idx > 0

THEN

LINE of CONDUCT (substr (l_list, 1, l_idx - 1));

l_list: = substr (l_list, l_idx + length (p_delimiter));

ELSIF TRIM (l_list) IS NOT NULL

THEN

PIPE ROW (l_list);

EXIT;

ON THE OTHER

EXIT;

END IF;

END LOOP;

RETURN;

END split_list;

/

In this way, you can define SQL like:

SELECT to_number (column_value) FROM TABLE (split_list (' 1, 3, 99', ','))

Or for this specific case: replace the condition

OFFENSE_ID IN(:P223_OFFENSES)

with

OFFENSE_ID IN (SELECT to_number (column_value) FROM TABLE (split_list (: P223_OFFENSES, ',')))

The advantage over using instr or regex is that you can usually always benefit index on OFFENSE_ID

Better also to restrict entry to only numbers and ', ' or you will always get invalid numbers errors if a user enters "1234, 567, ABC"in the field of P233_OFFENSES.

Kind regards

Thierry

Tags: Database

Similar Questions

  • How to select multiple values in a single field.

    Hi all

    I once select stmt as below

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

    SELECT msi.segment1,
    IN l_chr_omc_item
    OF SGM_INV_ITEM_ATTRIBUTES SIIA, msi mtl_system_items
    WHERE msi.inventory_item_id = siia.inventory_item_id
    AND siia.attribute12 = l_chr_tsb_item;

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

    I need to print some l_chr_omc_item, but if the above query retrieves multiple values of the l_chr_omc_item for a l_chr_tsb_item so I need to print all the values. How to get all these values in a single rank.
    Thanks in advance.

    Published by: Shivaji M on June 28, 2009 23:18

    Published by: Shivaji M on June 28, 2009 23:27

    cursor curGetxx (inpl_chr_tsb_item in SGM_INV_ITEM_ATTRIBUTES.attribute12%type)
    is
    SELECT
    MSI. Segment1
    Of
    SGM_INV_ITEM_ATTRIBUTES SIIA
    msi mtl_system_items
    WHERE msi.inventory_item_id = siia.inventory_item_id
    AND siia.attribute12 = inpl_chr_tsb_item;

    l_chr_omc_item SGM_INV_ITEM_ATTRIBUTES.attribute12%type;
    vStrl_chr_omc_item varchar (500);

    Start
    Open curGetxx (l_chr_tsb_item);
    loop
    extract the curGetxx in l_chr_omc_item;
    When the output curGetxx % NOTFOUND;
    vStrl_chr_omc_item: = concat (l_chr_omc_item, ',')
    dbms_output.put_line (l_chr_omc_item);
    end loop;
    vStrl_chr_omc_item: = substr (vStrl_chr_omc_item, 1, length (vStrl_chr_omc_item)-1);
    end;
    /

  • Use instr to search for multiple values

    Hello

    My version of Oracle DB is 10.2.0

    I have a file of text separated by delimiters. The text file has 14 columns, and in each column, I have to check the presence of the following
    RV, RV, RV, GV, GV, GV.

    The sample file contains the following

    51151111; 28.18.11; 14711119; 512-GV; 821949,39; 1223,21; 471,49; 821197,29; ABC; 1; 27.18.11; 13


    The following code is for the search for GV
     FUNCTION FUNC_FIND_GV   (p_str IN  VARCHAR2) RETURN NUMBER
       AS
             l_gv_pos NUMBER ;
             begin
             l_gv_pos := INSTR(p_str, 'GV') ;
             RETURN l_gv_pos ;
    
       EXCEPTION
          WHEN OTHERS THEN
           l_gv_pos := 0;
        RETURN l_gv_pos 
       END FUNC_FIND_GV ;
    How can I search for other cases?

    Hello

    You can use regular expresssions to find one a |-at the same time delimited list.
    For example:

    SELECT  REGEXP_INSTR ( p_str
                   , '(RV|RV-|RV/|GV|GV-|GV/)'
                   )          AS match_pos
    FROM     ...
    ;
    

    It is unnecessary to search for one of the 'RV', 'RV' - and ' RV /'; hot for just 'RV' will give the same results. However, it does no harm real, so if you build the list ' RV | RV | RV / | GV | GV | GV /' dynamically, so you don't have to check for duplicates.

    I hope that answers your question.
    If this isn't the case, post CREATE TABLE and INSERT statements for some examples of data and the results desired from these data.

  • How to use the find method to search for multiple items in a single paragraph?

    I'm desigining a script to find all instances where ctrl + b and ctrl + i are applied to body text and then replace the format of these characters replaced with chartag italic or bold.  Here's what the script is supposed to do:

    1. put the find method in a while loop that overrides seeks format character.
    2. If a substitution of format character is found, pass the text range returned by the find method and the CharPropsChange flag in the GetTextForRange method.
    3. Use a Boolean comparison between the idata of the text element to the angle of character and character constant weight.
    4. What that is the boolean is set to true, and then use the SetTextProp method to set the properties of the text range for the italic or bold character tag properties.

    This script works on the substitution of format first character found however it ignores other substitutions in the same paragraph. The cause of this is that the while loop updated the line of text control used by the find method for the following paragraph in the stream. I think I need to add an inner loop that runs through all the text in a single paragraph, where teaching iteration the loc text used by the find method is based on the same paragraph, but the offset is changed. I don't know how to do this.

    function removeOverrides (RPSC)

    {

    var vDocStart = pDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;

    var vBoldFmt = getCharFmt (RPSC, "Bold")

    var vItalicFmt = getCharFmt (RPSC, 'Italic')

    initFA_errno ();

    While (FA_errno is constant .FE_Success)

    {

    var vTextLoc = new TextLoc(vDocStart,0);

    var vFindParams = findOverrideParams (CDRP);

    var vTextRange = pDoc.Find (vTextLoc, vFindParams);

    If (vTextRange.beg.obj.ObjectValid ())

    {

    var vTextItems = pDoc.GetTextForRange (vTextRange, Constants.FTI_CharPropsChange)

    If (vTextItems.length ==! 0)

    {

    If (vTextItems [0] .idata == constant .FTF_WEIGHT)

    {

    pDoc.SetTextProps (vTextRange, vBoldFmt.GetProps ())

    }

    If (vTextItems [0] .idata == constant .FTF_ANGLE)

    {

    pDoc.SetTextProps (vTextRange, vItalicFmt.GetProps ())

    }

    } else (Log (vLogFileName, ' \nERROR: none of the items were found in the table in text format but alternative size were found: ' + pDoc.Name))

    }

    vDocStart = vDocStart.NextPgfInFlow;

    }

    }

    function findOverrideParams (RPSC)

    {

    var vFindParams = AllocatePropVals (1);

    vFindParams [0].propIdent.num = Constants.FS_FindObject;

    vFindParams [0].propVal.valType = Constants.FT_Integer;

    vFindParams [0].propVal.ival = Constants.FV_FindCharacterFormatOverride;

    Return vFindParams;

    }

    Another approach (which is what I usually did) is after the first search to set vTextLoc = vTextRange.end

    Whatever it is, you might consider moving your initialization of vTextLoc and vFindParams outside the while loop. The settings do not change, why redefine them for each search?

  • How to url using NOT IN (NIN) IR filter for multiple values?

    Apex 5.0.1 (but should work for Apex 4.2)

    I want to set a url with an IR filter using the filter NOT IN. For example, to get a filter that says: status not in (3,4)

    To do this, we can use the url IRNIN_STATUS parameter.

    This method works. Problem is how can I set multiple values in the url?

    IRNIN_STATUS:3, 4 will give a filter 'status not in (3) '

    4 is interpreted as the following for the next parameter value, even if there is no additional parameters.

    Find / remember the solution:

    We can add the backslashes to values to distinguish them from others.

    IRNIN_STATUS:\3, 4

  • Multiple values in a single Table cell

    Hello

    I have a requirement of the customer. I need to show multiple values within a table cell

    Example of

    Location City Shop
    NorthCity AHS-200, SH-210, SH310
    SouthCity BSH - 100, SH341
    EastCity CSH-20

    But my table shows repeating cell as follows.

    Location City Shop
    NorthCity ASH-200
    NorthCity ASH-210
    NorthCity ASH310
    SouthCity BSH-100
    SouthCity BSH341
    EastCity CSH-20

    So I need your help to show repeated STORE name in a single column of the Table.

    Thank you

    Try this

    EVALUATE_AGGR ('LISTAGG (%1, %2) within THE GROUP (ORDER BY DESC %3)', TableName.ColumnName, ',', TableName.ColumnName)

  • Struggling to search for multiple files

    Hello

    I'm fighting to search / select multiple files.

    This is my workflow:

    I have 2 computers, one is used for all image manipulations using a combination of LR & PS and the other computer is used for the sales presentation using ProSelect.

    Once I'm done with my post production I export images to my computer for presentation for sale to the JPG file format.

    After the sale I want to then be able to star the images that they have purchased on my computer to post production. Currently I did this manually, even if time can not too bad when you're talking about only 20 images. However, this does not work for weddings by looking at images of 150-200.

    That's what I tried. I made an export of the names of files in ProSelect. I then removed the suffix .jpg for example. In Lightroom, I the filter bar, text, select all text, Contains searchabe and then paste it into the list of file names. After a while, he'll come back and say no images found or it may come with only the 1st image in the list. I tried several combinations of formatting of the list of file names and none seem to work spaces, commas, semicolons, each file name in «»

    If anyone can help me in this regard, I would be very grateful.

    Thank you

    Tony

    The list of files must be separated by spaces or commas - you copy and paste from a list in which they are separated by line breaks.  I have tried in my own 5.6 LR (Mac), and when the file names are separated by spaces, it works, but not when separated by line breaks.

  • How to pass multiple values in a single parameter

    Hi all

    I have a setting in my report called dept, this setting takes values in a list. I am using a sql query to populate the list. then the values available for dept are HR, FINANCE, MARKETING.

    In the setting column, I checked the option "MULTIPLE SÉLECTION" AND "CAN SELECT ALL" and I select "all THE VALUES PASSED.

    Now my data model sql looks like

    Select * from emp where Department: dept

    When I try to view the report and select ALL the list of values I don't get any results out of it. In short, I want to run my query for all values of the Department and I want that this query to run when I select ALL from the list.

    Select * from emp where Department ('HR', 'FINANCE', 'MARKETING')

    But I don't get all the data, is it passing null? How to solve this?

    Any help will be really appreciated

    Thank you
    Ronny

    You can change the code to sql data model looks like

    select * from emp where department in (:dept )
    
  • Search for a value in a field in a subform before allowing a user to add a new Instance

    Configuration of the form:

    Name of the page = page 1

    1 subform in Page1 = Info (fixed to slur)

    Objects in the subform Info: name (textfield) and Email (textfield)

    I also have a 2nd subform within Page 1, which contains a button instance add

    What I'm doing:


    1. the user must enter their name and E-mail address, then click 'Add a button to the Instance' to create a new instance of the subform Info : _Info.addInstance (1);

    2. If the user does not enter an e-mail address, I want there to be a message box this info the user address of e-mail is required before, he or she can create a new instance. Note: would be nice if the slider is set to foucs on the email in this particular instance of subform field.

    3. as long as the user tries to add an instance, he or she will be refused if they are not an email in this case

    4. If the user has an e-mail address in this instance, then the script will create adds a new instance

    5. the process should continue in this way for each, each instance button click Add

    I presume that it nees to be a loop and perhaps a scipt for somExpression, but I'm not sure.

    Here's what I have so far (see below)... The script works for the first instance on the page, but this does not prevent instances to be created when the email in the 'current' instance field is empty. I want to prevent the user to add new instances if the email field is balnk in this "current instance. So, I guess I don't know how ot test a field in the current instance in a repeating subform.

    var VNAME = Info.somExpression + ".email";

    var vEmail = xfa.resolveNode (VNAME) .rawValue;

    if (vEmail == null)

    {

    xfa.host.messageBox ("Please enter an email address.");

    }

    else {

    Form._info.addInstance (1);

    var i = Form._Info.count 1;

    xfa.host.setFocus (xfa.resolveNode ("Info [" + i + "].")) Name')); This set is the focus of the cursor in the name field in the newly created subform

    }

    Please advise and thanks in advance!

    Hello

    Try something like;

    var lastRow = Form.resolveNode ("Info [" +(_Info.count-1) + "]"); Get the last row

    If (lastRow.Email.isNull) / / if the email field empty

    {

    xfa.host.messageBox ("Please enter an email address.");

    }

    on the other

    {

    newRow var = _Info.addInstance ();

    xfa.host.setFocus (newRow.Name.somExpression); set the focus to the field name on the line has been added

    }

    Concerning

    Bruce

  • engaging multiple values to a text field for a button

    I have a form that has several buttons that uses the items.push (command/script/EC) that you have to put some text in a text field.  People are asking now that they can put several selections from the button in the field.  Can someone point me in the right direction, or suggest a way to do it?

    I have attached a screenshot.  I clicked the button on the left to view features of the buttons and right I already have something of the key and he was placed in the text field.  I would like to be able to place several things in the field of the key even if possible.Screen shot 2011-01-19 at 12.14.18 PM.png

    You could change the code to:

    If {(response)

    Get a reference to the text field

    var f = getField ("competency");

    Add the selected value field, separated by a carriage return (except if the field is empty)

    f.Value = f.value? f.Value + "\r" + elements [answer]: [answer] points;

    } else {}

    App.Alert ("You have not selected an element.", 1);

    }

  • Can I link multiple field values in a single field?

    Here's the scenario: I have a form with 2 pages.  On the first page, there are three fields for the first, middle and last name of a person.  On the second page, there is a field that only says: 'name '.  I want the user to fill in the fields name, middle and field 'name' on the second page reflects the three fields on the first page.  How can I accomplish this?

    Add the script side client to the event calculate on the name field on page 2 to concatenate the fields name of page 1. For JavaScript, something like this:

    this.rawValue = form1.page1.subform1.firstName.rawValue + "" + form1.page1.subform1.lastName.rawValue;

    Steve

  • Address book crashes when searching for any value to AddressBook OSX 10.11.1

    Hi, opening address book without problems. Research or an opening speech crashes the application on the MacMini.

    Action 1 failed: delete cache of the application in the user library, then restart the application.

    Q: should I remove my icloud and restore the account or it is not a serious question?

    CrashLog below:

    ###############

    Process: Contacts [98477]

    Path: /Applications/Contacts.app/Contents/MacOS/Contacts

    ID: com.apple.AddressBook

    Version: 9.0 (1679)

    Generation information: AddressBook_executables-1679000000000000 ~ 6

    Code type: X 86-64 (Native)

    Parent process:? [1]

    Officials: Contacts [98477]

    User ID: 502

    Date/time: 21:22:52.215 2015-11-27 + 0100

    OS version: Mac OS X 10.11.1 (B 15, 42)

    Report Version: 11

    Anonymous UUID: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Sleep/wake UUID: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Time since started awake: 97000 seconds

    Integrity of system protection: enabled

    Crashed thread: 5 dispatch queue: com.apple.root.default - qos

    Exception type: EXC_CRASH (SIGABRT)

    Exception codes: 0 x 0000000000000000, 0 x 0000000000000000

    Note the exception: EXC_CORPSE_NOTIFY

    Request for clarification:

    Closing the app due to uncaught exception ", reason: '-[ABRecord setValue: forKey ' # #MyFirstNameDisplayedHere # ': 'First'] invalid value ' ending with an exception uncaught called abort() print type

    Specific application Backtrace 1:

    0 CoreFoundation 0x00007fff987dee32 __exceptionPreprocess + 178

    1 libobjc. A.dylib 0x00007fff937484fa objc_exception_throw + 48

    2 CoreFoundation 0x00007fff9884565d + [print raise: format:] + 205

    3 AddressBook 0x00007fffa071c0fd-[ABSuggestedEntriesFetcher personFromContact:] + 128

    Address book 0x00007fffa071bfc4 4 __53-[ABSuggestedEntriesFetcher entriesByUIDForContacts:] + 41 _block_invoke

    5 address book 0x00007fffa06614a8 __44-[NSArray (ABArrayAdditions) _abMapNoFilter:] + 20 _block_invoke

    6 CoreFoundation 0x00007fff9875b41d __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 77 _block_invoke

    7 CoreFoundation 0x00007fff9875b2e9-[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 201

    8 AddressBook 0x00007fffa0646819-[NSArray (ABArrayAdditions) _ab_each:] + 91

    9 AddressBook 0x00007fffa0661484-[NSArray (ABArrayAdditions) _abMapNoFilter:] + 136

    AddressBook 10 0x00007fffa071bf60-[ABSuggestedEntriesFetcher entriesByUIDForContacts:] + 175

    Address book 11 0x00007fffa071bcf3-[ABSuggestedEntriesFetcher fetchEntries] + 43

    Address book 12 0x00007fffa07bb18e-[ABPersonListSearchHelper fetchSuggestedEntriesByUID] + 202

    Address book 13 0x00007fffa07baf40-[ABPersonListSearchHelper performSuggestionSearch:] + 27

    14 ContactsFoundation 0x00007fff9b48286c-[_CNThrottledObservable _sendResultToObserver:withIdentifier:] + 77

    15 ContactsFoundation 0x00007fff9b4840d1 __45-[_CNQueueScheduler afterDelay: performBlock:] + 16 _block_invoke

    16 libdispatch.dylib 0x00007fff8df203c3 _dispatch_client_callout + 8

    17 libdispatch.dylib 0x00007fff8df30674 _dispatch_source_latch_and_call + 2235

    18 libdispatch.dylib 0x00007fff8df24a3b _dispatch_source_invoke + 983

    19 libdispatch.dylib 0x00007fff8df23d0b _dispatch_root_queue_drain + 538

    20 0x00007fff8df23ab8 _dispatch_worker_thread3 + 91 libdispatch.dylib

    21 libsystem_pthread.dylib 0x00007fffa0aa34f2 _pthread_wqthread + 1129

    22 libsystem_pthread.dylib 0x00007fffa0aa1375 start_wqthread + 13

    Binary images:

    0x10584a000 - com.apple.AddressBook (9.0 - 1679) <15886374-2D34-3849-9F68-9B448AC50496>0x1058e3fff /Applications/Contacts.app/Contents/MacOS/Contacts

    0x1085b8000 - 0x1085b9fff com.apple.AddressBook.LocalSourceBundle (9.0 - 1679) <4285734E-D30E-377B-A7EB-D40E0C541F0C>System/Library/Address Book Plug-Ins/LocalSource.sourcebundle/Contents/MacOS/LocalSource

    0x108a8e000 - 0x108a92fff com.apple.DirectoryServicesSource (9.0 - 1679) System/Library/Address Book Plug-Ins/DirectoryServices.sourcebundle/Contents/MacOS/DirectoryServices

    0x108a99000 - 0x108ae7fff com.apple.AddressBook.CardDAVPlugin (10: 9-512) System/Library/Address Book Plug-Ins/CardDAVPlugin.sourcebundle/Contents/MacOS/CardDAVPlugin

    # #MyFirstNameDisplayedHere #.

    If you know that you have a card with this text in the first name field, I suggest that you change or delete. Back up all data before making any changes.

  • How can I search for multiple files at the same time?

    In windows XP, after the advanced search mode, I used to be able to search multiple files simply by adding a comma between them like this...

    90025,90028,90094

    and which returns 3 image files I was looking for.

    How can I do this in Windows 7?

    Use OR instead of the comma...
     
    90025 OR 90028 90094
     
    --
    Dave N.
    MS - MVP (Mail)
    Windows 7 Ultimate 64
    "Tziware" wrote in message
    News: * e-mail address is removed from the privacy... *
     
    In windows XP, after the passage in the advanced search mode, I used to be able to
    Search multiple files, simply by adding a comma between them as
    This...
     
    90025,90028,90094
     
    and which returns 3 image files I was looking for.
     
    How can I do this in Windows 7?
     
     

    Windows 7 Ultimate 64

  • Left join of the two tables and multiple values into a single value separated by commas

    Hello

    I have following tables with their structures and their data as below.

    CREATE TABLE 'BETODI '. "" BETINFO ".

    (

    VARCHAR2 (8 BYTE) "CURRENTPRESS."

    ENABLE 'TYPEIDCONTAINER' VARCHAR2 (30 BYTE) NOT NULL

    )

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A24G', 'PMC');

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A24D', 'Pensky-MARTENS');

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ("A25D", "CMP");

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A25G', 'PMC');

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A26D', 'PMC');

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A26G', 'PMC');

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ("A32G", "V-BFC3");

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A32D', "V-BFC2");

    CREATE TABLE 'BETODI '. "" BETMASTER ".

    (

    ACTIVATE THE "CUREPRESS" TANK (5 BYTES) NOT NULL,

    ACTIVATE THE "TYPE" VARCHAR2 (5 BYTE) NOT NULL,

    NUMBER (5.0) "LASTPCIRIM".

    )

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A24', '45 M 8', 15);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A25', 42 16', 15);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A26", 16' 45, 15);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A27", '45 M 34', 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A28', '45 M 34', 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A29', '45 M 34', 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A30', '45MCH', 15);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A31", "45MCH", 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A32', '45MCH', 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A33', '45MCH', 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A34", "45MCH", 16);

    These two tables have left join as

    BETMASTER. CUREPRESS = substr (BETINFO. CURRENTPRESS, 1, 3)

    now I want to have the data in the two tables with fields Curepress, Lastpcirim, typeidcontainer.

    Also something like

    Make a group of typeidcontainer if this value is greater than 1 by press separated the values of semicolon (;)

    So, for example above, we should be given as

    A24 PMC 15; PENSKY-MARTENS

    A25 15 PMC

    A26 15 PMC

    A27 16 (NULL)

    A28 16 (NULL)

    A30 15 (NULL)

    A31 16 (NULL)

    A32 16 BFC2-V; V BFC3

    A33 16 (NULL)

    A34 16 (NULL)

    How could do?

    My current request is as

    Select distinct Curepress, lastpcirim, typeidcontainer

    BETMASTER STD left join INF BETINFO

    on the trim (STD. CUREPRESS) = substr (trim (INF. CURRENTPRESS), 1, 3)

    but I am unable to get the values separated by commas.

    Any help would be appreciated.

    Thank you

    Mahesh.

    Hi, Mahesh,

    If you want to only 1 row of output for each distinct combination of currentpress and lastpcirim?  This sounds like a job for GROUP BY.

    And you want the row to contain a list of all different typidcontainers-delimited?  This sounds like a job for the aggregate LISTAGG function.

    WITH joined_data AS

    (

    SELECT DISTINCT

    MST.curepress, mst.lastpcirim, inf.typeidcontainer

    OF betmaster STD

    LEFT JOIN betinfo ON TRIM (mst.curepress) inf = SUBSTR (TRIM (inf.currentpress)

    1

    3

    )

    )

    SELECT curepress, lastpcirim

    LISTAGG (typeidcontainer, ',')

    THE Group (ORDER BY typeidcontainer) AS container_list

    OF joined_data

    Curepress GROUP, lastpcirim

    ;

    Unfortunately, you can't say LISTAGG (DISTINCT ...), so you should always get the separate containers how you already are.  (Note that the subquery is just what you posted).

    Thanks for posting the CREATE TABLE and INSERT statements; It is very useful.  Don't forget to tell what version of Oracle you are using.  LISTAGG was new in Oracle 11.2.

    Why not add CHECK constraints (and perhaps triggers) to your tables, so that curepress and currentpress are not stored with the head or trailing spaces?  Then you wouldn't need to use the PAD in queries like this, and your code would be simpler and more effective.

  • Search and replace values in the text field before the values are stored in DB

    Hello
    There is a question - answer and text box text field - in my application. Problem is, some of the answers are stored with the apostrophes to the DB and I have a problem while recovering in the DB. I need to replace the single quotes 1 with 2 apostrophes. The values are stored in the DB when you click on the submit button.

    So, I'm using the following javascript code:
    italics
    < script type = "text/javascript" >
    function test().
    {
    var str = "& P2_S1.";
    document. Write (Escape (STR));
    }
    < /script >
    italics
    I need to call this javascript function, when the user clicks on the button submit, but BEFORE the values are stored in the DB. How can I get this done?

    Please let me know.

    Hi Suzi,

    Just use

    begin
    update test set S1=replace(:P2_S1, '''', '''''') where name=:APP_USER;
    end;
    

    as you did in your SELECT statement.

    But I shake also why you want to do? Where do you have problems with the apostrophe?

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

Maybe you are looking for