Returning a piece of text in a SELECT

Hello!
I'm doing a search in a table that has four fields:
ID
NAME varchar(128)
TEXT1 varchar(500)
TEXT2 varvhar(500)
Well, I need to search for a word in fields TEXT1 and TEXT2. My
first step is to do the following:
SELECT ID,NAME
FROM TABLE
WHERE CONTAINS(TEXT1,'word',1) > 0
AND CONTAINS(TEXT2,'word',2) > 0
Well, til here is all ok, but now... I need something more
difficult:
I need to obtain for each ID, the piece (or the first piece) of
text where 'word' was found on, considering that this word can
be allocated in TEXT1 or in TEXT2.
Thank you very much!!
Carlos Moreno

Carlos...
I'm not familiar with the CONTAINS function, but I'll assume it
returns a number greater than zero when the desired condition is
met.
The way your where clause is written, the result set will
include only those rows from TABLE where 'word' is in BOTH TEXT1
and TEXT2.
I'm guessing about what you want, but here goes...
SELECT id
     , name
     , CONCAT( DECODE( SIGN( CONTAINS(text1,'word',1) )
                     , 1, CONCAT( 'From text1: '
                                  SUBSTR( text1
                                  , 1
                                  , INSTR( text1
                                         , 'word'
                                         ) + 3
             , DECODE( SIGN( CONTAINS(text2,'word',1) )
               , 1, CONCAT( ' From text2: '
                            SUBSTR( text2
                            , 1
                            , INSTR( text1
                                   , 'word'
                                   ) + 3
             ) AS text
  FROM table
WHERE CONTAINS(text1,'word',1) > 0
   AND CONTAINS(text2,'word',2) > 0
     ;The column text should contain the contents of columns text1 and
text2 up to 'word', prepended with the 'From text1;' and 'From
test2:'
If the AND in the where clause is replaced with and OR, then the
parts of text1 and text2 will only be returned if the
contain 'word'.
I did not test this code.
Good Luck...
-

Similar Messages

  • Texting on iPhone 5.  When texting to multiple people why does the contact list return to the "A"s after you select a contact and try to add the next one in order?

    Texting on iPhone 5.  When texting to multiple people why does the contact list return to the "A"s after you select a contact and try to add the next one in order?  This really slows you down when trying to contact 50 people with information.  iPhone 4 worked just fine.  Any suggestions on how to fix this?

    None of my pictures that I uploaded into iPhoto are in my Finder under Pictures.  Should I copy and paste my folders from iPhoto into here, in case something happens to my iPhoto program (in addition to backing them up onto an external hard drive like I already do)?
    No, that's just wasting space.  A back up needs to be on a different disk.
    Your photos are within the iPhoto Library.

  • Getting the Physical Length of a Piece of Text (in mm etc.) in Javascript

    I'm trying to write a script in Indesign CS5 (Windows) that can measure the physical, 'rendered' length of two pieces of text of similar length (in mm etc.), calculate the average length of the two, and adjust the tracking/horizontal scale of one or both of the pieces of text so that the physical length of both texts are the same.
    I need a script because this task must be done thousands of time in a long document.
    I'm struggling to find a way to access the 'rendered' length of a piece of text in Javascript.
    I know among the attributes of a text box is whether the text has overrun. So I could copy the text to a special text-box, and use a for loop to reduce the dimentions of the text box, 1mm at a time, until the text box overruns, thus determining the length..
    I could also get the length of a rendered string using python with it's built in GUI toolkit Tkinter:
    http://stackoverflow.com/questions/2922295/calculating-the-pixel-size-of-a-string-with-pyt hon
    And then have an indesign script that takes some data from the python script and sets the tracking/horizontal in Indesign with some fudge factors.
    Both ideas seem like real kludges.
    Any other suggestions?
    Many thanks
    David

    You can simply iterate through each line in text to get the widest line. Something like this:
    Main();
    function Main() {
        var text = app.selection[0],
        minLength, maxLength, start, end;
        for (var i = 0; i < text.lines.length; i++) {
            start = text.lines[i].characters[0].horizontalOffset,
            end = text.lines[i].characters[text.lines[i].characters.length-1].horizontalOffset;
            if (minLength == undefined || start < minLength) {
                minLength = start;
            if (maxLength == undefined || end > maxLength) {
                maxLength = end;
        var length = maxLength - minLength;
        $.writeln(length);
    But this approach seems to be a little less precise than creating outlines since (I guess) it measures up to the beginning of the last character; discretionary hyphens, line brakes, etc. are not included into the measurement.

  • Adding a rectangle behind every piece of text in CS5

    Hi,
    I am making a series of map tiles (30) and would like to have a white rectangle behind every peice of black text in a certain layer. I know how to add a rectangle and position it behind the text, but want to avoid this repetive process.
    I understand that each piece of text has a 'bounding box' - is there a way to add a fill to this box for all text at once?
    Thanks,
    Mike.

    Mike,
    You may:
    1) Select all the instances of Type,
    2) In the Appearance palette flyout tick Add New Fill, drag it down below Characters, and change its colour to white,
    3) With the white Fill selected, Effect>Convert to Shape with the desired oversize.
    Edit: Once again, hi Kurt.

  • Join multiple pieces of text

    Does anyone know of a script that will take little pieces of text in CS4 & CS5, and join them into one piece so that the text is easier to edit? I've tried joining the text by selecting it, cutting it , and putting it into a text area, but the type often gets scrambled doing it this way.

    There are a couple of scripts already about that do this… Is your broken up text from PDF where the kerning shatters it? This link has 2 examples:
    http://ajarproductions.com/blog/adobe-extensions/

  • How to write text  on the selection screen of a  report

    Hi all,
    I need to write some user defined text on the selection screen of an ALV GRID Report.
    Please suggest me how can i do this
    Thanks
    Ajay.

    SELECTION-SCREEN BEGIN OF LINE .
    SELECTION-SCREEN COMMENT 12(31) text-024.<-----Goto text elements and add text.
    PARAMETERS:P_FILEN LIKE RLGRAP-FILENAME .
    SELECTION-SCREEN END OF LINE

  • Selecting an LOV item to return values in antother item based on selection

    I am having some difficulty hard coding a page item P3_INVOICE_STATUS value to return/ display values depending on a multiple select list on another item P3_EXCEPTION_REASON'. Example when i select from a drop down list on P3_EXCEPTION_REASON' = is a drop down LOVs, I’d like to select from = YES/ NO/ NA, and would like that to return/ display COMPLETE/ PENDING / REVIEW respectively, depending on what is selected.
    Can anyone please help
    I am still a novist in APEX .

    hi,
    to create application level process:
    1. go to shared component
    2. in logic section there is "application processes", in which you can create process
    3. For item you can click "application item".
    regards,
    Kartik

  • Editing a PDF file with Acrobat XI pro... some "text" is not selectable and vanishes upon saving

    Hi folks.
    I've googled around for a few hours, but I'm completely stumped with this one.
    I'm trying to edit a .pdf file that was generated from Word 2007.  Mostly it edits fine, but for reason some of what appears to be text isn't selectable with the text and image editor... in fact it doesn't even have a bounding box around it.  When I move around the document or save it in acrobat pro, the "text" then vanishes.
    I include a dropbox link to a partial screenshot image which shows what I'm talking about.  You can see that the italic bold A doesn't have a box around it in some cases.
    https://www.dropbox.com/s/42i8xms78lvw12b/Screenshot%202014-02-07%2011.19.07.png
    Can anybody kindly shed some light on what I'm doing wrong? 
    Thanks! 
    -- gyre --

    Hi Bill.  Thanks for replying. 
    Unfortunately, I don't have the option of using the original DOCX file.  The author lost it, leaving only the pdf around
    I'm using AA XI 11.0.06.  Upgraded this morning.  That's running on Windows 7 Ultimate 64.
    I get the boundary boxes by clicking on the 'edit text and images' tool, and they appear.  Or don't in this case
    I only need to change a few characters in the file.   However, even just opening up the file in AA and then saving, the "A = " "text" gets deleted.
    Could it perhaps be something to do with embedded or missing maths fonts on my machine?  I mean, I don't get any warnings, just can't do anything with the A and AB italic bold text.
    Thanks!
    -- gyre --

  • Change of variable text in BEx selection screen

    Hi all,
    in our BW system the key users are allowed to create queries and also create variables. In some cases, especially for often used info objects like 0DATE the number of variables is increasing very quickly. The reason for this is, that 0DATE is used for a big variety of meanings e.g. delivery date, order date, invoice date etc.
    So the users always create new variables only to have a meaningful description in the BEx selection screen, because they do not want only "date" to be displayed here. As result we have many different varianbles with exactly the same technical settings with only different names.
    So my question is: Is it possible to change the diplayed text in the selection screen for each query without having to create a new variable?
    Thanek you and best regards

    Hi Stephan,
    Changing the diplayed text in the selection screen for each query is not possible.You have to create a new variable for each query.
    Rgds,
    Murali

  • Oracle 11g:Query to return only 1 to 1 relationship & random selection

    Hi
    I have a complex query to modify but I have below the sample tables and data with only very few fields(only affected fields).
    Query based on 2 tables b_test and s_test.
    Pls see below.
    create table b_test(building_id number not null,invalid varchar2(1));
    create table s_test(sub_building_id number not null,building_id number ,invalid varchar2(1),sequence_no number);
    insert into b_test values (1000,'N');
    insert into b_test values(2000,'N');
    insert into b_test values(3000,'N');
    commit;
    insert into s_test values(1,1000,'N',90);
    insert into s_test values(2,1000,'N',91);
    insert into s_test values(3,1000,'N',92);
    insert into s_test values(4,1000,'Y',93);
    insert into s_test values(5,NULL,'N',NULL);
    insert into s_test values(1,2000,'N',94);
    insert into s_test values(2,2000,'N',95);
    insert into s_test values(3,2000,'N',96);
    insert into s_test values(4,2000,'N',97);
    insert into s_test values(5,2000,'N',98);
    insert into s_test values(6,NULL,'N',NULL);
    insert into s_test values(10,3000,'N',99);
    insert into s_test values(11,3000,'N',100);
    commit;The query below returns all rows required:(also see results:)
    select b.building_id,b.invalid,s.sub_building_id,s.sequence_no from b_test b,
    (select * from s_test where invalid='N') s
    where b.building_id = s.building_id(+)
    and b.invalid='N'
    Results:
    BUILDING_ID INVALID      SUB_BUILDING_ID     SEQUENCE_NO
    1000              N     1                     90
    1000             N     2                     91
    1000             N     3                     92
    2000             N     1                     94
    2000             N     2                     95
    2000             N     3                     96
    2000             N     4                     97
    2000             N     5                     98
    3000             N     10                      99
    3000             N     11                     100Now there are 2 requirements:
    1)How can the above query be changed so that 1:1 relationship if sub_building_id is returned?i.e For 1 building_id, only show 1 sub_building(This could be a random selection)
    (Pls help with query)
    The results would be like
    BUILDING_ID INVALID     SUB_BUILDING_ID     SEQUENCE_NO
    1000               N     1                      90
    2000               N     1                      94
    3000               N     11                     1002)How can the same SEQUENCE_NO be shown for all sub_buildings for the same building? (Pls help with query)
    The results will be:
    BUILDING_ID INVALID     SUB_BUILDING_ID     SEQUENCE_NO
    1000             N     1                       90
    1000             N     2                       90
    1000             N     3                       90
    2000             N     1                       94
    2000              N     2                       94
    2000             N     3                       94
    2000             N     4                       94
    2000             N     5                       94
    3000             N     10                       99
    3000             N     11                       99Many thanks!
    Edited by: Krithi on 08-Nov-2012 08:48
    Edited by: Krithi on 08-Nov-2012 08:55

    Krithi wrote:
    Hi
    I have a complex query to modify but I have below the sample tables and data with only very few fields(only affected fields).
    Query based on 2 tables b_test and s_test.
    Pls see below.
    create table b_test(building_id number not null,invalid varchar2(1));
    Thanks for posting the CREATE TABLE and INSERT statements, and your existing query; that's very helpful.
    The query below returns all rows required:(also see results:)
    select b.building_id,b.invalid,s.sub_building_id,s.sequence_no from b_test b,
    (select * from s_test where invalid='N') s
    where b.building_id = s.building_id(+)
    and b.invalid='N'
    Results:
    BUILDING_ID INVALID      SUB_BUILDING_ID     SEQUENCE_NO
    1000              N     1                     90
    1000             N     2                     91
    1000             N     3                     92
    2000             N     1                     94
    2000             N     2                     95
    2000             N     3                     96
    2000             N     4                     97
    2000             N     5                     98
    3000             N     10                      99
    3000             N     11                     100
    When I run your query, I get NULL for sequence_no on the last 2 rows, where building_id=3000. The numbers 99 and 100 don't seem to occur in either table. Did you post the worng sample data and/or results?
    >
    Now there are 2 requirements:
    1)How can the above query be changed so that 1:1 relationship if sub_building_id is returned?i.e For 1 building_id, only show 1 sub_building(This could be a random selection)
    (Pls help with query) Here's one way:
    WITH       got_r_num  AS
         SELECT  sub_building_id
         ,     building_id
         ,     sequence_no
         ,     ROW_NUMBER () OVER ( PARTITION BY  building_id
                                   ORDER BY          sequence_no
                           )         AS r_num
         FROM    s_test
         WHERE     invalid     = 'N'
    SELECT    b.building_id
    ,       b.invalid
    ,       r.sub_building_id
    ,       r.sequence_no
    FROM             b_test     b
    LEFT OUTER JOIN      got_r_num  r  ON  r.building_id  = b.building_id
    WHERE     NVL ( r.r_num
               , 1
               )          = 1
    ORDER BY  b.building_id
    ;This is called a Top-N Query , because we're picking N items (N = 1 in this case) from the top of an ordered list. What makes one item the "top", and another one "lower"? That's determined by the analytic ORDER BY clause, in this case
    ORDER BY      sequence_noThat means the row with the lowest sequence_no (for each building_id) will get r_num=1. If you want a random row from that building_id to be chosen as #1, then you can change the analytic ORDER BY clause to
    ORDER BY      dbms_random.valueYou can ORDER BY anything you like, even a constant, but you must have an analytic ORDER BY clause. ROW_NUMBER requires an analytic ORDER BY clause.
    The results would be like
    BUILDING_ID INVALID     SUB_BUILDING_ID     SEQUENCE_NO
    1000               N     1                      90
    2000               N     1                      94
    3000               N     11                     100
    Again, I don't see where the 100 comes from. The results I get are:
    BUILDING_ID I SUB_BUILDING_ID SEQUENCE_NO
           1000 N               1          90
           2000 N               1          94
           3000 N              11
    2)How can the same SEQUENCE_NO be shown for all sub_buildings for the same building? (Pls help with query)
    SELECT    b.building_id
    ,       b.invalid
    ,       s.sub_building_id
    ,       MIN (s.sequence_no) OVER ( PARTITION BY  s.building_id)
                            AS seq_no
    FROM             b_test  b
    LEFT OUTER JOIN      s_test  s  ON  s.building_id  = b.building_id
                                AND s.invalid      = 'N'
    The results will be:
    BUILDING_ID INVALID     SUB_BUILDING_ID     SEQUENCE_NO
    1000             N     1                       90
    1000             N     2                       90
    1000             N     3                       90
    2000             N     1                       94
    2000              N     2                       94
    2000             N     3                       94
    2000             N     4                       94
    2000             N     5                       94
    3000             N     10                       99
    3000             N     11                       99
    Again, I don't see where you get sequence_no = 99. The results I get are:
    BUILDING_ID I SUB_BUILDING_ID     SEQ_NO
           1000 N               1         90
           1000 N               2         90
           1000 N               3         90
           2000 N               1         94
           2000 N               2         94
           2000 N               5         94
           2000 N               3         94
           2000 N               4         94
           3000 N              10
           3000 N              11Edited by: Frank Kulash on Nov 8, 2012 12:12 PM
    Added explanation and results
    Edited by: Frank Kulash on Nov 8, 2012 12:28 PM
    It looks like you cahnged your sample data from
    insert into s_test values(10,3000,'N',NULL);
    insert into s_test values(11,3000,'N',NULL);to
    insert into s_test values(10,3000,'N',99);
    insert into s_test values(11,3000,'N',100);The queries I posted are niow getting 99, like you requested.

  • Regarding text box in selection screen

    Hi all,
    Can i know how we can implement a text with scroll bars so that user can enter a data of about 2000 characters with paragraph indent. also this needs to be done on the selection screen of PNP logical database.
    Please let me know if this can be done.
    Thanks.
    Harshad.

    Hi Harshad,
    [text box in the selection screen|Text box on selection screen]
    Thanks!

  • How to Add/Concatenate to a text field, values selected in a combo box

    I have a combo box form field that allows the user to select a value from a list and click on an Add button. The Add button should add/concatenate the vaue selected to a text field in order to create a list of values selected. I'm not sure how to do this using Javascript in Acrobat? I know I need to add the javascript to the Add button's Mouse Up action. Any help would be greatly appreciated. Thanks!

    Thanks so much - it works!
    >>> "Gilad D (try67)" <[email protected]> 9/25/2013 9:16 AM >>>
    Re: How to Add/Concatenate to a text field, values selected in a combo box created by Gilad D (try67) ( http://forums.adobe.com/people/try67 ) in JavaScript - View the full discussion ( http://forums.adobe.com/message/5712118#5712118 )
    Let's say the text field's name is "Text1", and the combo is called "Combo1". You can then use this code as the MouseUp script of the Add button:
    var f1 = this.getField("Text1");
    var f2 = this.getField("Combo1");
    if (f1.value=="") f1.value = f2.value;
    else f1.value = f1.value + ", " + f2.value;
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5712118#5712118
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5712118#5712118
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5712118#5712118. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in JavaScript by email ( mailto:[email protected].com ) or at Adobe Community ( http://forums.adobe.com/choose-container!input.jspa?contentType=1&containerType=14&contain er=3286 )
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How to display the dynamic text in the selection screen

    Hi All,
    I want to display the dynamic text in the selection screen .... ( I searched in forums , didnt get the any answer fot this sort of qustion ).....
    EX: If i have the date of today 31st  it has to show message like " today date is 31 like some thing "  when i execute the report .
    Could any one face this sort of requirment, Please let me know.
    Thanks in advance.
    Reagrds,
    Bharani

    Where would you like this dynamic text being displayed? As an "message" or in some parameter field?
    If first
    parameters date type d.
    data: text type string.
    at selection-screen.
       concatenate 'Today is' date into text.
       message text type 'I'.
    If second
    parameters pa_text type c length 50.
    at selection-screen on date.
      if date is not initial.
        concatenate 'Today is' date into  pa_text.
      enidf.
    at selection-screen output.
       "show it as read only
       loop at screen.
        if screen-name = 'PA_TEXT'.
               screen-input = abap_false.
              modify screen.
        endif.
       endloop.
    Regards
    Marcin

  • How to get the text boxes and select lists dynamically?

    Hi,
    I have a requirement such that I need to create the text boxes and select lists depending on the user input at the run time. It means that if the user requires four text boxes/select lists then I need to have 4 such thing. If the user need 6 then I need to have 6.
    The design may be such that initially only one text box/select list will be available when the page launches. Then as ad when the user asks for more those will be available to the user accordingly.
    regards,
    Dipankar.

    You can use Ajax to call textboxes and select list based on what user enters.
    Otherwise make those items conditional and based on what user enters you can display textbox or select list.
    You can call Single Textbox and Select List using Ajax for any number of conditions.
    Regards
    Chandra

  • Diplay Text in Text Box in selection Screen

    Hi Experts i want to display text in text box in selection screen like
    Personnal Number
    Display in text box and disable................please help me
    Edited by: BFawad26 on Jun 21, 2010 9:46 AM

    Hi,
    You mean to say parameter in selection screen
    Just press F1 on parameter you will get all the option available for the parameter
    for defaulting text just give your text in DEFAULT option for the parametr
    And for disabling this checkbox you can explore the LOOP AT SCREEN concept
    In at selection screen output event you can modify the selection screen.just give one modif id for your
    paramete and use this at selection screen output event , loop at screen and modify screen with the screen input = 0
    for ur parameter.
    Thanx
    Edited by: PawanG on Jun 21, 2010 9:51 AM

Maybe you are looking for

  • Photoshop Elements tags to Sharepoint?

    I just started working as a work study at our local college and I've just been given the task of organizing and tagging 10,000+ photos on our college SharePoint server. The person who was working on this project before I joined was using Photoshop El

  • Automatically create user private library

    Hi,, I would like to know if it is possible to automatically create the Private Library in '/<domain>/Users/User-<letter>/' when provisioning a user or if the only possibility is to check the box 'Private Library' at the first user connection to Cont

  • How can I Construct this Linked Teardrop Pattern?

    I'm trying to replicate the way these circles are connected for use in a new design. I've gotten so close, but aligning everything exactly is incredibly frustrating. At first I tried constructing this with the use of a white outline around the circle

  • How to open/read file using Java in Unix?

    Hi Friends, Can you please help me out how to open/read file using java in unix os? I have create one text file in "/home/test.txt" in unix environment. How to open the same file & read using java code? - Hiren Modi

  • [SOLVED] cant install acpi_call-git

    cant install acpi_call-git from aur here is the output Comment by CIB (2013-08-02 13:22) Getting errors when trying to build this, it seems to rely on something already being in /usr/lib/modules/3.10.3-1-ARCH/build Does this rely on some kernel sourc