Substring in SELECT Statemen

Hello I need to do something like this:
select single bukrs     
from ce1xx00            
into v_bukrs            
where prctr+2(2) = 'ab'.
but is telling me prctr+2(2) is not valid.
How can I do that? I'm doing this in an RFC call and is not affordable to bring all the data from the table
Any ideas?
TIA

So in your case....
select single bukrs
from ce1xx00
into v_bukrs
where prctr  = '__ab%'.
You may have to use upper case.
select single bukrs
from ce1xx00
into v_bukrs
where prctr  = '__AB%'.
REgards,
Rich HEilman

Similar Messages

  • Substring in select statement

    i have a selection screen where year is only input field, and in my table there is a date field, so i have to retrieve the data only of the given year only, so how do i substring the date field of that table and compare with my input in select statement

    If your corresponding database table has the year field and you want to get the data according to the fiscal year
    then try the following ways : .
    parameters : p_date type datum. " Ur date field.
    data : g _year type i.
    at selection-screen:.
    move p_date+0(4) to g_year.
    Then pass g_year in your where clause.
    or you can use the FM.
    CALL FUNCTION 'GET_CURRENT_YEAR'
        EXPORTING
          bukrs = u2018ur company code'u2019
          date  = ur date field.
        IMPORTING
    *      currm = fiscalmonth
          curry = g_year.
    here also pass g_year in your where clause.
    Regards
    Abhinab.

  • How to get all rows that are returned in inner sub query of select statemen

    If a sub query in select statement returns more than one row than how to get all those returned rows in the final
    output of the query .It will be all right if all column's value repeat and that multiple output of inner query comes
    in another column .
    How to get that ?

    As Frank said, you likely want a join, and likely an outer join to replicate the select in the projection. Something like:
    SELECT id,stat, section, USER_ID concerned_person
    FROM table_all,
      left join table2
        on room_id = sectoion and
           sur_role = 'r001'
    WHERE section IN (SELECT code
                      FROM t_area
                      WHERE dept= 'p002')An alternative, depending on where and how you are using the statement would be something like:
    SQL> WITH t AS (
      2    select 1 id from dual union all
      3    select 2 id from dual),
      4  t1 as (
      5    select 1 id, 'One' descr from dual union all
      6    select 1, 'Un' from dual union all
      7    select 1, 'Une' from dual)
      8  SELECT t.id, CURSOR(SELECT t1.id, t1.descr from t1
      9                      WHERE t1.id = t.id)
    10  FROM t;
                      ID CURSOR(SELECTT1.ID,T
                       1 CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
                      ID DESCR
                       1 One
                       1 Un
                       1 Une
                       2 CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    no rows selectedJohn

  • Regexp substr to select the max number out an string

    Hi all,
    I need a solution for a query.
    I,ve a query to select the lowest number in a string.
    select regexp_substr('9 - 10','\d+')
    from dual;
    9
    So this is the query I need to select the min number in he string.
    but now I need it to give me the highest nr in the string .
    the output that I need =10
    Can someone help me pleasse?
    My regards

    Caroline wrote:
    select regexp_substr('9 - 10','\d+')
    from dual;
    9
    So this is the query I need to select the min number in he string.Actually it only gives you the first number in the string, not the minimum number.
    SQL> select regexp_substr('9 - 10','\d+')
      2  from dual;
    R
    9If your string is the other way around it will give you 10 instead of 9.
    SQL> ed
    Wrote file afiedt.buf
      1  select regexp_substr('10 - 9','\d+')
      2* from dual
    SQL> /
    RE
    10You probably want something like...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '9 - 10' as txt from dual)
      2  -- end of sample data
      3  select min(num) as min_num, max(num) as max_num
      4  from (
      5        select to_number(trim(REGEXP_SUBSTR (txt, '[^-]+', 1, level))) as num
      6        from t
      7        connect by level <= length(regexp_replace(txt,'[^-]*'))+1
      8*      )
    SQL> /
       MIN_NUM    MAX_NUM
             9         10
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '10 - 9' as txt from dual)
      2  -- end of sample data
      3  select min(num) as min_num, max(num) as max_num
      4  from (
      5        select to_number(trim(REGEXP_SUBSTR (txt, '[^-]+', 1, level))) as num
      6        from t
      7        connect by level <= length(regexp_replace(txt,'[^-]*'))+1
      8*      )
    SQL> /
       MIN_NUM    MAX_NUM
             9         10
    SQL>

  • How do I change the selected text of a combobox on the fly?

    Hi all,
    I am trying to make a combobox, that is sort of a "recently used" connection box. So you can type in a computer name, hit connect and it then connects. When you disconnect, it adds the computer name, and the logged in username to the combobox,
    so when you click on the drop down, you get selections for example : "COMPUTER1 - johnsmith"
    Which is cool, but what I want, is to be able to click on the selection, and it only puts the computer name in the TextBox - i.e. "COMPUTER1"
    So I have done a bit of research, and tried making a hashtable, and using the DisplayMember and ValueMember properties, so i can at least have a combobox selection like "COMPUTER1 (johnsmith)". I have tried many different pages and suggestions,
    but the furtherest I have got is to only have one or the other value display, or it displays as System.Collection...... (can't remember the rest).
    So my next attempt, is using an event handler for the combobox to change the text, so that once "COMPUTER1 - johnsmith" is selected from the combobox, it puts "COMPUTER1" as the selected text.
    I have tried the following using the SelectedIndexChanged handler. Here is a snippet of my code relating to the ComboBox:
    # PC Connection Input Box$global:pcInputBox = New-Object System.Windows.Forms.ComboBox
    $global:pcInputBox.Location = New-Object System.Drawing.Size(70,50)
    $global:pcInputBox.Size = New-Object System.Drawing.Size(210,20)
    $global:pcInputBox_SelectedIndexChanged = {
    if (($global:pcInputBox.Text -ne $null) -and ($global:pcInputBox.Text -ne "")){
    $selection = $global:pcInputBox.Text
    addLog("Selection is $selection")
    $global:trimSelection = $selection.substring(0,$selection.indexof("-"))
    addLog("TrimSelection is $global:trimSelection")
    $global:pcInputBox.SelectedItem = $global:trimSelection
    addLog("SelectedText is $global:pcInputBox.SelectedItem")
    $global:pcInputBox.add_GotFocus({
    $Form.AcceptButton = $pcButton
    $global:pcInputBox.add_SelectedIndexChanged($global:pcInputBox_SelectedIndexChanged)
    $Form.Controls.Add($global:pcInputBox)
    I have also tried setting the $global:pcInputBox.Text but the result is that nothing changes. Its as though I can't change that ComboBox from its own event?? If I try setting $global:pcInputBox.Text from another function, it will do it fine.
    Can anyone please recommend how I would get this achieved?
    Thanks in advance
    Adam Street

    Use objects:
    $o=@()
    $o+=New-Object PsObject -Property @{Computer='COMP1';User='USER01'}
    $o+=New-Object PsObject -Property @{Computer='COMP2';User='USER02'}
    $o+=New-Object PsObject -Property @{Computer='COMP3';User='USER03'}
    $combobox1.DataSource=[collections.arraylist]($o|select Computer,User, @{N='DisplayName';E={"$($_.Computer)-$($_.User)"}})
    $combobox1.DisplayMember='DisplayName'
    This can also be loaded from a CSV or from AD or almost anywhere else;
    Here is another trivial example:
    $o=@()
    $o+=New-Object PsObject -Property @{Computer='COMP1';User='USER01'}
    $o+=New-Object PsObject -Property @{Computer='COMP2';User='USER02'}
    $o+=New-Object PsObject -Property @{Computer='COMP3';User='USER03'}
    Add-Type -AssemblyName System.Windows.Forms
    $form=New-Object System.Windows.Forms.Form
    $form.StartPosition='CenterScreen'
    $combobox1 = New-Object System.Windows.Forms.ComboBox
    $combobox1.Location='70,50'
    $combobox1.Size='210,20'
    $combobox1.DataSource=[collections.arraylist]($o|select Computer,User, @{N='DisplayName';E={"$($_.Computer)-$($_.User)"}})
    $combobox1.DisplayMember='DisplayName'
    $combobox1.add_SelectedIndexChanged({[System.Windows.Forms.MessageBox]::Show($combobox1.SelectedItem.Computer)})
    $form.Controls.Add($combobox1)
    $form.ShowDialog()
    ¯\_(ツ)_/¯

  • Substring Location in String

    I am having a problem using substring to select/filter.  The substring selection is not holding to the specified locations in the string.  Instead, it finds any matching text in the entire string.
    For reference, my web site intent is,
    1. A single XML master data base contains all photographs for display.  My XML data set does not have quotes.
    2. Spry tabbed panels are used to select galleries (Spry regions) (e.g. roses, Big Sur Coast, etc) from the master data base.  There are a dozen galleries.
    3. Thumbnails of a gallery are displayed in the content panel.
    4. Selecting a thumbnail displays a large view of the selected photo in a separate div (Spry detail region).
    The galleries are filtered using spry:test, with the "subject" variable compared against a specified value (i.e. rose, Monterey, Salinas, etc.).
    The "2010 Photographs" gallery is determined by the year of the photo.  In the "name" variable, the first 6 digits are the date (month, day, year).  I've set up the spry:test with substring as follows,
    spry:test="'substring({name},5,2)'.search ('10 ') != -1;"
    This is to obtain the 5th and 6th locations of "name" variable and compare it with the "10 ".
    A sample of the "photo" node follows,
    <photo>
    <name>032010 Lover's Pt, Pacific Grove 02a web.jpg</name>
    <width>599</width>
    <height>400</height>
    <thumbname>032010 Lover's Pt, Pacific Grove 02a thumbnail.jpg.</thumbname>
    <thumbwidth>150</thumbwidth>
    <thumbheight>100</thumbheight>
    <subject>night</subject>
    <description>West side of Lover's Point, Pacific Grove, Ca.; the surf was unusually calm.  The glow reflecting on the clouds and the bay is from the town of Santa Cruz.</description>
    </photo>
    <photo>
    <name>090609 Pelican over Pacific Grove 02a 8x10 web.jpg</name>
    <width>500</width>
    <height>400</height>
    <thumbname>090609 Pelican over Pacific Grove 02a 8x10 thumbnail.jpg</thumbname>
    <thumbwidth>125</thumbwidth>
    <thumbheight>100</thumbheight>
    <subject>animal</subject>
    <description>Pelican caught in flight; using a flash, this photograph was taken at dusk; Pacific Grove, Ca.</description>
    </photo>
    Both of these nodes would be selected with the "10 " criteria.  However the second one is not from the year 2010.
    The full source code is shown below.
    My search of these forums and the Internet have indicated that this should work.  Please explain what I am missing or doing incorrectly in the code.
    I thank you.
    Scott
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>EnvisionMoore</title>
    <style type="text/css">
    <!--
    body {
    background-color: #FFF;
    text-align: center;
    margin: 0px;
    padding: 0px;
    #wrapper {
    width: 98%;
    margin-top: 10px;
    margin-right: auto;
    margin-bottom: 0px;
    margin-left: auto;
    border: 0px dashed #F0F;
    position: absolute;
    left: 1px;
    top: 1px;
    height: 825px;
    background-color: #FFE4CA;
    #leftColumn {
    float: left;
    height: 700px;
    width: 400px;
    position: relative;
    left: 0px;
    top: 0px;
    #header {
    height: 125px;
    font-size: 24px;
    font-style: italic;
    vertical-align: bottom;
    padding: 0px;
    text-align: center;
    float: right;
    width: 50%;
    border: 0px solid #F00;
    position: relative;
    top: 0px;
    right: 0px;
    #selectedPhoto {
    height: 600px;
    font-size: 24px;
    font-style: italic;
    vertical-align: middle;
    padding: 0px;
    text-align: center;
    margin-top: 135px;
    width: 650px;
    border: 0px solid #0F0;
    position: absolute;
    right: -1px;
    bottom: 1px;
    -->
    </style>
    <script src="SpryAssets/xpath.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryData.js" type="text/javascript"></script>
    <script type="text/javascript">
    <!--
    var name;
    var width;
    var height;
    var thumbname;
    var thumbwidth;
    var thumbheight;
    var subject;
    var description;
    var thumbnail;
    var dsphoto;
    var dsdata;
    //-->
    </script>
    <script type="text/javascript">
    var dsdata = new Spry.Data.XMLDataSet("EM_photo.xml", "/gallery");
    var dsphoto = new Spry.Data.XMLDataSet("EM_photo.xml", "gallery/photos/photo");
    </script>
    <script type="text/javascript">
    function MM_callJS(jsStr) { //v2.0
      return eval(jsStr)
    </script>
    <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="wrapper">
      <div id="leftColumn">
        <div id="TabbedPanels1" class="TabbedPanels">
          <ul class="TabbedPanelsTabGroup">
            <li class="TabbedPanelsTab" tabindex="0">Welcome</li>
            <li class="TabbedPanelsTab" tabindex="0">Mechanical Engineering</li>
            <li class="TabbedPanelsTab" tabindex="0">Photography</li>
          </ul>
          <div class="TabbedPanelsContentGroup">
            <div class="TabbedPanelsContent">
              <h1><br />
      <br />
      <br />
      <br />Welcome!
      <br />
              </h1>
            </div>
            <div class="TabbedPanelsContent">Mechanical Engineering - Content 2</div>
            <div class="TabbedPanelsContent"> <!-- Photography - Content 3 -->
              <div id="TabbedPanels2" class="TabbedPanels">
                <ul class="TabbedPanelsTabGroup">
                  <li class="TabbedPanelsTab" tabindex="0">2010 Photographs</li>
                  <li class="TabbedPanelsTab" tabindex="0">Roses</li>
                  <li class="TabbedPanelsTab" tabindex="0">Calla Lilies</li>
                  <li class="TabbedPanelsTab" tabindex="0">Other Blossoms and Leaves</li>
                  <li class="TabbedPanelsTab" tabindex="0">Pacific Grove Beach</li>
                  <li class="TabbedPanelsTab" tabindex="0">Monterey Harbor and Beach</li>
                  <li class="TabbedPanelsTab" tabindex="0">Big Sur Coast</li>
                  <li class="TabbedPanelsTab" tabindex="0">Salinas Valley</li>
                  <li class="TabbedPanelsTab" tabindex="0">Animals</li>
                  <li class="TabbedPanelsTab" tabindex="0">Night</li>
                  <li class="TabbedPanelsTab" tabindex="0">Church</li>
                  <li class="TabbedPanelsTab" tabindex="0">Other</li>
                </ul>
                <div class="TabbedPanelsContentGroup-2">
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'substring({name},5,2)'.search ('10 ') != -1;" ; onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat = "dsphoto" spry:test="'{subject}'.search (/rose/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/callalily/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = "{thumbwidth}px" height = "{thumbheight}px" onclick="dsphoto.setCurrentRow('{ds_RowID}');" spry:repeat="dsphoto" spry:test="'{subject}'.search (/blossom/) !=-1;" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = "{thumbwidth}px" height = "{thumbheight}px" onclick="dsphoto.setCurrentRow('{ds_RowID}');" spry:repeat = "dsphoto" spry:test="'{subject}'.search (/^p/) !=-1;" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/Monterey/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/bigsurcoast/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/Salinas/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/animal/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/night/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/church/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
                  </div>
                  <div class="TabbedPanelsContent-2">
                    <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/other/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
                  </div>
                </div>
              </div>
            </div>
            <!-- End "Photography Content 3" Tabbed Panels Content. -->
          </div>
        </div>
      </div><!-- End div "leftColumn" -->
      <div id="header">
        <p>Envision Moore</p>
        <p>      Mechanical Engineering and Photography</p>
        <p>      Scott W. Moore</p>
      </div><!-- End div "header". -->
      <div id="selectedPhoto">
      <div id="Selection" spry:detailregion = "dsphoto dsdata"  >
    <!-- Selected photographs are 400px tall. -->
    <img src="Photo-Email/{name}" width = {width}px height = {height}px align="center" />
      <br />
    Description<br /><br />
    <p> {dsphoto::email/base}{description} </p>
    </div>
    </div> <!-- End div "selectedPhoto". -->
    </div> <!-- End div "wrapper" -->
    <script type="text/javascript">
    <!--
    var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
    var TabbedPanels2 = new Spry.Widget.TabbedPanels("TabbedPanels2");
    //-->
    </script>
    </body>
    </html>

    Moore6931 wrote:
    Ben
    I thank you but the change of the starting location did not correct the problem.  I copied your script and pasted it into the source code but the results were the same set of thumbnails; several of the thumbnails are prior to (20)10.
    In considering the results, I decided to try,
    spry:test="'{name}'.search  ('10 ') != -1;"
    This filter gave the same result as,
    spry:test="'substring({name},4,2)'.search  ('10 ') != -1;"
    I found out that the "4,2" arguments of substring should be "4,6".  Each of these arguments are locations; other substring functions have location and length.
    I updated the filter to,
    spry:test="'substring({name},4,6)'.search  ('10') != -1;"
    The filter result was not changed.  Are the location arguments being ignored or overwritten by a default setting?  The symptom is that the first location is "0" and the second location is omitted.
    I thank you for your help.  This is rather fascinating!
    Scott
    Howdy,
    When you take a closer look at your at your code you will notice that you actually wrapped the substring function inside a string. So you are actually performing a search on:
    'substring(contents,4,6)'
    So what i would suggest is to do:
    spry:test="'{name}'.substring( 4,6 ).search( '10' ) != -1 "
    And if that doesn't work, try to use a function::syntax instead, see API: function::<function name>

  • Select a part of a videofile

    hi
    i want to capture a specific,adjustable(from frame.. to frame...) part of an existing videofile. for example i have a file with a length of 2 minutes an i only need frame 400 - 600 to work with them. i want to set these borders by scrolling the file in a player. is there (in jmf) any method which can do this?
    thanks for answers and sorry for the bad english.

    If you want to select the first 10 characters of a character column, you would use the SUBSTR function
    SELECT SUBSTR( reportdate, 1, 10 )
      FROM traffic;If reportdate is really a DATE column, you would want to include a to_char cast operation to specify how the DATE should be converted to a string. Since you are explicitly specifying the formatting in that case, you can eliminate the SUBSTR call
    SELECT to_char( reportdate, 'DD-MM-YYYY' )
      FROM traffic;If you want to group by day, and reportdate is a DATE column, you can do
    GROUP BY TRUNC( reportdate )Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Help With SUBSTR in dynamic SQL statement

    Following is the dynamic SQL statement.
    EXECUTE IMMEDIATE 'UPDATE table_name pml
    SET pml.'|| con_fields.field ||' = SUBSTR(pml.'||con_fields.field||' ||'' ''||
    (SELECT pml1.'||con_fields.field||'
    FROM table_name pml1
    WHERE pml1.grp_id = '||los_concats.grp_id ||'
    AND pml1.row_id = '||los_concats.row_id||'
    AND pml1.loser_flg = ''Y''),1, '||con_fields.max_length||')
    WHERE pml.grp_id = '||los_concats.grp_id ||'
    AND pml.loser_flg IS NULL ';
    what it does is that it updates a particular field. This field is concatenated by a field of a similar record.
    My problem is with SUBSTR function. Since I am concatenating fields I do not want the field to be updated greater than max_length on that field, the reason why I use SUBSTR. the select query inside SUBSTR works alright with one of the AND condition in a WHERE clause not present. When I add that additional condition it gives me this error.
    ORA-00907: missing right parenthesis.
    Is there any way to get around this problem. Does SQL has other than SUBSTR function which can limit the character length.
    Appreciate it.

    The other alternative I thought about was to do this first
    EXECUTE IMMEDIATE 'SELECT pml.'||con_fields.field||'
    FROM table_name pml
    WHERE pml.grp_id = '||los_concats.grp_id||'
    AND pml.row_id = '||los_concats.row_id||'
    AND pml.loser_flg = ''Y''
    ' INTO v_concat_field;
    write into the variable v_concat_field and then use it into the previous script.
    But on this I get SQL Command not properly terminated, I don't get it Why?
    Donald I tried with your suggested script. It works fine with one of the conditions eliminated. I don't understand what the error trying to say?
    Thanks

  • Question on Substring or Regular Expression

    Experts,
    I have values is column similar to this:
    Remarks:
    IHCIS 651216 K6
    KORE 657526
    COR SWITX 658999 K6 ADHOC
    I need to pull out the number starting with "6" (it always starts with 6, and it is always six characters). I then need to set the value of another column to that substring.
    Update table x
    set p_code = "Query returning the substring value"
    I've used substring before but I don't know how to search for the "6" since it is in different locations for each row.
    Any help is greatly appreciated.
    Rich

    Hi,
    Here is an example using "SUBSTR':
    SQL> select substr('IHCIS 651216 K6', instr('IHCIS 651216 K6', '6') , 6) from dual;
    SUBSTR
    651216

  • How to get each value from a parameter passed like this '(25,23,35,1)'

    Hi
    One of the parameter passed to the function is
    FUNCTION f_main_facility(pi_flag_codes VARCHAR2) return gc_result_set AS
    pi_flag_codes will be passed a value in this way '(25,23,35,1)'
    How to get each value from the string
    like 25 first time
    23 second time
    35 third time
    1 fourth time
    I need to build a select query with each value as shown below:-
    (SELECT t2.org_id, t4.description
    from org_name t2, ref_org_name t3, code_table t4
    where t2.att_data = t4.code
    and t3.ref_code = t2.att_type
    and t2.att_type = 25 and t3.code_type = t4.code_type
    and to_date('01-JAN-10', 'DD-MON-YY') between t2.att_start_date AND t2.att_end_date) q1,
    (SELECT t2.org_id, t4.description
    from org_name t2, ref_org_name t3,code_table t4
    where t2.att_data = t4.code
    and t3.ref_code = t2.att_type
    and t2.att_type = 23 and t3.code_type = t4.code_type
    and to_date('01-JAN-10', 'DD-MON-YY') between t2.att_start_date AND t2.att_end_date) q2,
    (SELECT t2.org_id, RTRIM(xmlagg(xmlelement(e, t4.description || ';')
    ORDER BY t4.description).EXTRACT('//text()'), ';') AS DESCRIPTION
    from org_name t2, ref_org_name t3,code_table t4
    where t2.att_data = t4.code
    and t3.ref_code = t2.att_type
    and t2.att_type = 35 and t3.code_type = t4.code_type
    and to_date('01-JAN-10', 'DD-MON-YY') between t2.att_start_date AND t2.att_end_date
    group by t2.org_id) q3,
    (SELECT t2.org_id, t4.description
    from org_name t2, ref_org_name t3, code_table t4
    where t2.att_data = t4.code
    and t3.ref_code = t2.att_type
    and t2.att_type = 1 and t3.code_type = t4.code_type
    and to_date('01-JAN-10', 'DD-MON-YY') between t2.att_start_date AND t2.att_end_date) q4
    Please help me with extracting each alue from the parm '(25,23,35,1)' for the above purpose. Thank You.

    chris227 wrote:
    I would propose the usage of regexp for readibiliy purposes and only in the case if this doesnt perform well, look at solutions using substr etc.
    select
    regexp_substr( '(25,23,35,1)', '\d+', 1, 1) s1
    ,regexp_substr( '(25,23,35,1)', '\d+', 1, 2) s2
    ,regexp_substr( '(25,23,35,1)', '\d+', 1, 3) s3
    ,regexp_substr( '(25,23,35,1)', '\d+', 1, 4) s4
    from dual 
    S1     S2     S3     S4
    "25"     "23"     "35"     "1"In pl/sql you do something like l_val:= regexp_substr( '(25,23,35,1)', '\d+', 1, 1);
    If t2.att_type is type of number you will do:
    t2.att_type= to_number(regexp_substr( '(25,23,35,1)', '\d+', 1, 1))Edited by: chris227 on 01.03.2013 08:00Sir,
    I am using oracle 10g.
    In the process of getting each number from the parm '(25,23,35,1)' , I also need the position of the number
    say 25 is at 1 position.
    23 is at 2
    35 is at 3
    1 is at 4.
    the reason I need that is when I build seperate select for each value, I need to add the query number at the end of the select query.
    Please see the code I wrote for it, But the select query is having error:-
    BEGIN
    IF(pi_flag_codes IS NOT NULL) THEN
    SELECT length(V_CNT) - length(replace(V_CNT,',','')) FROM+ ----> the compiler gives an error for this select query : PLS-00428:
    *(SELECT '(25,23,35,1)' V_CNT  FROM dual);*
    DBMS_OUTPUT.PUT_LINE(V_CNT);
    -- V_CNT := 3;
    FOR L_CNT IN 0..V_CNT LOOP
    if L_CNT=0 then
    V_S_POS:=1;
    V_E_POS:=instr(pi_flag_codes, ',', 1, 1)-1;
    else
    V_S_POS:=instr(pi_flag_codes,',',1,L_CNT)+1;
    V_E_POS:=instr(pi_flag_codes, ',', 1, L_CNT+1)-V_S_POS;
    end if;
    if L_CNT=V_CNT then
    V_ID:=TO_NUMBER(substr(pi_flag_codes,V_S_POS));
    else
    V_ID:=TO_NUMBER(substr(pi_flag_codes,V_S_POS,V_E_POS));
    end if;
    VN_ATYPE := ' t2.att_type = ' || V_ID;
    rec_count := rec_count +1;
    query_no := 'Q' || rec_count;
    Pls help me with fetching each value to build the where cond of the select query along with the query number.
    Thank You.

  • Performance for table BKFP

    Hi,
    I would like to enquire is there anyway that i can improve the performance for table BKPF from the ABAP code point of view.
    Because we have customise one program to generate report for the asset master listing.
    one of the select statement are show as below:
          SELECT SINGLE * FROM BKPF WHERE BUKRS = ANEP-BUKRS
                                      AND GJAHR = ANEP-GJAHR
                                      AND AWKEY = AWKEYUS.
    I would like to know how it different from the select statemene below:
    SELECT SINGLE * FROM BKPF INTO CORRESPONDING FIELDS OF T_BKPF
          WHERE
          BUKRS = ANEP-BUKRS
      AND GJAHR = ANEP-GJAHR
      AND AWKEY = AWKEY.
    Which of the select statements above can enhance report,because currently we have face quite bad issue on this report.
    Can i post the ABAP code on this forum.
    Hope someone can help me on this. thank you.

    Hi,
    As much as possible use the primary keys of BKPF which is BUKRS, BELNR and GJAHR. Also, select only the records which are needed so to increase performance. Please look at the code below:
    DATA: lv_age_of_rec TYPE p.
      FIELD-SYMBOLS: <fs_final> LIKE LINE OF it_final.
      LOOP AT it_final ASSIGNING <fs_final>.
      get records from BKPF
        SELECT SINGLE bukrs belnr gjahr budat bldat xblnr bktxt FROM bkpf
        INTO (bkpf-bukrs, bkpf-belnr, bkpf-gjahr, <fs_final>-budat,
              <fs_final>-bldat, <fs_final>-xblnr, <fs_final>-bktxt)
        WHERE bukrs = <fs_final>-bukrs
          AND belnr = <fs_final>-belnr
          AND gjahr = <fs_final>-gjahr.
      if <fs_final>-shkzg = 'H', multiply dmbtr(amount in local currency)
      by negative 1
        IF <fs_final>-shkzg = 'H'.
          <fs_final>-dmbtr = <fs_final>-dmbtr * -1.
        ENDIF.
      combine company code(bukrs), accounting document number(belnr),
      fiscal year(gjahr) and line item(buzei) to get long text.
        CONCATENATE: <fs_final>-bukrs <fs_final>-belnr
                     <fs_final>-gjahr <fs_final>-buzei
                     INTO it_thead-tdname.
        CALL FUNCTION 'READ_TEXT'
          EXPORTING
            client                        = sy-mandt
            id                            = '0001'
            language                      = sy-langu
            name                          = it_thead-tdname
            object                        = 'DOC_ITEM'
          ARCHIVE_HANDLE                = 0
          LOCAL_CAT                     = ' '
        IMPORTING
          HEADER                        =
          TABLES
            lines                         = it_lines
         EXCEPTIONS
           id                            = 1
           language                      = 2
           name                          = 3
           not_found                     = 4
           object                        = 5
           reference_check               = 6
           wrong_access_to_archive       = 7
           OTHERS                        = 8.
       IF sy-subrc <> 0.
         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
       ENDIF.
      if successful, split long text into start and end date
        IF sy-subrc = 0.
          READ TABLE it_lines TRANSPORTING tdline.
          IF sy-subrc = 0.
            SPLIT it_lines-tdline AT '-' INTO
                  <fs_final>-s_dat <fs_final>-e_dat.
          ENDIF.
        ENDIF.
      get vendor name from LFA1
        SELECT SINGLE name1 FROM lfa1
        INTO <fs_final>-name1
        WHERE lifnr = <fs_final>-lifnr.
        lv_age_of_rec = p_budat - <fs_final>-budat.
      condition for age of deposits
        IF lv_age_of_rec <= 30.
          <fs_final>-amount1 = <fs_final>-dmbtr.
        ELSEIF lv_age_of_rec > 30 AND lv_age_of_rec <= 60.
          <fs_final>-amount2 = <fs_final>-dmbtr.
        ELSEIF lv_age_of_rec > 60 AND lv_age_of_rec <= 90.
          <fs_final>-amount3 = <fs_final>-dmbtr.
        ELSEIF lv_age_of_rec > 90 AND lv_age_of_rec <= 120.
          <fs_final>-amount4 = <fs_final>-dmbtr.
        ELSEIF lv_age_of_rec > 120 AND lv_age_of_rec <= 180.
          <fs_final>-amount5 = <fs_final>-dmbtr.
        ELSEIF lv_age_of_rec > 180.
          <fs_final>-amount6 = <fs_final>-dmbtr.
        ENDIF.
        CLEAR: bkpf, it_lines-tdline, lv_age_of_rec.
      ENDLOOP.
    Hope this helps...
    P.S. Please award points for useful answers.

  • Can I use Replace function in a decode??

    Hello,
    I am trying to use replace function inside a Decode Function,
    Here is how I am doing it:
    select
    SUBSTR (
    DECODE (
    IH.DRVD_ALT_MAIL_ADDR_PRIM_FLAG,
    'N',
    REPLACE (
    ih.subs_addr_1
    || ' '
    || ih.subs_addr_2
    || ' '
    || ih.subs_city
    || ','
    || ih.subs_state_code
    || ' '
    || ih.subs_zip_code,
    'Y',
    REPLACE (
    IH.PRINT_ALT_MAIL_ADDR_LINE_1
    || ' '
    || IH.PRINT_ALT_MAIL_ADDR_LINE_2
    || ' '
    || IH.PRINT_ALT_MAIL_ADDR_LINE_3
    || ' '
    || IH.PRINT_ALT_MAIL_ADDR_LINE_4
    || ' '
    || IH.PRINT_ALT_MAIL_ADDR_LINE_5
    || ' '
    || IH.PRINT_ALT_MAIL_ADDR_LINE_6,
    ) 1,
    50
    address from x
    Can anyone please tell me what am I doing wrong here, It always gives me an error about missing a right parenthesis.
    Thanks in advance.

    Hi Jimmy,
    Looks like you are missing the first comma in the SUBSTR function
    SELECT SUBSTR (
             DECODE (
               ih.drvd_alt_mail_addr_prim_flag,
               'N', REPLACE (
                         ih.subs_addr_1
                      || ' '
                      || ih.subs_addr_2
                      || ' '
                      || ih.subs_city
                      || ','
                      || ih.subs_state_code
                      || ' '
                      || ih.subs_zip_code,
               'Y', REPLACE (
                         ih.print_alt_mail_addr_line_1
                      || ' '
                      || ih.print_alt_mail_addr_line_2
                      || ' '
                      || ih.print_alt_mail_addr_line_3
                      || ' '
                      || ih.print_alt_mail_addr_line_4
                      || ' '
                      || ih.print_alt_mail_addr_line_5
                      || ' '
                      || ih.print_alt_mail_addr_line_6,
             ), -- HERE
             1,
             50
             address
    FROM   xRegards
    Peter

  • Sharepoint Workflow to change another item in the same library

    Is it possible to change another item in the current library using a sharepoint workflow
    I currently has a customised approval workflow that approves procedures. I would like this workflow to set the status of the previous version to archive when the current procedure is approved.
    Jack

    Hi Jack,
    If the documents in your library are all word files and the names of the documents are named as"A001_Rev_+number", you take follow the steps below to update the status column.
    Create a 2013 workflow associated with the library, and start the workflow when an item is created.
    Select Start a task process.
    Select If any value equals value and set it to be: If Variable: Outcome equals Approved.
    Select Extract Substring of String from Index with Length, and set it to be:Copy from Current Item:Name, starting at 0 for 9 characters(Output to Variable: substring).
    Select Set Workflow Variable and set it to be:Set Variable: string to Current Item:Name.
    Select Replace Substring in String and set it to be:Replace Variable: substring with (space) in Variable: string(Output to Variable: output).
    Select Do Calculation and set it to be:Calculate Variable: output to minus 1(Output to Variable: calc).
    Select Update List Item to update the status column(refer to the picture below).
    Select Go to a stage and set it to be:Go to End of Workflow.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Why does text field in InfoPath 2010 show user name with two commas between first name and last?

    Here's the problem. I have a text field called Manager in an InfoPath 2010 form that is getting populated by a drop down field called
    Business Unit.
    The Business Unit drop-down field is pulling information from
    column A in a custom list via a managed data connection. The custom List has two columns:
    Title & Manager. 
    The Manager column in the custom list is a 'Person or Group' type column.
    The Data Connection pulls both the Title, Manager
    (and ID) data.
    There is a rule on the Business Unit drop-down field to change the value of the
    Manager text field with the Manager data on the custom list. The rule pulls the
    Manager information and filters the value to match the
    Business Unit on the Data Connection with the Business Unit drop-down
    field value (Main).
    The Business Unit drop-down field works great and pulls the value from the custom list, and the rule populates the Manager text field. The problem is that Manager text field shows the name as such:
    [smith,, john]. Notice the two commas between the last and first name. There should only be
    one comma!
    Anyone have an idea why the text field is appearing with two commas?
    Arnel

    Hi all,
    I have a workaround for this. I have an InfoPath 2010 form pulling data from a SP2010 list. The user chooses a System (Business Unit) from the dropdown list and that choice auto populates the associated user (Manager) for that system. I had to
    use concatenation, substring before and substring after to display the correct data.
    concat(substring-before(DisplayName, ",, "), ", ", substring-after(DisplayName, ",, "))
    DisplayName is the original data for the field. I am able to cut & paste this field into the formula. Therefore, I added a few spaces to separate it from the actually formula for future use.
    Select Insert Function
    Select concat
    Select the first link to double-click to insert field
    and then select Insert Function
    Select the Text category and choose substring-before
    Select the third link to double-click to insert field
    and then select Insert Function
    Select the Text category and choose substring-after
    Copy and paste your fieldname (in my case DisplayName) in the
    double-click to insert field
    parts of the substring-before and substring-after links.
    Delete the middle double-click to insert field link
    Add quotes, spaces and commas so that they match the following format:
    concat(substring-before(DisplayName, ",, "), ", ", substring-after(DisplayName,
    Translation:
    concat(substring-before(Doe,, John, ",, "), ", ", substring-after(Doe,,
    John, ",, "))
    Bring together all of the text before ",," (i.e. Doe) with ", " (comma, space) and all text after ",," (i.e. John).
    It should return
    Doe, John.
    I hope this makes sense. I have these instructions with screenshots if you need them, contact me.

  • How to create index for Telecom large table

    Hi ,
    I'm working on DB 10G on REHL 5 for telecom company with more than 1 million recorded per day , we need to speed the query result ,
    we know there are many types of the INDEX and I'm need a professional advice to create a suitable one ,
    many of our queries depend on the MSID ( the MAC address of the Modem ) column ,
    Name           Null Type        
    STREAMNUMBER        NUMBER(9)   
    MSID                VARCHAR2(20)
    USERNAME            VARCHAR2(20)
    DOMAIN              VARCHAR2(20)
    USERIP              VARCHAR2(16)
    CORRELATION_ID      VARCHAR2(64)
    ACCOUNTREASON       NUMBER(3)   
    STARTTIME           VARCHAR2(14)
    PRIORTIME           VARCHAR2(14)
    CURTIME             VARCHAR2(14)
    SESSIONTIME         NUMBER(9)   
    SESSIONVOLUME       NUMBER(9)   
    .please any help ,

    really i have 3 queries for the subscriber activity like (usage details , the date of bundle start the the total of the download , he's working out of bundle or not )
    and any of the subscribers can check those queries at any time thorw web ,
    select nvl(min(substr(a.starttime,1,8)),0) Service_Start_Time, nvl(sum(a.sessionvolume),0) Total_Traffic_KB
    FROM aaa_bill a
    where msid='84A8E46E929D'
    and starttime >=(select  max(fee) FROM aaa_bill
    where msid='84A8E46E929D' and accountreason=5);and the expected result is
    service_start_date  totoal_traffic_KB
    20120225                   440554the MSIDs examples
    (84A8E46E7F43,
    84A8E46E7A82,
    84A8E46E7C84,
    84A8E46E7CBF,
    also i have this query ,
    select
    substr(nvl(
    (select nvl(starttime,'0') as starttime
    from (
    select nvl(starttime,0) starttime,sum(sessionvolume) over(partition by msid order by starttime) sum1
    from aaa_bill
    where msid='84A8E46E90BC' and starttime >=(select  max(fee) FROM aaa_bill
    where msid='84A8E46E90BC' and accountreason=5))
    where sum1>=44987000
    and rownum<2)
    ,0),1,8) Reached_45GB
    from dual;and this one ,
    select min(to_char(to_date(starttime,'yyyymmddhh24miss'),'yyyy-mm-dd hh24:mi:ss')) "Accounting Start Time",
    max(to_char(to_date(curtime,'yyyymmddhh24miss'),'yyyy-mm-dd hh24:mi:ss')) "Accounting Stop Time",sum(sessiontime) Duration1,
    TO_CHAR (TRUNC (SYSDATE) + NUMTODSINTERVAL (sum(sessiontime), 'second'),'hh24:mi:ss') hr,
    sum(sessionvolume) Traffic
    from aaa_bill
    where msid='84A8E46E78EF'
    and starttime >=(select  max(fee) FROM aaa_bill
    where msid='84A8E46E78EF' and accountreason=5)
    group by correlation_id
    order by min(starttime);

Maybe you are looking for

  • I have space on my ipod, but Itunes will not let me sync anymore photos

    I keep receiving this message from Itunes: Itunes will no longer sync photos to the ipod. Do you want to keep or remove photos previously synced to your ipod?

  • Aspect ratio out of whack...

    Hello, I find occasionally when I import a movie into Logic 9 the aspect ratio goes out of whack. The same clip opens fine in Quicktime. I can uncheck 'Keep Aspect Ratio' in the video settings and rough the ratio into something that looks normal agai

  • How to call a subvi with event controll?

    Hi:      I got a control vi written extensively by front panel events. I want to use it as a subvi,  can I  fire  a  event trigger programmably by anyway? Thanks

  • Leading Zero in Material Master

    Hi, I am trying to do a simple select query from MAR inside the BADI  imp of IDOC_CREATION_CHECK, i get the Material no from segment  E1MARAM of IDOC data  & fill this in work area  & use it Now in one environment, the material no is coming without l

  • CS5 Fireworks as crappy as all the CSs... help!

    First, Adobe apps are the only ones to freeze my 16GB, Phenom Black, 64-bit, 6TB, ATI Radeon HD 5970, twin 28" DVIs monitor computer. When Fireworks loads it would give the error 'Your user priviliges do not allow Fireworks to update your registry, L