How to get a subset of the text in a field of varchar2

Hello.  I'm trying to select a subset of the text in a field of varchar2.  It is the view dba_audit_trail login information.  Here is an example of the field (dba_audit_trail comment_text):

Authenticated by: Word of PAST DIRECTORY; EXTERNAL NAME: cn = orcladmin, cn = Users, dc is idacorp, dc = local; Customer's address: (ADDRESS = (PROTOCOL = tcp (PORT = 99999))(HOST=555.555.555.555))

I'm trying to simply select the text of 'sleep' - i.e. everything after the first ' = 'up to the first"

I can get everything after the first '=' with this:

Select substr (comment_text, instr (comment_text, '=') + 1) of dba_audit_trail

... but I don't know how to stop at the first «,»

Any help would be greatly appreciated.

Thank you!

Post edited by: DRC

Hello

Here's a way to do it:

WITH got_pos AS

(

SELECT comment_text - and whatever the other columns you need

INSTR (cooment_text, "=") AS equal_pos

INSTR (cooment_text, ",") AS comma_pos

OF dba_auit_trail

WHERE--no filtering is going here

)

SELECT SUBSTR (comment_text

equal_pos + 1

, comma_pos - (equal_pos + 1)

) AS first_cn

OF got_pos

;

You could do it without a subquery; you would just do the exact same INSTR 2 times, I used equal_pos 2 times.

You can also get the results desired using regular expressions, such as:

SELECT REGEXP_SUBSTR (comment_text

, '=([^,]*),'

1

1

NULL

1

) AS first_cn

OF dba_audit_trail

;

Although this uses less code, it is slower than with a SUBSTR and INSTR.

Tags: Database

Similar Questions

  • How to get Firefox to ignore the status of liaison visits when printing?

    How to get Firefox to ignore the status of liaison visits when printing?

    When I print something, visited links are a different color than unvisited links.
    Is there a way to make the color even when printing?
    (without changing the story, or how things look on the screen)

    If there isn't a way to do that, how about this by adding as a feature?

    One way to do would be to create style rules customized for the printed output that hardcode the link colors for all of the printed output. Firefox supports two ways to proceed: a file userContent.css that you create in the folder settings, and a custom stylesheet applied using the Stylish extension.

    However, 'one size fits all' could lead to unreadable results or ugly on some pages. If an add-on that can do adaptive way would be better. I do not know if someone has created a.

    For sites that do not require a login and that are not personalized, you could launch the page in a private window (right click on the link > open in a new private window or copy the URL and then Ctrl + Shift + p, then paste it in the address bar and enter). Because private windows have their own history, the print should not reflect the history of your regular windows.

  • How to get Firefox to check the compatibility of the addon first, then ask me if I want to continue the update of Firefox?

    How to get Firefox to check the compatibility of the add-on first, then ask me if I want to continue the update of Firefox? The update process currently only told me that an add-on has been disable after you apply the update to Firefox. Options > Advanced Options > switch to the update tab, "Warn me if this turns off one of my modules," doesn't seem to work.

    delores51

    This is an add-on that does this.

    https://addons.Mozilla.org/en-us/Firefox/addon/is-it-compatible/

    More specifically, what modules are always appear as incompatible after a Firefox updated? Firefox 10, extensions that are made properly shouldn't be a problem, with a few exceptions.

    Extension that contains a binary code must be compiled for each new version of Firefox. These modules are usually installed by applications on security Norton, McAfee, ZoneAlarm, etc..

  • How can I copy parts of the text of a pdf file in preview?

    How can I copy parts of the text of a pdf file in preview? For example, the beginning and the end part of a passage - copy not a few sentences in the Middle

    Select the first part of the text you want to copy. Press the command and option together and also select another passage of text. Now, press command + C to copy the two text selections.

    Hypothesis: The PDF did not limit content selection.

  • How to get a program all the list of the names of the values in a registry key?

    Hello

    How to get a program all the list of the names of the values in a key of windows registry without having to configure the number of values in the key?

    Thank you & best regards

    Samuel J

    Hi Samuel,.

    you will get this info from "Query registry key Info.vi".

    Mike

  • How to get a reference to the delivery of the program (not at base of LV)?

    Hello

    I need to create a LV application which will be:

    -Run external executable and not on LV. It has a window of the UI which will open

    -Open PS (no title, menus, etc.) and position it under the user interface

    -If the user moves main UI, LV app FP follows the window

    -If the user closes the main user interface, LV app closes and ends.

    App - LV does not display in the bar of tasks

    So, basically, I need to develop an application that will add-on to an existing GUI, so that together they look and behave like a single user interface.

    The main thing I am struggling with now is how to get a reference to the execution of UI that I call using the exec.vi system

    Help, please!

    What operating system? If you are on Windows, you can try to use the Windows API. Specifically, FindWindow to get a reference to both windows and SetParent to set the parent of one of the windows. This example gives you the basic idea.

  • Me am XP license key do not have an installation disc. How to get a copy of the Setup disk?

    Recently, I bought an IBM Net Vista original case, a site auction like eBay, but for my country (Serbia). It came with a sticker with a windows XP Professional license print top (with all holograms too, so I think this is authentic). All components in this case are mine (MB, CPU, GPU, RAM...), and I don't have an original Win XP Pro Installation CD. Can I use this license number? If so, how to get a copy of the installation disc?

    Please see: How to replace Microsoft software

  • I'm reading a file mpeg and Windows Media Player C00D1199 error. How to get good download of the missing codec?

    I'm reading a file mpeg and Windows Media Player C00D1199 error.  How to get good download of the missing codec?  I have windows 7 x 64 os.

    All is not lost.

    Download and install a pack of codecs, such as K-Lite (Google for it). You can find THAT WMP can then read the file.

    Or
    Download and install a small program called Gspot (Google it)! Drag and drop in its window one of the files, you can't plzy. It will tell you which codecs are used. You can then download and install the only after doing a search on the web for it.
    See you soon,.
    Jerry
  • How to get special characters in the oracle column only

    Hi all

    with spec_tab

    as

    (

    Select ',' col1 of double

    Union

    Select ',' col1 of double

    Union

    Select 'something' double

    )

    Select col1

    of spec_tab

    How to get special characters in the oracle column only

    You mean like this?

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

    WITH spec_tab
         AS (SELECT ',,,,' col1 FROM DUAL
             UNION
             SELECT ',' col1 FROM DUAL
             UNION
             SELECT 'some thing' FROM DUAL)
    SELECT col1
      FROM spec_tab
      where translate('~'||col1,'~0123456789abcdefghijklmnopqrstuvwxyz ','~')<>'~'
    

    Output:

    -----

    COL1

    ,

    ,,,,

    See you soon,.

    Manik.

  • How to get a glimpse of the Chrome using Adobe Dreamweaver PHP page?

    How to get an overview of the PHP page on Chrome with Adobe Dreamweaver CS 6 using Xampp. When I click on "Preview in Chrome.pic2.png

    When I click 'Yes' and the site configuration parameter, I don't understand what to do in the server side.

    pic3.png

    Click on the sign (bottom left) to create new server details.   See screenshot.

    Your directory of default web in XAMPP's htdocs.

    Folder on the server: C:\xampp\htdocs\yourSiteName

    Web URL: http://localhost/yourSiteName/

    Don't forget to add the template to your test server (Advanced tab).

    Nancy O.

  • How to add an outline to the text?

    How to add an outline to the text?

    Add a line in the character of the text layer settings.

  • Photography plan Cloud creative student and Teacher Edition (one year) and no idea of how to get and start using the programs?

    So I just brought the creative plan Cloud photography student and Teacher Edition (one year) and no idea of how to get and start using the programs?

    Hello

    Go to creative.adobe.com and you identify with your Adobe ID

    From there, you can download the applications you purchased.

    Normally, you are taken there immediately after the purchase.

  • DOES ANYONE KNOW HOW TO GET THESE IDIOTS ON THE PHONE?

    DOES ANYONE KNOW HOW TO GET THESE IDIOTS ON THE PHONE

    Salvation of barracks,

    We will probably address your issue and would try our best to solve this problem, but we ask to use professional words so that we can help you.

    I beg of you please explain about this, if possible we would guide you with the steps detailed here only.

    In case you want to connect with the Adobe support team, you might check out the following link.

    http://helpx.Adobe.com/x-productkb/global/Service1.html

    Please click on the blue button "Still need help" to connect with one of the Adobe Executive.

    Concerning

    Sukrit diallo

  • How to set background color of the text?

    I have a TextFrame: abcd

    I want to set the background color of the text "bc" is red

    How to set background color of the text?

    Who would be with custom underscore. Set the solid style, choose a color and to adjust the weight and offset of an underline, making it thick and move up behind the text.

  • How to get other channels in the channel list.

    Hi experts,

    How to get other channels in the channel list.

    for example

    "Country1, Italy countries2, India, countries3, paris, countries4, scottland, Canada5, rome"

    in the list above, I need to get all the countries and their names separately.

    as countries1, countries2, countries3 countries4 Canada5

    India, paris, Scotland, Italy, rome

    I try the one above in the fashion below

    SELECT SUBSTR

    ("Country1, Italy, countries2, India, countries3, paris, countries4, scottland, Canada5, rome,

    1,

    INSTR

    ("Country1, Italy, countries2, India, countries3, paris, countries4, scottland, Canada5, rome,

    ',',

    1,

    1

    )

    -1

    )

    OF THE DOUBLE

    everything please help me

    If you want the data to be more structured and useful:

    Column collar for a20
    Col col_value to a20

    inlist var VARCHAR2 (2000)

    exec: inlist: = 'Country1, Italy, countries2, India, countries3, paris, countries4, scottland, Canada5, rome;
    exec: inlist: = replace (: inlist,' ')

    Select max (decode (mod(lvl,2), 1, value)) Column
    , max (decode (mod(lvl,2), 0, value)) col_value
    from (select substr (: InList, + 1 start_pos, end_pos-start_pos-1) value)
    lvl
    from (select: InList)
    case when level = 1 then
    0
    on the other
    InStr(:InList,',',1,Level-1)
    end start_pos
    case when instr(:InList,',',1,level) = 0
    then length(:InList) + 1
    on the other
    InStr(:InList,',',1,Level)
    end end_pos
    level lvl
    of the double
    connect by level<>
    )
    )
    ceil(lvl/2) group
    order by 1;
          
    COLUMN COL_VALUE
    ____________________ ____________________
    Country1 Italy
    countries2 India
    countries3 paris
    Scottland countries4
    country5 rome

    Not tested on 10g

    Then you could stragg lines together...

Maybe you are looking for

  • How to remove the disc from the optical drive

    Had to change hard drive on MacBook Pro - had tried to use Drive Genius to fix an old - not good - now have a new HD in there with no OS - now have a disc in the drive I can not eject so I can load OSX of a disc and eith no OS can not download oe ElC

  • Pavilion g7-1077nr: HP PAVILION g7-1077nr forgotten power on password

    Hi, I have not used this laptop for a while and I forgot my password on. A way to recover or reset it? Thanks in advance.

  • Ship to Dominican Republic

    Hello, I hope you're well. I have a problem to buy a headset of Dominican Republic.What is the "Clave LADA"? Do you ship to Dominican Republic?

  • Nighthawk R7000 does not connect

    I bought this router on July 7, 2015. I was able to set up fine, and it worked perfectly. All of a sudden, it stopped work. It won't send a signal wifi on any of my devices. I run on Windows 8.1. I could connect my old router netgear very well, but I

  • Restrict changes to the desktop in Windows XP Pro

    I have two computers that are running Windows XP Pro.  They must be used to access the Internet and Microsoft Office programs.  I turned on the guest account so that a password is not necessary to log in.  Some features are blocked because the user d