Query to show the output using SUBSTR or REGEXP_SUBSTR

Hi All,
I need a help..
I want to populate the data from varchar2 column, if it has the value 1,2,3 stored in it.
Then I need to pick the values between the commas and show some string for each value available with commas.
For Example: for '1' I should show India.
For '2' I should show US.. etc.
Regards
Suresh

According to me, your algorithm should be as follows:
1) Create table dfntn which defines the relation between id and nm
e.g
id    nm
1     India
2     US
3     Other2) Develop generic code which splits the data of any given values..
e.g. 1,2,3 ...
changed to
id
1
2
3
.Now join this id with the dfntn. This way u will be maintaining more robust code.. i.e. even though your id assignment changes, u can control that in the table level itself.
Cheers,
Manik.

Similar Messages

  • Query to show the most useful Indexes in SQL?

    So I'm familiar with the Queries that show the Bad Indexes, but, is there a query I can run that shows which Indexes are the best, or, most used?
    This topic first appeared in the Spiceworks Community

    Hi ganesh,
    Thanks for response.
    but assumption is wrong.
    the values below 200 also needed and the values above 200(400,204) has to show 200 in the output of the report.
    format before the output of the query.
    james 400
    kitty   200
    jhones 180
    francy  204.
    Now my output has to show
    james 200
    kitty   200
    jhones 180
    francy  200.
    I hope you can understand better now.
    Thanks,
    James

  • Filter a Query Based on the Output of Another Query

    Is it possible to run a query based on the put put of another query? I have two queries. One query is based on GL Line items and shows the account assignemnt of postings where a customer has had a debt raised and it been credited to an account assignment e.g. Order, Cost Centre or Profit Centre. The other query is on an AR cube and that shows payment made. I want to bring these together to show the owners of the various account assignments to what extent customers have actually paid the debts that have been raised and credited to them. This I do as the source document of the CO doscument matches the allocation of the ar document. So I have a query that shows the CO journal and another query that shows payments. But I only want to show the payments in the second query for documents displayed in the first query (which can be restricted by period and fiscal year and the particular account assignment).

    Hi,
    This can be acheived by usign a replacement path variable.
    Create replacement pathe variables for those the filter values in the second report nneds tobe restricted from the first.
    Then in the properties of the varioable say replce by query result and input the first query name in it.
    Use these variables in teh filter section of the second report.
    Make sure the characteristics for which you created the replacement path variables are in teh row section of the first Query.
    Now on executing the second query you will have it filtered based on teh values of the first Query.
    Hope this helps.
    Regards.
    Shafi.

  • Submit a program and skip output or dont show the output (alv list)

    hi,
    is it possible to use the submit command and skip output or don't show the output (alv list) ?
    Regrads
    ertas

    Hi all,
    I get the message
    REPORT  ZTEST.
    DATA: jtab TYPE TABLE OF sbook,
          wa_jtab LIKE LINE OF jtab,
          jtab2 TYPE z_incident_li OCCURS 0 WITH HEADER LINE.
    submit Z_INCIDENT_LIST EXPORTING LIST TO MEMORY AND RETURN.
    IMPORT lt_incident_res TO  jtab2 FROM MEMORY ID 'table'.
    LOOP AT jtab2 .
      WRITE / jtab2-RECN.
    ENDLOOP.
    Runtime Errors         RAISE_EXCEPTION
    Date and Time          12.06.2008 17:54:00
    Short text
         Exception condition "CNTL_ERROR" raised.
    What happened?
         The current ABAP/4 program encountered an unexpected
         situation.
    Error analysis
         A RAISE statement in the program "CL_GUI_CONTROL================CP" rais
          exception
         condition "CNTL_ERROR".
         Since the exception was not intercepted by a superior
         program, processing was terminated.
         Short description of exception condition:
         For detailed documentation of the exception condition, use
         Transaction SE37 (Function Library). You can take the called
         function module from the display of active calls.

  • AppBuilder Application doesnt show the output

    Hi All,
      I am doing the sample application in AppBuilder, when i run the application it opens a new browser window but it doesnt show the output.
    this is the problem, how to resolve this?
    If any body come across this issue please help me.
    Regards,
    Sravanya

    Hi Sravanya K,
    There seems to be some compatibility issue with latest Chrome update. (All the other pre requisites have nt had any releases very recently)
    Last release of other Pre requisites :
    Node JS - 5th june 2014 ( Node.js ChangeLog )
    JDK - (its to be manually updated).
    APP Builder (appbuilder-1.0.1252.zip is the last release which happened a long time back )
    Google Chrome - Can find latest release logs in Chrome Releases and chrome has an Update almost everyday
    UI5 Liraries - As per OpenUI5 - Download  16 th July 2014 is the last release of Ui5 libraries.
    More over App builder does not need any internet connectivity to atleast run the sample applications / templates of SuperList,Chart. (so the issue might be internally in the system using these pre requisites )
    So i certainly doubt the Auto Update feature of Google Chrome , causing this issue.
    Though this currently have nt worked in latest version of chrome in my system , other major browsers are still supported .
    As a work around can suggest to work with other browsers.
    I also tried with Safari , Firefox and  safari  worked satisfactorily -
    (Chrome, Safari are recommended for App Builder ) (Firefox worked partially)
    attached is the screenshot of Sample Application running in Safari
    Regards
    Virinchy

  • MDX Query to show the latest product text again historical facts (Type 2 dimenion linking on Surrogate key and also Natural Key)

    I need to write a MDX query to show the latest product text again historical facts or a chosen product text in time. I can write this query in TSQL, but new to MDX.
    The way I do it in TSQL is joining two queries together on the Natural Key as opposed to the surrogate key.
    Can this be done in MDX. I know I could write two separate MDX queries, one which get the product text I wan and the other to get the measure with the actual product text and Natural Key, and use a lookup function in ssrs to show the two result sets I the
    same tablix by looking up the Natural Keys. But this should be able to be done in one query shouldn't it.
    In the dsv the fact knows to join to the dimension using the surrogate key.
    Thanks J

    Hi Jamster,
    According to your description, you want to write a query to show the latest product text, right?
    In MDX, we can use LastNonEmpty function to return the lastest member winth a dimension. LastNonEmpty is an aggregation function available in the Enterprise version of SQL Server. However, you can create your own with a little bit of recursive MDX. Here
    is a sample query for you reference.
    With Member Measures.LastHits as
    iif(isempty(Measures.Hits),
    ([Date].[Year Month Day].prevmember,
    Measures.LastHits
    ),Measures.Hits)
    Reference
    http://cwebbbi.wordpress.com/2011/03/24/last-ever-non-empty-a-new-fast-mdx-approach/
    http://richardlees.blogspot.com/2010/07/getting-last-non-empty-value.html
    If this is not what you want, please provide us the detail structure of your cube and the expected result, so that we can make further analysis and give you the exactly MDX query.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Creation of a Query to show the values for the current month and the last 12 months data.

    Dear All,
    Good day!
    I have to create a Query with the below requirement.
    I have to create a Query to show the values for the current month and the last 12 months data.
    Can you please guide me how to achieve this ??
    thank you,
    Regards,
    Hema

    Hema
    explain the exact problem..? as you mentioned you want to create query to show values for current month and last 12 months.. so I think you want to show values for 12 months from current data.. you can achive this by multiple way..
    you can have selection screen and field with date .. and restrict based on system current date and 12 months before or you can handle this at your target.. .. I mean there are multiple ways to restrict data by date range..
    for some more hints..
    http://www.forumtopics.com/busobj/viewtopic.php?t=34393&sid=7fba465d0463bf7ff5ec46c128754ed6
    http://businessintelligence.ittoolbox.com/groups/technical-functional/cognos8-l/how-to-display-last-12-months-in-report-based-on-todays-date-3231850
    http://scn.sap.com/thread/3217381
    search on SDN you will get many other ways..
    Thanks,
    Bhupesh

  • How to run the report and show the output in excel file

    salam
    how to run the report and show the output in excel file,
    how to run the report and print the o/p via printer
    how to run the report and send the o/p via mail
    thank u all

    Hi,
    There are Parameters DESTTYPE, DESFORMAT and DESNAME. You can set these parameters to get as you want.
    1) Output in Excel File
         ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'FILE');
         ADD_PARAMETER(PL_ID, 'DESFORMAT', TEXT_PARAMETER, 'DELIMITED');
         ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<file_name>.XLS');2) output to printer
         ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'PRINTER');
         ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<printer_name>');3) Email - Have to configure SMTP and all. ( i didn't checked it)
         ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'MAIL');
         ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<email_id>');Regards,
    Manu.
    If this answer is helpful or correct, please mark it. Thanks.

  • Can I get a query to get the output data like 4th column instead of 3rd col

    Can I get a query to get the output data like 4th column instead of 3rd column ?
    SQL&gt; select emp.deptno, empno, rownum from emp, dept where emp.deptno=dept.deptno;
    DEPTNO EMPNO ROWNUM
    10 7782 *1* *1*
    10 7839 *2* *2*
    10 7934 *3* *3*
    20 7369 *4* *1*
    20 7876 *5* *2*
    20 7902 *6* *3*
    20 7788 *7* *4*
    20 7566 *8* *5*
    30 7499 *9* *1*
    30 7698 *10* *2*
    30 7654 *11* *3*
    30 7900 *12* *4*
    30 7844 *13* *5*
    30 7521 *14* *6*
    14 rows selected.

    SQL> select emp.deptno, emp.empno,
      2    row_number() over(order by emp.deptno, emp.empno) rn,
      3    row_number() over(partition by emp.deptno order by emp.empno) dept_rn
      4  from emp, dept
      5  where emp.deptno=dept.deptno
      6  order by emp.deptno, emp.empno;
        DEPTNO      EMPNO         RN    DEPT_RN
            10       7782          1          1
            10       7839          2          2
            10       7934          3          3
            20       7369          4          1
            20       7566          5          2
            20       7788          6          3
            20       7876          7          4
            20       7902          8          5
            30       7499          9          1
            30       7521         10          2
            30       7654         11          3
            30       7698         12          4
            30       7844         13          5
            30       7900         14          6
    14 rows selected.Regards,
    Dima

  • Why does safari show the last used page when the Ipad is turned on again

    Why does Safari show the last used page when the IPad is next used?

    Read this article:  Open iOS Safari to a blank page, http://www.macworld.com/article/159303/2011/04/ios_safari_blank_page.html

  • Get the values using substr

    Hi All,
    i am a comma seperated values into a variable. below are the values.
    "1234567,3,124567,3,14"
    the length of the values can vary. eg the output can also be
    "123,3,124567,443,1224"
    I need to get each value and store it a separate variable. is it possible using substr..?
    Please help me out...

    Hi,
    Here's how you can split a delimited list into parts in Oracle 9:
    WITH     got_part_cnt     AS
         SELECT     pk
         ,     csv
         ,     1 + LENGTH (csv)
                - LENGTH (REPLACE (csv, ','))     AS part_cnt
         FROM     table_x
    ,     cntr     AS
         SELECT     LEVEL     AS n
         FROM     ( SELECT  MAX (part_cnt)     AS max_part_cnt
                FROM       got_part_cnt
         CONNECT BY     LEVEL <= max_part_cnt
    ,     got_pos          AS
         SELECT     p.pk
         ,     p.csv
         ,     c.n
         ,     INSTR ( ',' || p.csv
                    , 1
                    , c.n
                    )          AS start_pos
         ,     INSTR ( p.csv || ','
                    , 1
                    , c.n
                    )      AS end_pos
         FROM    got_part_cnt     p
         JOIN     cntr          c     ON     c.n     <= p.part_cnt
    SELECT       pk
    ,       csv
    ,       n
    ,       SUBSTR ( csv
                 , start_pos
               , end_pos - start_pos
               )               AS item
    FROM       got_pos
    ORDER BY  pk
    ,            n
    ;Pk is the primary key of table_x. If you don't need it, you can omit it.
    Of course, this will work in versions later than 9, but you wouldn't want to if you could use REGEXP_SUBSTR.

  • How do I show the output of a command called within a gui script

    I'm starting from scratch on a project I've been tasked with.  My intention is a quick down-and-dirty way to apply an image within winPE to apply a windows image to the machine I've booted to a usb drive loaded with winPE.
    Here's my start.  It's rough, but, I have to start somewhere.
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
    $objForm = New-Object System.Windows.Forms.Form
    $objForm.Text = "DISM"
    $objForm.Size = New-Object System.Drawing.Size(600,400)
    $objForm.AutoSizeMode = "GrowAndShrink"
    $objForm.StartPosition = "CenterScreen"
    $objForm.FormBorderStyle = "Fixed3D"
    $objForm.KeyPreview = $True
    Function do_DISM{
    $dism = "dism /apply-image /imagefile:D:\W7x86.wim /index:1 /applydir:C:\"
    Invoke-Expression $dism
    $DISMButton = New-Object System.Windows.Forms.Button
    $DISMButton.BackColor = "ButtonFace"
    $DISMButton.Location = New-Object System.Drawing.Size(12,27)
    $DISMButton.Size = New-Object System.Drawing.Size(120,25)
    $DISMButton.TabIndex = 1
    $DISMButton.Text = “Start DISM”
    $DISMButton.Add_Click({do_DISM})
    $objForm.Controls.Add($DISMButton)
    $objForm.Add_Shown({$objForm.Activate()})
    [void] $objForm.ShowDialog()
    Now, this does work, and it will in fact apply the windows image to c:\ which is what I need it to do.  But, I have a few quesitons.
    Am I correct to use "Invoke-Expression" in the function do_DISM to start the command?  According to technet's articles, yes, but, want to make sure I'm doing this the proper way, since I'm learning that calling Invoke-Expression isn't always
    the way to do things.
    Also, since this will be used by others in my group, I'm going to need to show some sort of progress report on how far along DISM is getting along, otherwise, 5 minutes into DISM running, some people are going to think nothing's happening, and just power
    down the computer no matter what I tell them.  I know that running DISM from the command line, it will show a progress bar that is adequate for what I'm needing.  Running the script above and clicking the button, it does run, but, all in the background
    with no progress indication.  Is there a way I can tell either in the function or when the function calls Invoke-Expression to run DISM, to open in a new command window which shows the live progress of the command running?
    Again, my disclaimer: VERY new to writing bits of code, and am trying my best here, so, thanks in advance for patience with me.

    That's exactly what I was looking for!  Thank you!
    Changed code to:
    $dism = "X:\Windows\System32\Cmd.exe /c start CMD /k dism /apply-image /imagefile:D:\W7x86.wim /index:1 /applydir:C:\"
    And voila, new window opened with the live output of dism.
    new... and have a glazed over look about my eyes to prove it...

  • Adhoc Query- problem with the output file format

    Hi Gurus,
    I have a problem in exporting the output of an adhoc query to Excel format.
    The menu option I chose to export the report data into Excel is List>Export>Spreadsheet.
    However,I think I've just pressed the wrong option to export my report and now I can't seem to change it from a HTML file option.
    Can anybody help me correct this output setting.
    Points assured for apt help...

    Hi Sushil,
    There are two ways to save the output in the excel format.
    As you have mentioned, you can use
    List -> Export-> Spreadsheet.
    Then select table. Now the output will open in a spreadsheet.
    The other way is
    List -> Export-> Local File
    Here you need to select the option spreadsheet. Then mention the path where you want the file to be stored. Also mention the format as .xls
    Hope this helps
    Regards,
    Brinda

  • How to Split the string using Substr and instr using loop condition

    Hi every body,
    I have below requirement.
    I need to split the string and append with single quotes('') followed by , (comma) and reassign entire values into another variable. so that i can use it where clause of update statement
    for example I am reciveing value as follows
    ALN varchar2(2000):=(12ERE-3MT-4Y,4IT-5O-SD,OP-K5-456,P04-SFS9-098,90P-SSF-334,3434-KJ4-O28,AS3-SFS0-J33,989-3KL-3434);
    Note: In the above variable i see 8 transactions, where as in real scenario i donot how many transaction i may recive.
    after modification i need above transactions should in below format
    ALTR Varchar2(2000):=('12ERE-3MT-4Y','4IT-5O-SD','OP-K5-456','P04-SFS9-098','90P-SSF-334','3434-KJ4-O28','AS3-SFS0-J33','989-3KL-3434');
    kindly help how to use substr and instr in normal loop or for loop or while loop while modifying the above transactions.
    Please help me to sort out this issue.
    Many Thanks.
    Edited by: user627525 on Dec 15, 2011 11:49 AM

    Try this - may not be the best way but...:
    create or replace type myTableType as table of varchar2(255)
    declare
    v_array mytabletype;
    v_new_str varchar2(4000);
    function str2tbl
             (p_str   in varchar2,
              p_delim in varchar2 default '.')
             return      myTableType
        as
            l_str        long default p_str || p_delim;
             l_n        number;
             l_data     myTableType := myTabletype();
        begin
            loop
                l_n := instr( l_str, p_delim );
                exit when (nvl(l_n,0) = 0);
                l_data.extend;
                l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
                l_str := substr( l_str, l_n+length(p_delim) );
            end loop;
            return l_data;
       end;
    begin
      v_array := str2tbl ('12ERE-3MT-4Y,4IT-5O-SD,OP-K5-456,P04-SFS9-098,90P-SSF-334,3434-KJ4-O28,AS3-SFS0-J33,989-3KL-3434', ',');
          FOR i IN 1 .. v_array.COUNT LOOP
             v_new_str := v_new_str || ''''||v_array(i)||'''' || ',';
          END LOOP;
       dbms_output.put_line(RTRIM(v_new_str, ','));
    end;  
    OUTPUT:
    =======
    '12ERE-3MT-4Y','4IT-5O-SD','OP-K5-456','P04-SFS9-098','90P-SSF-334','3434-KJ4-O28','AS3-SFS0-J33','989-3KL-3434'HTH
    Edited by: user130038 on Dec 15, 2011 12:11 PM

  • Query to show the values of Keyfigures with above 200(201,202.....) as 200

    Hi all,
    query has to show the values of keyfigures with above 200(201,202.....) as 200.
    for example
    james         200
    willy           180
    Jhones       450
    kiris            204 and so on.
    the values above 200 that is 450 204 has 200 in the query output.
    Thanks,
    James

    Hi ganesh,
    Thanks for response.
    but assumption is wrong.
    the values below 200 also needed and the values above 200(400,204) has to show 200 in the output of the report.
    format before the output of the query.
    james 400
    kitty   200
    jhones 180
    francy  204.
    Now my output has to show
    james 200
    kitty   200
    jhones 180
    francy  200.
    I hope you can understand better now.
    Thanks,
    James

Maybe you are looking for

  • How can I transfer iTunes library to a new Apple ID?

    I have a substantial quantity of music in iTunes on a old lap top. All the music has been put on to my iPod. None of it was purchased from iTunes but was uploaded from CD's. I have since moved from the UK to France with a new lap top and now have a n

  • ValueMappingReplication in PI 7.1

    Hello - We are on PI 71 and I am trying to create the Value mapping in RWB - >Cache Monitoring  by uploading  a CSV file from the local PI server  which has the value mapping information. I have configured this scenario and when the CSV file was pick

  • How do I know if my iPhone 4s is locked?

    Is there a way to tell if your iPhone 4S is locked or not? I bought it at the Apple store when it first came out.

  • Not enough memory error

    Hello, I'm using snow leopard system and in the last few weeks it is get stuck and slowly. I have 4GB of RAM. I'm using this computer for graphics (indesign, photoshop, iphoto, illustrator). Can you please help me to have a best performance? Thanks,

  • Every time Photoshop CS6 is updated it loses the ability to process RAW files

    I have had no trouble with PHotoshop CS6 for several years. Then I bought a copy of Dreamweaver CS6, which on installation destroyed all records of every other Adobe product that I have. It also stopped Photoshop CS6 from handling RAW files. So I rei