Need help to highlight the query text in the document

Hi, I'm trying to load files into the blob column and try to create the text index.

I need to query the blob column in the original glass by a string, which should return the relevant documents with the query string, highlighted with some color.

Can you please help me with an example of the above.

Thanks in advance.
SCOTT@orcl_11gR2> -- table:
SCOTT@orcl_11gR2> CREATE TABLE document_tab
  2    (document_col  BLOB)
  3  /

Table created.

SCOTT@orcl_11gR2> -- procedure to load documents:
SCOTT@orcl_11gR2> CREATE OR REPLACE PROCEDURE load_document
  2    (p_dir  IN VARCHAR2,
  3       p_file IN VARCHAR2)
  4  AS
  5    v_blob       BLOB;
  6    v_bfile       BFILE;
  7  BEGIN
  8    INSERT INTO document_tab (document_col)
  9    VALUES (EMPTY_BLOB())
 10    RETURNING document_col INTO v_blob;
 11    v_bfile := BFILENAME (UPPER (p_dir), p_file);
 12    DBMS_LOB.FILEOPEN (v_bfile, DBMS_LOB.LOB_READONLY);
 13    DBMS_LOB.LOADFROMFILE (v_blob, v_bfile, DBMS_LOB.GETLENGTH (v_bfile));
 14    DBMS_LOB.FILECLOSE (v_bfile);
 15  END load_document;
 16  /

Procedure created.

SCOTT@orcl_11gR2> SHOW ERRORS
No errors.
SCOTT@orcl_11gR2> -- load documents (directory and files must be on server, not client):
SCOTT@orcl_11gR2> CREATE OR REPLACE DIRECTORY my_dir AS 'c:\my_oracle_files'
  2  /

Directory created.

SCOTT@orcl_11gR2> BEGIN
  2    load_document ('my_dir', 'banana.pdf');
  3    load_document ('my_dir', 'english.doc');
  4    load_document ('my_dir', 'sample.txt');
  5  END;
  6  /

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> -- confirm files were loaded:
SCOTT@orcl_11gR2> SELECT DBMS_LOB.GETLENGTH (document_col)
  2  FROM   document_tab
  3  /

DBMS_LOB.GETLENGTH(DOCUMENT_COL)
--------------------------------
                          222824
                           22016
                              60

3 rows selected.

SCOTT@orcl_11gR2> -- text index:
SCOTT@orcl_11gR2> CREATE INDEX document_idx
  2  ON document_tab (document_col)
  3  INDEXTYPE IS CTXSYS.CONTEXT
  4  /

Index created.

SCOTT@orcl_11gR2> -- confirm files were indexed:
SCOTT@orcl_11gR2> SELECT COUNT(*) FROM dr$document_idx$i
  2  /

  COUNT(*)
----------
       319

1 row selected.

SCOTT@orcl_11gR2> -- function to return highlighted document:
SCOTT@orcl_11gR2> CREATE OR REPLACE FUNCTION your_markup
  2    (p_index_name IN VARCHAR2,
  3       p_textkey    IN VARCHAR2,
  4       p_text_query IN VARCHAR2,
  5       p_plaintext  IN BOOLEAN  DEFAULT TRUE,
  6       p_tagset     IN VARCHAR2 DEFAULT 'HTML_DEFAULT',
  7       p_starttag   IN VARCHAR2 DEFAULT '*',
  8       p_endtag     IN VARCHAR2 DEFAULT '*',
  9       p_key_type   IN VARCHAR2 DEFAULT 'ROWID')
 10    RETURN          CLOB
 11  AS
 12    v_clob          CLOB;
 13  BEGIN
 14    CTX_DOC.SET_KEY_TYPE (p_key_type);
 15    CTX_DOC.MARKUP
 16        (index_name => p_index_name,
 17         textkey    => p_textkey,
 18         text_query => p_text_query,
 19         restab     => v_clob,
 20         plaintext  => p_plaintext,
 21         tagset     => p_tagset,
 22         starttag   => p_starttag,
 23         endtag     => p_endtag);
 24    RETURN v_clob;
 25  END your_markup;
 26  /

Function created.

SCOTT@orcl_11gR2> SHOW ERRORS
No errors.
SCOTT@orcl_11gR2> -- query that returns highlighted document:
SCOTT@orcl_11gR2> VARIABLE string VARCHAR2(100)
SCOTT@orcl_11gR2> EXEC :string := 'test AND demonstration'

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> SELECT your_markup ('document_idx', ROWID, :string)
  2           AS highlighted_text
  3  FROM   document_tab
  4  WHERE  CONTAINS (document_col, :string) > 0
  5  /

HIGHLIGHTED_TEXT
--------------------------------------------------------------------------------
It is a document test of demonstration to highlight.

1 selected line.

Scott@orcl_11gR2 >

Tags: Database

Similar Questions

  • Need help with a SQL query

    Hello

    I have a data in table (raj_table) with columns (char11) raj_id, raj_number (varchar2 (15)), raj_format (NUMBER), Primary_ID (identity with the values of the primary key column)

    Primary_ID raj_id Raj_number Raj_format

    1                            raj                 rajvend                      1

    2                            raj                 rajvend                      1

    3                            raj                 rajvendor1                 2

    4                            raj                 rajvendor1                 2

    5                            raj                 rajvendor1                 2

    6                            raj                 rajvendor2                 3

    I used under SQL to get query output as below, but has not achieved the required result:

    Select client_id vendor_number, vendor_format, primary_id, row_number() on sl_no (client_id partition, primary_id, vendor_format order of client_id primary_id, vendor_format, vendor_number, vendor_number)

    from raj_table by sl_no asc

    SL_NO raj_id raj_number raj_format primary_id

    1                   1                   raj              rajvendor                 1

    1                   2                  raj              rajvendor                 1

    2                   3                   raj              rajvendor1                2

    2                   4                   raj              rajvendor1                2

    2                   5                  raj               rajvendor1                2

    3                   6                    raj              rajvendor2                3

    I need help with a SQL query to get the result as above without using the group by clause. I want to bring together the combination of separate line of the three columns (raj_id, raj_number, raj_format) and add a unique serial number for each online game (SL_NO column below). So, above there are 3 unique set of (raj_id, raj_number, raj_format) I can get in a group by clause, but I can not add prmiary_id, SL_NO values if I group by clause. I used the analytical functions like row_number() but no luck. Need solution for this.

    with t as)

    Select 'raj' raj_id, 'rajvend' raj_number, 1 raj_format, 1 primary_id Union double all the

    Select option 2, 'raj', 'rajvend', 1 double Union all

    Select 3, 'raj', 'rajvendor1', 2 double Union all

    Select 4, 'raj', 'rajvendor1', 2 double Union all

    Select 5, 'raj', 'rajvendor1', 2 double Union all

    Select 6, 'raj', 'rajvendor2', 3 double

    )

    Select dense_rank() over (order of raj_id, raj_number, raj_format) sl_no,

    t.*

    t

    order by primary_id

    /

    PRIMARY_ID RAJ RAJ_NUMBER RAJ_FORMAT SL_NO
    ---------- ---------- --- ---------- ----------
    1 1 raj rajvend 1
    1 2 raj rajvend 1
    2 3 raj rajvendor1 2
    2 4 raj rajvendor1 2
    2 5 raj rajvendor1 2
    3 6 raj rajvendor2 3

    6 selected lines.

    SQL >

    SY.

  • Need help to find the "main point size.

    Hello

    I need help to find the "main point size.

    Any style of Pará which is more than 2 points of my font size, I need the alert message "His more than 2 points for your font size". For example, the font size of my para 10 here is my attack should be 12 points rather than his 14 points, I need the alert message.

    Is it possible by script?

    by

    hasvi

    Hi Hasvi,

    Try this.

    var doc = app.activeDocument;

    var texts = doc.stories.everyItem ().textStyleRanges.everyItem () .getElements ();

    pstyle var = ' Suite of paragraph styles have more leadings: \r\r ";

    for (var i = 0; i)<>

    {

    PS var = text [i] .pointSize;

    If (texts [i] .leading > ps + 2).

    {

    pStyle += text [i].appliedParagraphStyle.name;

    }

    }

    Alert (pStyle)

    While it is true that mark as answer correct and do not select your question as a correct answer.

    Kind regards

    Cognet

  • Need help to diagnose the regular system analysis on iMac - processors maxed out

    I need help to identify the cause of a problem that occurs at least 2 - 3 times per day using my iMac (27-inch, mid 2010) running 10.11.5.

    I will use my iMac and then all at once things will start to really trolling. To the point of being completely unusable. Even if I'm able to move my cursor, then click to drag the windows around the screen nothing does really.

    I have iStat menus running so that can see graphics in my menu bar that all 4 cores are completely overfished. Occasionally, I was fast enough to launch the activity monitor to try to see what applications / services are responsible for, the use of % CPU column is completely empty of values, so I can't identify the culprits in a reliable way. I try to keep that column sorted by % CPU use in the hope that he could reveal something and normally it's the kernel_task who is up there.

    I use a Wacom Bamboo dated Tablet (MTE - 450 has) instead of a mouse, and at one point, I was convinced the pilot of PenTabletDrive it is based on was to blame. I contacted Wacom on this subject, and although there is no known issues they pointed out that although the latest drivers will allow me to use the tablet that they no longer support older devices. I was wondering if there was a problem of communication between the device and a driver that is no longer supported. I installed the latest driver supported for my tablet, but the problems persist.

    It may be interesting to note that, when my computer is in this semi-frozen state, I am able to launch the window enough force and quit all open applications leaving me with only the Finder. I guess that means that there are none of my apps running and it is probably one of the services. If I restart the Finder system grinds to a completely enclosed holt.

    I hope someone can let me know what I can find in the Console or elsewhere to help me finally zero in on what is to blame. I can share a log if that helps.

    Thank you in advance!

    Information that might be useful:

    Kept by I tend to be running: Adobe InDesign, Photoshop, Acrobat (all CC 2015), Mail, Safari with several tabs & Dropbox sync constantly.

    Download and run EtreCheck, created by one of his own assistants here in CSA. It is a diagnostic tool that is very useful for us to find problems. It will also give us additional specifications on your Mac. After his execution after the logfile here. It will never contain any personal information.

  • Need help to remove the zeros on the right

    Hello.

    I need help to replace the zeros in the string.

    I have a string which is the output of the network packet. There are a few trailing zeros in the package.

    I don't see them in normal mode, but the size of the string tells me that it's bigger then it looks like.

    When I pass in hexadecimal mode, you can see zeros.

    I tried to use the find/replace function allows you to search for 0 and replace it with an empty string constant. But, for some reason any, that he took no zeros.

    I need to stop the string that follows * 69.

    Show your code.  You won't find and replace with all zeroes.  These 00 in hex mode they are null characters.  (not printable byte with a value of zero).  You need search and replace on that character.  (replace string should look like 00, when it is set to display the hexadecimal code.

  • cq57: need help cq57 enter the password administrator or power on password... deisabled system 58555314

    need help cq57 enter the password administrator or power on password... deisabled system 58555314

    Thank you!!!

    @clatimer

    Enter 47433930

    REO

  • Need help in using the ActiveX to retrieve a VARIANT

    Need help in using the ActiveX to retrieve a VARIANT.

    Variant is shown as var {VT_Ul1, 1} in debugging

    By using the following

    HR = CA_VariantGetShort (& var, &value);)

    I get 0 for my answer instead of 1.

    Answered my own question.

    VT_Ul1 is an unsigned char and not a short.

  • I need help to Flash the bios. I have an Aspire 5810TZ. I start and it just says: "acer".

    I need help to Flash the bios. I have an Aspire 5810TZ. I start and he just says "acer" and goes no further. I went to the download page for BIOS on us.acer.com and it has a zip file with 5 files:
    JM4151135.exe
    IN FLORIDA...
    GPC_V135.bin
    Readme.txt
    FLASH. BAT
    What should I do? I tried to copy the files on a USB key and turn on/off with Fn + ESC key. After the release the power button and pressed Fn - Esc another screen appears after 30 seconds. I gave up and gave her 30 minutes but it does nothing. I read another person that should be flashing power button online. I have to rename one of the files. Help, please!

    Aspire 5810TZ menu of frozen startup.

    I finally understand it.

    I couldn't start a back b/c drive, it me did not start anything.

    I followed this chain of logic:

    -Downloaded the bios (2.35 is the one that worked for me)
    -Find the exe file in the winflash file.
    -Extract the files in archive exe using the 7-Zip program
    -Find the .fd file and rename it to JM41X64. FD (I read in a forum was unique in my laptop)
    -Copied JM41X64. FD and FLASH it is. EXE on a USB
    -A the battery and the hard drive out.
    -With its trendy diet I supported Fn + Esc and that you press the power button once while ensuring that the Fn + Esc has been always held down.
    -J' waited 6 seconds and release the Fn + Esc and seen the flashing flash player
    -After about 10 minutes, restarted the machine and the bios as like new.

    Later, I found that there was a hard drive problem.

    I want you guys should help more. All I needed was the name of the JM41X64 file. FD and you don't know how many hours I put into trying to find how simpy bios flash. It is not that difficult for someone with a b.s. in computer science to learn how. Couldn't we a m.s. back b/c the bios drive was messed up. F12 didn't work.

  • Need help now for the live installation

    Need help now for the live installation

    Hello

    As described in the question, I understand that you need help. I will definitely help you however, I would be grateful if you could help me with more information to better understand the problem and resolving it.

    1. What is the problem you are experiencing during installation?

    2. That you install? Any software or operating system?

    3. How you try to install the software/Os/application?

    If you need live support from Microsoft then you can click on the link given below and check if it helps.

    https://support.Microsoft.com/en-us/contactus/

    Hope that this help, please write us back for any further assistance on this point, we will be happy to help you further.

  • Need help to install the network on laptop drivers

    I have a laptop of HP 2000-239WM and recently erased due to trying to sell. However, when I reinstalled everything back on the PC, no network drivers have been installed, so I have no access to the internet, wireless and wired. Should what programs I install via USB in order to solve this problem?

    The network adapter driver specifically requests the Ethernet, wifi and it...

    Hello McKinley,

    Thank you for visiting Microsoft Community and we provide a detailed description of the issue.

    According to the description, I understand that you need help to install the network drivers into the laptop.

    Certainly, I understand your concern and will try my best to help you.

    In order to install the NIC drivers in the system, I suggest to visit the link below and check if that helps.

    http://support.HP.com/us-en/drivers/selfservice/HP-2000-200-notebook-PC-series/5091493/model/5119030

    Note: Make sure you have access to the internet to another computer and download the network drivers using the USB and install on your laptop.

    I hope this information is useful.

    Please let us know if you need more help, we will be happy to help you.

    Thank you.

  • Need help to uninstall the game Deadspace

    Original title: uninstall Deadspace

    need help to uninstall the game Deadspace

    What you're looking for?
     
    Revo uninstaller can be faster.
     
  • Need help to retrieve the magnetic border

    As the title says, I need help to get the magnetic border thing (I don't know what his name). It helps a lot when I am rearraging my dekstop icon so that they are all neatly. Its the sticky feeling when you put an icon next to each other. I installed Stardock Fences before and which could lead to the missing or disabled?

    Hello

    • Right-click on an empty part of the desktop
    • Leave the mouse on the view
    • Click Align icons on the grid

    Tricky

  • Need help to identify the type of object in the loop of pl/sql

    Hello

    I need help to identify the Type of object declared beneath a procedure as shown below:

    I need to pass the parameter to the procedure as a TYPE of OBJECT and also refer to variables of Type Object in a loop

    create or replace type TEST_VALIDATION_REC is RECORD (order_num varchar2 (30),)

    number of inventory_item_id

    reserved_YN varchar2 (1).

    error_flag varchar2 (1).

    Error_message varchar2 (2000)

    );

    CREATE OR REPLACE TYPE VALD_TBL AS VARRAY (10000) OF TEST_VALIDATION_REC;

    PROCEDURE ADD_TO_ORD)

    p_lot_number_list IN VALD_TBL,

    p_ord_number IN Varchar2,

    p_user_id in NUMBER: = fnd_profile.value ('USER_ID'),-change 1.10

    p_responsibility_id in NUMBERS: = fnd_profile.value ('RESP_ID'),-change 1.10

    p_application_id IN VARCHAR2: = 'PO',-change 1.10

    x_error_flag OUT Varchar2,

    x_error_msg OUT Varchar2

    )

    In the above procedure, I had the VALD_TBL. Is it OK?

    And how in the loop if the records if I use:

    FOR indx1 IN 1.p_lot_number_list. COUNTY

    LOOP

    BEGIN

    SELECT

    inventory_item_id

    IN

    ln_item_id

    Of

    dummy_lot_tab

    WHERE

    lot_number = p_lot_number_list (indx1); - > how direct the item here?

    EXCEPTION

    WHILE OTHERS THEN

    ln_item_id: = NULL;

    END;

    Records are PL/SQL objects.  They are not the SQL objects.  You can create a SQL TYPE (schema level) as a collection (variable-tables only, tables nested).

    So therefore your first statement is syntactically incorrect

    CREATE OR REPLACE TYPE TEST_VALIDATION_REC IS RECORD
    (order_num VARCHAR2(30),
    inventory_item_id NUMBER,
    reserved_YN VARCHAR2(1),
    error_flag VARCHAR2(1),
    Error_message VARCHAR2(2000)
    );
    

    You must put in an anonymous PL/SQL block or the stored procedure

    DECLARE
    
       TYPE test_validation_rec IS RECORD
       (
        order_num VARCHAR2(30),
        inventory_item_id NUMBER,
        reserved_YN VARCHAR2(1),
        error_flag VARCHAR2(1),
        error_message VARCHAR2(2000)
       );
    
       TYPE vald_tbl iS VARRAY(10000) OF test_validation_rec;
    
       lv_tbl vald_tbl;
    
    BEGIN
    
       lv_tbl := vald_tbl();
      -- insert your code here 
    
    END;
    
  • Hello, I need help for cancel the payment on my adobe account.

    Hello, I need help for cancel the payment on my adobe account. I'm from Peru, Im paying a monthly fee as a student. Help, please...

    Cancel your membership creative cloud

  • Need help to solve the problem with the margin at the bottom of the converted pdf file.

    Need help to solve the problem with the margin of the converted CEO down. What caused the change in format?

    Hi jerrio1949,

    There is no way to change the margin, you settle back into your original file & then convert to PDF format.

    Kind regards
    Nicos

Maybe you are looking for