Parsing a column

I am using 11g
I have the following data_set.
Table consits of seq_no, order_key, model and sr_no. For Each order_key, there can be multiple seq_no, model and sr_no.
with data_Set as (
SELECT 105 SEQ_NO,    1240077 ORDER_KEY,    7018572 MODEL,    'ABCD|EFGH'  SR_NO FROM DUAL UNION ALL
SELECT 105,    1240077,    7018572,    'ABCD|EFGH' FROM DUAL UNION ALL
SELECT 107,    1240077,    7018574,    'XXXX|YYYY' FROM DUAL UNION ALL
SELECT 107,    1240077,    7018574,    'XXXX|YYYY' FROM DUAL UNION ALL
SELECT 999,    1240165,    7018569,    'AAA|BBB|CCC' FROM DUAL UNION ALL
SELECT 999,    1240165,    7018569,    'AAA|BBB|CCC' FROM DUAL UNION ALL
SELECT 999,    1240165,    7018569,    'AAA|BBB|CCC' FROM DUAL
) SELECT * FROM DATA_SET
In the above data set,
for order_key 1240077, model_no = 7018572,  SR_NO is 'ABCD|EFGH', on the result set, it need to be split into two 'ABCD' for line 1 and 'EFGH' for line 2
similarly, for order_key 1240077, model_no = 7018574, SR_NO = 'XXXX|YYYY' ,on the result set, it need to be split into two 'XXXX' for line 1 and 'YYYY' for line 2
and for order_key 1240165, SR_NO = 'AAA|BBB|CCC', on the result set, it need to be split into three, 'AAA' on line 1, 'BBB' on line 2 and 'CCC' on line 3
with RESULT_SET as (
SELECT 105 SEQ_NO,    1240077 ORDER_KEY,    7018572 MODEL,    'ABCD'  SR_NO FROM DUAL UNION ALL
SELECT 105,    1240077,    7018572,    'EFGH' FROM DUAL UNION ALL
SELECT 107,    1240077,    7018574,    'XXXX' FROM DUAL UNION ALL
SELECT 107,    1240077,    7018574,    'YYYY' FROM DUAL UNION ALL
SELECT 999,    1240165,    7018569,    'AAA' FROM DUAL UNION ALL
SELECT 999,    1240165,    7018569,    'BBB' FROM DUAL UNION ALL
SELECT 999,    1240165,    7018569,    'CCC' FROM DUAL
) SELECT * FROM RESULT_SET
I am trying this , but can't figure out.
SELECT seq_no, order_key, model,
            REGEXP_SUBSTR (NVL ( sr_no, LAG (sr_no)OVER ( PARTITION BY order_key ORDER BY 1)), '[^|]+' ) AS new_sr_no
FROM data_set a ORDER BY seq_no

Hi,
It looks like you were on the right track.
Depnding on your data and your requirements:
SELECT  seq_no, order_key, model
,       REGEXP_SUBSTR ( sr_no
                      , '[^|]+'
                      , 1
                      , ROW_NUMBER () OVER ( PARTITION BY  seq_no
                                             ,             order_key
                                             ,             model
                                             ORDER BY      NULL
                      ) AS sr_no
FROM    data_set

Similar Messages

  • How to parse XML Column and insert values into a table

    Hello,
    I am working on a simple project to demonstrate how to load and extract XML using SQL, I have already made a table that contains a column of XMLTYPE and loaded an XML file into it (code below)
    create or replace directory XMLSRC as 'C:\XMLSRC';
    drop table Inventory;
    create table Inventory(Inv XMLTYPE);
    INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
    select * from Inventory;
    I now however need to get the XML data back out of that and loaded into a new table. Troubleshooting guides I have read online seem to only be dealing with parsing an external XML document and loading it into a table, and not what I need to do which is parse a column of XML data and load that into a table. The project trivial with simple tables containing only 3 columns.
    The table that needs to be loaded is as follows:
    create table InventoryOut(PartNumber Number(10), QTY Number(10), WhLocation varchar2(500));
    The XML document is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
    <Inventory>
    <PartNumber>101</PartNumber>
    <QTY>12</QTY>
    <WhLocation>WA</WhLocation>
    </Inventory>
    </dataroot>
    Thank you for any help you can offer.

    First of all, thank you for your help!! Still stunned that you actually took the time to write out an eample using my tables/names/etc. Thank you!!
    Attached is the code, there seems to be an issue with referencing the other table, Inventory.Inv, I checked and that table and the Inv column are showing up in the database so I am not sure why it is having issues locating them, take a look at the code I wrote as well as the output (*I included the real version number for you this time :)
    EDIT: In your code right here:
    select xt.*
    3 from Inventory inve,
    4 XMLTable('/dataroot/Inventory'
    5 PASSING inve.Inv
    I think is where I am messing it up, perhaps not understanding fully what is going on, as you write "Inventory inve" and "inve.Inv" ---- Is inve a keyword that I am just not familiar with? I think this is where the issues lies in my code.
    END EDIT
    EDIT2: Well that looks like it was it, changed that to how you have it and it now works!!! Could you please explain what that few lines is doing, and what the xt.* and inve are doing? Thanks again!!!
    END EDIT2
    drop table InventoryOut;
    create table InventoryOut (PartNumber number(10), QTY number(10), WhLocation varchar2(500));
    insert into InventoryOut (PartNumber, QTY, WhLocation)
    select xt.*
    from Inventory Inv,
    XMLTable('/dataroot/Inventory'
    PASSING Inventory.Inv COLUMNS
    PartNumber number path 'PartNumber',
    QTY number path 'QTY',
    WhLocation path 'WhLocation')xt;
    select * from InventoryOut;
    select * from v$version;
    table INVENTORYOUT dropped.
    table INVENTORYOUT created.
    Error starting at line 4 in command:
    insert into InventoryOut (PartNumber, QTY, WhLocation)
    select xt.*
    from Inventory Inv,
    XMLTable('/dataroot/Inventory'
    PASSING Inventory.Inv COLUMNS
    PartNumber number path 'PartNumber',
    QTY number path 'QTY',
    WhLocation path 'WhLocation')xt
    Error at Command Line:8 Column:12
    Error report:
    SQL Error: ORA-00904: "INVENTORY"."INV": invalid identifier
    00904. 00000 - "%s: invalid identifier"
    *Cause:   
    *Action:
    PARTNUMBER QTY WHLOCATION
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE     11.2.0.1.0     Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    If this helps here is the code and output for the creation of the Inventory table itself:
    create or replace directory XMLSRC as 'C:\XMLSRC';
    drop table Inventory;
    create table Inventory(Inv XMLTYPE);
    INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
    select * from Inventory;
    directory XMLSRC created.
    table INVENTORY dropped.
    table INVENTORY created.
    1 rows inserted.
    INV
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
    <Inventory>
    <PartNumber>101</PartNumber>
    <QTY>12</QTY>
    <WhLocation>WA</WhLocation>
    </Inventory>
    </dataroot>
    Thanks again for your help so far! Hope we can get this working :)
    Edited by: 926502 on Apr 11, 2012 2:47 PM
    Edited by: 926502 on Apr 11, 2012 2:49 PM
    Edited by: 926502 on Apr 11, 2012 2:54 PM
    Edited by: 926502 on Apr 11, 2012 2:54 PM
    Updated issue to solved - Edited by: 926502 on Apr 11, 2012 2:55 PM

  • Parsing which columns used in a query

    Hi,
    i try to write my own advisor :-) I´m looking for a package that can help me to find out which columns a used in query in a codition
    Example:
    select 1 from emp
    where deptno=10
    and job='CLERK';
    => deptno and clerk
    I worked with col_usage$, but it seems not always correct, and it´s not updated when you zuse explain plan ...
    Does anybody know, how Oracle´s dbms_advisor/dbms_sqltune finds out which columns are used in a condition ?
    Thanks
    Marco

    mpatzwahl wrote:
    i try to write my own advisor :-)Oh dear, that is completely insane. Why not use the one provided?
    You would need to write a SQL parser.
    The language definition is here
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/toc.htm
    And don't forget that a function could be used in the condition so you will need to parse PL/SQL also
    http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm
    Try it out on something simple like this and see how far you get
    {message:id=1908539}
    SQL> create or replace function f1 return varchar2 as
      2  l_dummy dual.dummy%type;
      3  begin
      4    select dummy into l_dummy from dual;
      5    return l_dummy;
      6  end;
      7  /
    Function created.
    SQL> edi
    Wrote file afiedt.sql
      1  create or replace function f2 return varchar2 as
      2  begin
      3    return 'X';
      4* end;
    SQL> /
    Function created.
    SQL> create or replace view v as
      2  select
      3      dummy a,
      4      (select dummy from dual) b,
      5      f1 c,
      6      f2 d,
      7      'X' e
      8  from dual;
    View created.
    SQL> select * from v where c = 'X';
    A B C D E
    X X X X X

  • Iwork 09 Numbers Wildcard Parse for Column Cell Dat

    As a "Novice"
    I ran into a problem I cannot find the answer in PDF..maybe lack of examples..
    I have a table for "CT" data that has many rows imported via "CSV" sets
    I have a column that is called "Radiation Dose"..say AA:16
    In this cell, I want to extract and sum the "CTDIvol" data to another column cell (un-named)..say AD:16
    Data looks like this
    Example 1:
    Topogram: kV=120 mAs=130  CHEST: kV=120 mAs=1058 CTDIvol=6.84 DLP=84.82  CHEST: kV=120 mAs=1055 CTDIvol=6.84 DLP=84.82
    I only want the CTDIvol data and it summed for a total.
    I would like to do again as a seperate function for say AE:16 for "DLP"
    I will have to repeat this process for All rows....that are imported...
    How would I even attempt to to this??
    Thanx you...remember..I am a novice and show and tell works best for me...otherwise..I will be lost..

    If the order of data is always the same I would doctor the data before importing to remove all the extra stuff that is not numerical values.  e.g.  I would change:
    Topogram: kV=120 mAs=130  CHEST: kV=120 mAs=1058 CTDIvol=6.84 DLP=84.82  CHEST: kV=120 mAs=1055 CTDIvol=6.84 DLP=84.82
    to:
    Topogram: kV, mAs, CHEST: kV, mAs, CTDIvol, DLP, CHEST: kV, mAs, CTDIvol, DLP
    120, 130, 120, 1058, 6.84, 84.82, 120, 1055, 6.84, 84.82
    For a Numbers solution I would make an table where you paste your CT data and another one the parses out the fields with an area where you can copy the parsed data.  Something like:
    What I am showing is:
    your original row of data followed by the character location of the equal signs (just count characters starting at the left until you find an equal sign) followed by the location of the space following the equal sign.  followed by the parsed values.
    once you know where the "=" and " " are you can pick out the charaters between them... that take characters from:
    Character location of "=" + 1 to the next space.
    So the formulas are:
    B1=SEARCH("=", A1, 1)+1
    C1=SEARCH("=", $A$1, B1+1)+1
    select C1 and fill to the right until K1
    M1=SEARCH("=", $A$1, B1+1)+1
    select M1 and fill to right until U1
    V1=LEN(A1)+1
    X1=MID($A$1, B1,M1-B1)
    select X1 and fill to the right until AG1
    X1 thru AG1 are the numerical values
    you can now copy them to another location by select the range you want then select the destination cell, and select the menu item "Edit > Paste Values"
    I hope this helps

  • Parsing Column Value. SQL / Stored Proc/ Function ?

    Hi,
    I just started writing SQL. Need your valuable input for the following query,
    Need to query a table and parse a column to produce a desired output.
    like suppose my column value is
    #ADFA
    /SDFGAS
    {ABC}: 123
    {BCA}: 456
    {DEF}: 789
    and i need to get an out put as follows
    {ABC} {BCA} {DEF}
    123 456 789
    so the patterns are defined.
    I some how tried and reached through SQL, but there should be better way than this. So posted this question.
    I tried using SQL itself (using substr, instr & decode functions in the select statement)... with out using stored proc/ function as i have not created one earlier.. I am just learning the syntax and trying it.
    The psuedo code i have planned is
    function substring(column_value, search_string)
    var start_index NUMBER;
    var end_index NUMBER;
    var result VARCHAR2;
    result = 'N/A';
    start_index = instr(column_value, search_string) + 4
    if start_index >= 4
    end_index = instr(substr(column_value, 0, start_index), CHR(13)-1)
    if start_index >= 4 && end_index >=0
    result = substr(column_value, start_index, end_index);
    return result;
    I just wrote it like writing in a programming language. Need to implement this through Stored Proc/ Function. Please let me know your comment on this

    Oops, I think regular expressions are not available in my current oracle version :-(
    I am having Oracle 9i.
    Got it.. Yes it is available from 10G onwards.. :-(
    Message was edited by:
    Thiru.Thiru

  • Parsing an xml document inside a Thread

    Hi Friends
    I have to do some processing in my application for which i need to use multithreading.
    Inside every new thread created i have to parse an xml document using s parsing tool like castor or jibx.
    My question is that is it possible to parse a xml document inside a new thread everytime it gets created.
    is it a good coding practice as it involves java code to do it.
    Thanks
    Vikeng

    vikeng wrote:
    Hi
    Thanks for the reply.
    Well i need to do some kind of a batch processing in my application.
    I need to parse an xml document and upload the data i get after parsing into columns in the database.
    Since its a batch what i was asking was is it possible to do it for every request as batch needs to handle hundreds of records during the daily or nightly sync.
    Is it a good practice to do parsing for every record in a batch
    Thanks
    VikengI don't get it. One batch is one document, and that document contains e.g. 100 records? What's one request? A request for one batch? I would execute one batch in one thread.
    Kaj

  • Custom HTML or JS in Column Headers in Answers

    All,
    I am primarily a web developer, but a co-worker asked me how a site was doing a particular effect (they had set the title parameter of a node, and it was showing up like a tooltip). He wanted to set it up on the column header of an Answer, so that when a user scrolled over it, it would display some metadata about the field. I said it should be really easy to do.....
    So after a day of reading up on Seibel/Oracle Analytics, I'm about ready to strangle the developers.
    I had assumed (apparently incorrectly), that I could set the column header text, and just include an html element with the title set. Simple enough, after that didn't work (it never parses the HTML, it just renders it as character entities). I thought, surely it would be an easy task to track down the actual html templates that were being used to generate those tables. No such luck there either.
    Ideally, I'd like to edit the "advanced" tab report xml, and just say something like:
    <saw:title>My Tooltip Title</saw:title>
    but I can't find any documentation on that XML document format.
    Surely though, the original developers did not embed HTML table info inside the magical mystical saw.dll....
    Any help would be much appreciated.
    Thanks in advance,
    James

    Update:
    This is interesting. So when my coworker asked me how get the tooltip effect, I said it was super straight forward. All they had to do was something like:
    &lt;span title="My tooltip"&gt;My Column Header&lt;/span&gt;
    And it would work. After trying all kinds of HTML, I despaired of a simple fix.
    Then we set the HardenXSS flag to false in the server instance config file, and I tried that exact code again. It still was not parsing the column header correctly. Then one of my other coworkers, tells me that he put a line break tag in, and it rendered the break.
    o.O
    So I tried the following:
    &lt;b title="My tooltip"&gt;My Column Header&lt;/b&gt;
    Which of course worked. Why is span being discriminated against? I have no idea.
    So basically, for column header tooltips, disable XSS hardening, and use a bold tag. (why bold? it was the first thing that came to mind, and since the default font-weight of a table header is bold, it should be practically unnoticable).
    The next question is, what exactly is the impact of disabling the HardenXSS. I'm not sure if it allows certain HTML elements only, or if it allows any HTML (or more to the point the script tags). I wonder if anyone has done a vulnerability assesment of having hardening turned off.
    --james
    Message was edited by:
    jholder
    Message was edited by:
    jholder
    Fixed html entities

  • Xml data source in db column?

    Hi everybody
    If I want to use XML data as data source for BI Publisher, can these data be stored in a database column
    or do I have to store the source data in XML files in a file system?
    If it can be stored in a db column - is there anything I need to consider in terms of defining the data source and building the data model?
    Thanks
    Regards
    Andy

    can these data be stored in a database column
    or do I have to store the source data in XML files in a file system?
    yes
    data can be stored in
    1) table column as xmltype or clob or blob or .....
    so you can parse this column in some way by xquery or xmltable or ...
    2) as os file
    processing by bfilename like
    xmltype( bfilename('GET_XML', xmlfilename.xml))

  • Create SSIS Import parsing based on text file...

    I have a text file listing 500 field names and their lengths.  (In a few months we will begin receiving monthly data files matching that schema). I can create an SSIS 2008 project and manually parse the columns (inside SSIS)  to match that
    schema but I wonder if there is an easier way to do what I want (e.g. if I created a table using t-sql commands could SSIS somehow "pickup" the SSIS parsing from the table schema?)
    TIA,
    edm2

    Not exactly. What I was hoping for is that instead of pointing SSIS to the data file and manually parsing all the fields that  I could create an (empty) table with the right schema and have SSIS use that table schema to define how it should
    parse the input data. (Kind of backwards from the usual approach.)
    edm2
    Sorry you cant parse text file for metadata like that as metadata has to fixed in SSIS
    However one way you can implement this is as follows
    1. Create your table with required schema
    2. In SSIS have a data flow task with flat file source which points to your file. Choose only a row delimiter and no column delimiter
    3. Put a oledb destination and point to staging table with an identity column
    4. Put a Execute SQL Task  with query as below
    SELECT CASE WHEN (SELECT Column FROM Staging WHERE IDCol=1) = STUFF((SELECT ',' + COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'Your schema table name'
    AND TABLE_SCHEMA = 'dbo'
    FOR XML PATH('')),1,1,'')
    THEN 0
    ELSE 1
    END AS SchemaDiff
    FROM (SELECT 1)t
    Then map SchemaDiff column in the resultset to a boolean variable created in ssis. Also make sure you set resultset option to single row
    Then you can use this boolean variable to check if schema is same. If False means no difference in schema else there's difference.
    just a caution thar this will only compare column details without comparing their datatypes,lengths etc
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Parse a String with FIRSTNAME MI and LASTNAME but not always a MI

    Anyone,
    can I write a single clause to parse a column that cotains first name, middle initial and Last name but the Middle initial is sometimes there and sometimes not?
    Like this:
    Steven F Abbott
    Mikel Allums (Steve)
    Pedro A Arroyo
    Daniel R. Hasbrook
    Steve G Ball
    Ernie C Bloecher
    Richard Carrillo
    James M Chamberlain
    I need data seperated.
    I have:
    SUBSTR(NAME, 1, (INSTR(NAME,' ',1,1)-1)) "FIRST_NAME",
    SUBSTR(NAME,(INSTR(NAME,' ',1,1)+1), LENGTH(NAME)) "LAST_NAME",
    But that middle initial presents problems and I see it as first letter in last name but if I chnage the search for space to second occurance I get the whole name:
    SUBSTR(NAME,(INSTR(NAME,' ',1,2)+1), LENGTH(NAME)) "LAST_NAME",
    Any help would be greatly appreciated.
    Thanks,
    Miller

    may this eaxmple is little better if there is only one name then will display as first anem only
    SQL> WITH T AS
      2       (
      3          SELECT 'john smith' col1  FROM DUAL
      4          UNION ALL
      5          SELECT 'Derick R Alias' FROM DUAL
      6          UNION ALL
      7          SELECT 'Michel M john'  FROM DUAL
      8          UNION ALL
      9          SELECT 'Kiren'  FROM DUAL)
    10  SELECT (CASE
    11             WHEN INSTR (col1, ' ') = 0
    12                THEN col1
    13             ELSE SUBSTR (col1, 1, INSTR (col1, ' ') - 1)
    14          END
    15         ) first_name,
    16         CASE
    17            WHEN INSTR (col1, ' ', 1, 2) > 0
    18               THEN SUBSTR (col1, INSTR (col1, ' '), 2)
    19            ELSE NULL
    20         END middle_name,
    21         (CASE
    22             WHEN INSTR (col1, ' ', 1, 2) > 0
    23                THEN SUBSTR (col1, INSTR (col1, ' ', 1, 2) + 1)
    24             WHEN INSTR (col1, ' ') = 0
    25                THEN NULL
    26             ELSE SUBSTR (col1, INSTR (col1, ' ') + 1)
    27          END
    28         ) last_name
    29    FROM T;
    FIRST_NAME     MI LAST_NAME
    john              smith
    Derick          R Alias
    Michel          M john
    Kiren

  • How to clone data with in Table with dynamic 'n' number of columns

    Hi All,
    I've a table with syntax,
    create table Temp (id number primary key, name varchar2(10), partner varchar2(10), info varchar2(20));
    And with data like
    insert itno temp values (sequence.nextval, 'test', 'p1', 'info for p1');
    insert into temp values (sequence.nextval, 'test', 'p2', 'info for p2');
    And now, i need to clone the data in TEMP table of name 'test' for new name 'test1' and here is my script,
    insert into Temp  select sequence.nextval id, 'test1' name, partner, info from TEMP where name='test1';
    this query executed successfully and able to insert records.
    The PROBLEM is,
    if some new columns added in TEMP table, need to update this query.
    How to clone the data with in the table for *'n' number of columns and*
    some columns with dynamic data and remaining columns as source data.
    Thanks & Regards
    PavanPinnu.
    Edited by: pavankumargupta on Apr 30, 2009 10:37 AM

    Hi,
    Thanks for the quick reply.
    My Scenario, is we have a Game Details table. When ever some Game get cloned, we need to add new records in to that Table for the new Game.
    As, the id will be primary key, this should populate from a Sequence (in our system, we used this) and Game Name will be new Game Name. And data for other columns should be same as Parent Game.
    when ever business needs changes, there will be some addition of new columns in Table.
    And with the existing query,
    insert into Temp (id, name, partner, info) select sequence.nextval id, 'test1' name, partner, info from TEMP where name='test'_
    will successfully add new rows but new added columns will have empty data.
    so, is there any way to do this, i mean, some columns with sequence values and other columns with existing values.
    One way, we can do is, get ResultSet MetaData (i'm using Java), and parse the columns. prepare a query in required format.
    I'm looking for alternative ways in query format in SQL.
    Thanks & Regards
    PavanPinnu.
    Edited by: pavankumargupta on Apr 30, 2009 11:05 AM
    Edited by: pavankumargupta on Apr 30, 2009 11:05 AM

  • Parse Excel File via PowerShell for a loop

    Hello everyone,
    I would like to parse a column of one of my Excel file to retrieve the string that each of its cell can contain.
    This will be used to set the appropriate value of the UPN of users in a specific OU in Active Directory.
    The first column being the SAMAccountName and the second column the email address, I would like a loop that for each match of SAMAccountName it finds in the first column, it sets the value of associated row in the second column as its UPN.
    I know already the Active Directory cmdlets I would have to use, they works but I do not succeed retrieving data  like I would like from the Excel file.
    If someone could help me out on this that will be appreciated :)
    Thanks a lot.

    Hi,
    This might help:
    http://gallery.technet.microsoft.com/scriptcenter/7b2fdc8f-a528-4f19-b9ef-f5af349dc906
    I haven't used this module myself, so I'm not sure how well it works.
    Don't retire TechNet! -
    (Don't give up yet - 12,700+ strong and growing)

  • XML Structure in XML Component

    Hi,
    I'm trying to build an XML component in Portal 9.0.2.
    What I need to know is the structure of the XML generated by SQL placed inside the <ORACLE> tags so I can parse it with the XSL style sheet.
    All the examples I've seen (about 2) show the sql coming out in one lump in a table, but I want to be able to parse individual columns from the SQL. All I seem to get is a default presentation of the data.
    Any Ideas ?

    Hi,
    This is not possible currently. There is an enhancement filed for this.
    Thanks,
    Sharmila

  • Dynamic PL/SQL & substr, instr function

    I am having trouble with incorporating the SUBSTR and INSTR functions into my dynamic PL/SQL procedure using Oracle 8i.
    I have data that is packed into one column seperated by a delimiter (':')
    I need to seperate the data to use indicidual pieces.
    If I run my query in general -
    select substr(secondcol, 1, instr(secondcol, ':',1,1)-1) ONE,
    substr(secondcol,instr(secondcol, ':',1,1)+1,instr(secondcol, ':',1,1)-1) TWO,
    substr(secondcol,instr(secondcol, ':',1,2)+1,instr(secondcol, ':',1,1)-1) THREE,
    substr(secondcol,instr(secondcol, ':',1,3)+1,instr(secondcol, ':',1,1)-1) FOUR
    from temp_table where firstcol=100
    This works and gives me the right result.
    e.g
    DATA :
    Firstcol SECONDCOL
    100 1:2:3:4
    Result:
    ONE TWO THREE FOUR
    1 2 3 4
    However to make this generic if I use it in a function passing it a parameter which has ':' delimited data it does not work and gives me errors. All I want is to get the output as a string that looks like my query above so I can use it in my proc.
    create or replace function MYJUNK(TFieldNew IN CHAR)
    RETURN CHAR IS
    UpdateString Varchar2(100);
    BEGIN
    UpdateString := 'First=substr('||TFieldNew||', 1, instr('||TFieldNew||', '':'',1,1)-1) ONE, ';
    UpdateString := UpdateString || ' Second=substr('||TFieldNew||', instr('||TFieldNew||', '':'',1,2)+1, instr('||TFieldNew||', '':'',1,1)-1) TWO, ';
    UpdateString := UpdateString || ' third=substr('||TFieldNew||', instr('||TFieldNew||', '':'',1,3)+1, instr('||TFieldNew||', '':'',1,1)-1) THREE from temp_table';
    return UpdateString;
    END;
    The function compiles but gives me run time errors
    This is what I get -
    SQL> select myjunk('''1:2:3:4''') from dual;
    select myjunk('''1:2:3:4''') from dual
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "SGHDTA.MYJUNK", line 8
    ORA-06512: at line 1

    You are getting an error because updatestring is longer than the 100 characters you defined it as. Try using VARCHAR2(4000). Also, if you are trying to generate the sql statement, you need to get rid of first=, second= and third= when you build the string.
    This is what your function returns. I put in line breaks for clarity:
    First=substr('1:2:3:4', 1, instr('1:2:3:4', ':',1,1)-1) ONE,
    Second=substr('1:2:3:4', instr('1:2:3:4', ':',1,2)+1, instr('1:2:3:4',':',1,1)-1) TWO, 
    third=substr('1:2:3:4', instr('1:2:3:4', ':',1,3)+1,instr('1:2:3:4', ':',1,1)-1) THREE
    from temp_tableIf you are trying to actually parse the column, then you need something more like:
    create or replace procedure MYJUNK(TFieldNew IN VARCHAR2,out1 OUT VARCHAR2,
                                       out2 OUT VARCHAR2, out3 OUT VARCHAR2) is
    BEGIN
       out1 := SUBSTR(TFieldNew,1, INSTR(TFieldNew,':',1,1)-1);
       out2 := SUBSTR(TFieldNew, INSTR(TFieldNew,':',1,2)+1, INSTR(TFieldNew,':',1,1)-1);
       out3 := SUBSTR(, INSTR(TFieldNew,':',1,3)+1, INSTR(TFieldNew,':',1,1)-1);
    END;

  • Troubleshooting 9.3.1 Data Load

    I am having a problem with a data load into Essbase 9.3.1 from a flat, pipe-delimited text file, loading via a load rule. I can see an explicit record in the file but the results on that record are not showing up in the database.
    * I made a special one-off file with the singular record in question and the data loads properly and is reflected in the database. The record itself seems to parse properly for load.
    * I have searched the entire big file (230Mb) for the same member combination, but only come up with this one record, so it does not appear to be a "last value in wins" issue.
    * Most other data (610k+ rows) appears to be loading properly, so the fields, in general, are being properly parsed out in the load rule. Additionally, months of a given item are on separate rows, and other rows of the same item are loading properly and being reflected in the database. As well as other items are being loaded properly in the months where this data loads to, so, it is not a metadata-not-existing issue.
    * The load is 100% successful according to the non-existent error file. Also, loading the file interactively results in the file showing up under "loaded successfully" (no errors).
    NOTE:
    The file's last column does contain item descriptions which may include special characters including periods and quotes and other special characters. The load rule moves the description field to the earlier in the columns, but the file itself has it last.
    QUESTION:
    Is it possible that the a special character (quote??) in a preceding record is causing the field parsing to include the CR/LF, and therefore the next record, into one record? I keep thinking that if the record seems to fine alone, but is not fine where it sits amongst other records, that it may have to do with preceding or subsequent records.
    THOUGHTS??

    Thanks Glenn. I was too busy looking for explicit members that I neglected thinking through implicit members. I guess I was thinking that implied members don't work if you have a rules file that parses out columns...that a missing member would just error out a record instead of using the last known value. In fact, I thought that (last known value) only worked if you didn't use a load rule.
    I would prefer some switch in Essbase that requires keys in all fields in a load rule or allows last known value.

Maybe you are looking for

  • How to determine patch bundle level?

    Hi, there, Newb to Exadata here (apologies if this is obvious). We're looking to upgrade our Exadata machine (v2) from 11.2.0.1 to 11.2.0.2 and we need to know which patch bundle we're currently on. I tried figuring it out myself and I can't find how

  • Pdf file viewing (purple border)

    hi guys , this may be a silly question , but when i save a PDF file from Illustrator and view it on a folder say in Photoshop or Illustrator itself, i get a purple/pink border on top and bottom of the design document which its very handy for identify

  • LV2011 64-bit install error

    I just downloaded the installer for Labview 2011 64 bit from http://search.ni.com/nisearch/app/main/p/ap/tech/lang/en/pg/1/sn/n8:28,ssnavdl/# (the below version). LabVIEW Development System 2011 English Windows Server 2008 R2 / 7 / Vista - 64-bit 201

  • (Can't load tod module) Program terminated ?

    Hi I have a NetraX1 500 mhz, and i reinstalled Solaris 8. Now when I boot up I get this error: Executing last command: boot Boot device: disk File and args: SunOS Release 5.8 Version Generic_108528-07 64-bit Copyright 1983-2001 Sun Microsystems, Inc.

  • Spotlight + help menu -- crashes any programs

    Has anyone else had a program crash when opening/typing into the Leopard help menu? I figured out the other day that if you accidentally open Spotlight when you have the help menu open, whatever program you're currently using will crash. It's very an