Mapping repeated (identical) elements to SQL columns based on element attribute

Given this XML data, is it possible to generate the table shown?  If it's relatively easy, could someone please demonstrate.  If it's involved, then just suggesting references which are pertinent to solving this particular problem
would be greatly appreciated.  I am coming up dry in researching how one might accomplish this transformation.  OPENXML seemed capable of this - and, I have generated many different tables from this data using OPENXML.  But,
I cannot see how to generate this one.
<ROOT>
<listitem>
<variable name="Id">1</variable>
<variable name="Src">10.10.10.23</variable>
<variable name="Dst">192.168.99.7</variable>
<variable name="Service">NetBIOS-NS </variable>
<variable name="ValidTime"></variable>
</listitem>
<listitem>
<variable name="Id">8</variable>
<variable name="Color">4</variable>
<variable name="Src">10.0.0.3</variable>
<variable name="Dst">172.22.39.4</variable>
<variable name="Service">FTP </variable>
</listitem>
</ROOT>
Id Color Src Dst Service ValidTime
1 NULL 10.10.10.23 192.168.99.7 NetBIOS-NS NULL
8 4 10.0.0.3 172.22.39.4 FTP NULL

Hi ,
Minor modification to Dan's query:
SELECT
listitem.value('variable[@name="Id"][1]', 'int') AS Id
,listitem.value('variable[@name="Color"][1]', 'int') AS Color
,listitem.value('variable[@name="Src"][1]', 'varchar(15)') AS Src
,listitem.value('variable[@name="Dst"][1]', 'varchar(15)') AS Dst
,listitem.value('variable[@name="Service"][1]', 'varchar(30)') AS Service
,CASE WHEN listitem.value('variable[@name="ValidTime"][1]', 'varchar(20)') = ''
THEN NULL
ELSE listitem.value('variable[@name="ValidTime"][1]', 'varchar(20)')
END AS ValidTime
FROM @xml.nodes('ROOT/listitem') AS ROOT(listitem)
Refer below links for better understanding on XML shedding:
http://blogs.msdn.com/b/simonince/archive/2009/04/24/flattening-xml-data-in-sql-server.aspx
http://technet.microsoft.com/en-us/library/ms190798.aspx
http://stackoverflow.com/questions/61233/the-best-way-to-shred-xml-data-into-sql-server-database-columns
http://www.allaboutmssql.com/2013/10/sql-server-different-ways-to-shred-xml.html
sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.

Similar Messages

  • XML Gateway Mapping of XML Element Attribute

    Hi:
    If an inbound XML message contains this tag:
    <STATUS CODE="100"></STATUS>
    is it possible to map the CODE attribute to a database column?
    I've been attempting to do this but I'm receiving this error: Element STATUS not complete, expected elements ''.
    Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I'll answer my own question here.  Found the section in the XML User Guide about mapping HTTP Error Responses (chapter 22 in the v6.1 pdf) and realized that the XML gateway had preconfigured settings to handle various error conditions.  Edited the error handling configuration for the specific Handler (rather than the global setting) and checked the box to allow the error to pass through the XML gateway.  Redeployed the subpolicy.

  • Mapping a value to a key column

    Hi,
    I need some information in understanding the 2nd point from below
    "2. UPDATE statement changes City from SF to LA on the source. This does not succeed on the
    target. The SQLEXEC query looks up the City column in TCUSTMER1 and returns a value of
    LA. Based on the COLMAP clause, the before and after versions of City both are now LA.
    This leads to SQL error 1403 when executing the target WHERE clause, because a value
    of LA does not exist for the City column in the target table."
    I am unable to follow what exactly it states.
    Can some one explain with a good example?
    Reference:
    Mapping a value to a key column
    If using COLMAP to map a value to a key column (which causes the operation to become a
    primary key update), the WHERE clause that Oracle GoldenGate uses to locate the target row
    will not use the correct before image of the key column. Instead, it will use the after image.
    This will cause errors if you are using any functions based on that key column, such as a
    SQLEXEC statement.
    The following illustrates what happens:
    This is the SQLEXEC statement in the MAP statement:
    SQLEXEC (id mytest, query "select city from TCUSTMER1 WHERE state = 'CA'",
    noparams, ERROR RAISE),
    This is the COLMAP statement in the MAP statement:
    COLMAP ( usedefaults, city = mytest.city );
    This is the sequence of events:
    1. INSERT statement inserts the following:
    INSERT into TCUSTMER1 values (Cust = ‘1234’, Name = ‘Ace’, City = ‘SF’,
    State = ‘CA);
    Commit;
    This succeeds, because the SQLEXEC query will return mytest.city = ‘SF, so the target table
    also will have a value of SF for City and CA for State.
    2. UPDATE statement changes City from SF to LA on the source. This does not succeed on the
    target. The SQLEXEC query looks up the City column in TCUSTMER1 and returns a value of
    LA. Based on the COLMAP clause, the before and after versions of City both are now LA.
    This leads to SQL error 1403 when executing the target WHERE clause, because a value
    of LA does not exist for the City column in the target table.

    user582604 wrote:
    I am unable to follow what exactly it states.Join the club. The description is admittedly a bit complicated to follow, but it's unlikely that you're actually experiencing a problem related to this.
    It's just saying (as far as i can tell) either don't do a pk (primary key) update.... or (presumably) if you must do a pk update, do not also try at the same time to map the pk column to the result of some GG function (e.g., a sqlexec). When you have a replicat map "colmap(usedefaults, pk=sqlexec.result)", then the "where" clause constructed to perform the pk update on the target DB will use the new, updated ("after") value of the pk, and not the old, original ("before") value. Therefore the row won't be found on the target, since the pk has not actually been updated yet.
    (To paraphrase, the docs could have just said: "See this? Don't do that.")

  • How to pass multiple parameters while calling a pl/sql procedure based serv

    Hi,
    I have a pl/sql procedure based service that needs to be invoked from the bpel console for testing purpose. This procedure accepts multiple input values which are of varchar2,boolean and datetime data types. How can I get the bpel console to throw a UI where I can enter these values --in other words where(which file and where) can I specify that these are the input parameters that need to be entered along with their types.
    Thanks for yr help!

    Change the payload of the request 'Process WSDL' message type. Change the element of the payload for the RequestMessage to be 'InputParameters' from the XSD generated by the DB Adapter wizard.
    Edit the payload (Element) - Choose 'Project Schema Files'. Select 'InputParameters' from the XSD.
    You can also change the ResponseMessage by doing the same thing, except that you select 'OutputParameters' from the XSD.

  • Include Button that executes PL/SQL procedure to SQL query based region

    I would like to add two columns to a SQL query region.
    These columns would not be sourced from the query, but rather would be used to execute a PL/SQL procedure.
    For example, I would like to have a manager approve or deny adding an additional employee to the department.
    There would be one button for APPROVE. And, one button for DENY.
    The PL/SQL procedure would execute to perform the required DML based upon the selected action (either APPROVE or DENY).
    A sample output would look like this:
    <APPROVE>, <DENY>, John Doe, Accountant
    <APPROVE>, <DENY>, Jane Doe, Accountant
    Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?
    Thanks!
    -Reid

    Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?Conditional page item? You can associate processes with buttons on a page

  • Out of memory Error while querying SQL Script based Calculation View

    Hi All,
    I wanted to test the performance of Graphical and SQL Script based Calculation views.
    Created Graphical (CA_GRPH) and SQL Script (CA_SQL) Calculation views.
    Analytic View (AN_GRPH) for both Calculation views are the same which is Graphical based (90 Attributes and 5 Measures)
    In Analytic View data foundation I have a Fact table which has 1.5 Billion records and 9 Dimension Tables –collectively 500 million records (7 Attribute Views). 9 Referential joins with cardinality N:1 and 1 Referential join with cardinality N:N.
    I wanted to keep (CA_GRPH) and (CA_SQL) as a base Calculation views and leverage those to create various calculation views (Will be creating different Calc views for respective Business segments)
    In order to test this I have created below calc views on top of base calc views.
    Graphical Based: Created (CA_GRAPH_XYZ) by having CA_GRPH in projection with 30 Calculated Columns. – This retrieves data in 13 secs
    SQL Script Based: Created (CA_GRPH_ABC) by having CA_SQL in projection view with 30 calculated columns – This errors out after 1.50 mins.
    Could not execute 'SELECT "COLUMN_A","COLUMN _B"," COLUMN _C"," COLUMN _D", SUM("COLUMN _REVENUE") AS ...' in 1:50.480 minutes .
    SAP DBTech JDBC: [2048]: column store error:  [2048] column store error: search table error: [1000002] Error executing physical plan: exception 1000002:
    ltt/impl/memory.cpp:63
    Out of memory ; $size$=1507711; $name$=ihm; $type$=pool; $inuse_count$=170104; $allocated_size$=219215007925
    exception 1000002:
    Any suggestion / help in fixing this issue will be greatly appreciated.
    Regards,
    Av

    Hi Raj,
    Thanks for your time, please find edited snap hot of Analytic View (AN_GRPH) below,
    Calculation view(CA_SQL)
            /********* Begin Procedure Script ************/
    BEGIN
           var_out =
         SELECT
                "COLUMN_1"
                "COLUMN_2",
                "COLUMN_84",
                "COLUMN_85;",
                SUM("REVN") AS "REVN",
                SUM("MGN") AS "MGN",
                SUM("ORD_QTY") AS "ORD_QTY",
                SUM("SYS_QTY1") AS "SYS_QTY1",
                SUM("SYS_QTY") AS "SYS_QTY"
    FROM
          "_SYS_BIC"."XYZ/AN_GRPH"
    GROUP BY
                "COLUMN_1"
                "COLUMN_2",
                "COLUMN_84",
                "COLUMN_85";
    END
    /********* End Procedure Script ************/
    Later i have built one more Calculation view(CA_GRPH_ABC) using (CA_SQL)in projection. i have 30 calculated measures in this final calc view. this final calc view is throwing above mentioned error.
    Not sure if i can use SQL script based calc view in graphical based calc views?
    Regards,
    AV

  • SQL Query based BI Pub report - Taking too long to produce the output

    Hi All,
    I was trying to produce a BI Publisher based report through enterprise edition of BI Publisher 10.1.3.4
    Its a sql query based report and it has around 20 columns and it has around 1 lakh records.
    The query actually takes only 2 seconds to execute in the database but when we execute from BI Publisher it takes a long time and also it times out most of the time
    Is there something I am missing in the configuration options ?
    Thanks
    Shasi

    I am facing the same problem as well. I am using the Publisher Web service API to run a report with 1 Million records. This report is configured to use OBIEE. It takes a lot of time to generate the report ( around 30 Mins) and even though OBIEE generates the data, my web service client either timesout. Even after increasing the timeout, a 500 internal server error is thrown . Does anyone know of a solution to this.
    Thanks

  • How to get the SQL queries based on SQL_ID.

    Hi Experts,
    I want to get the SQL queries based on SQL_ID.
    I have tried the following query,but I am not getting full query.
    [code]SET linesize 132 pagesize 999
    column sql_fulltext format a60 word_wrap
    break on sql_text skip 1
    SELECT   REPLACE (TRANSLATE (sql_text, '0123456789', '999999999'), '9', ''),sql_id
    FROM   dba_hist_sqltext s
    WHERE   s.sql_id = '7tvurftg8zryb';[/code]
    One of my friend said use grid to get full query text.
    Can you please help me how to use grid ,else any other method to get the full query based on SQL_ID.
    Please help me.
    Thanks in advance.

    You have these many options to set, if sql_text is really huge. But better use a tool(TOAD) as it's really helpful and easy to use instead! (See my previous comment).
    column sql_text format A10000
    set echo off
    set head off
    set feed off
    set verify off
    set termout off
    set lines 10000
    set long 1000000
    set trimspool on
    set pages 0
    Thanks!

  • How to get digital signature for Google Map geocoding V3 in PL/SQL?

    Hi, Gurus:
        Could anyone provide me an example about how to generate digital signature for Google Maps service v3 in PL/SQL? We tried to upgrade our program using Google maps service from v2 to v3. We are using PL/SQl on background to send request to Google for geocoding. We found some sample code to register with digital signature, but none of them is based on PL/SQl. Notice I used Google business client ID "gme-XXX" and wallet.
    https://developers.google.com/maps/documentation/business/webservices/auth#digital_signatures
    Google Maps API - more URL signing samples
    Here is my code for V2. I notice in order to get signature, I need to use HMAC-SHA1 algorithm.
    procedure Get_Geocoding(P_s_Address in varchar2, P_s_Geocoding out varchar2, P_n_accuracy out number, P_b_success out boolean) is
      l_address varchar2(4000);
      l_url varchar2(32000);
      l_response varchar2(3200);
      n_first_comma number;
      n_second_comma number;
      n_level_length number;
    BEGIN
      /* TODO implementation required */
      l_address:=APEX_UTIL.URL_ENCODE(P_s_Address);
      l_address := replace(l_address,' ','+');
      l_url := 'http://maps.google.com/maps/geo?q='||l_address||'&'||'output=csv'||'&'||'client=gme-XXX';
    l_response := utl_http.request(l_url, APEX_APPLICATION.G_PROXY_SERVER, '/u02/app/oracle/admin/apexsb/wallet', 'XXXXXXXX');
      n_level_length:=0;
      n_first_comma:=instr(l_response,',',1,1);
      n_second_comma:=instr(l_response,',',1,2);
      n_level_length:=n_second_comma-n_first_comma-1;
      P_n_accuracy:=0;
      if n_level_length>0 then
      P_n_accuracy:=to_number(substr(l_response,n_first_comma+1, n_level_length));
      end if;
      l_response:=substr(l_response,instr(l_response,',',1,2)+1);
      --dbms_output.put_line('In function: l_response ='||l_response);
      P_s_Geocoding:=l_response;
      if (P_s_Geocoding<>'0,0') then
      P_b_success:=true;
      --dbms_output.put_line('true');
      else
      P_b_success:=false;
      --dbms_output.put_line('false');
      end if;
    END;
    Thanks!

    Hi, guys:
        I tried to generate digital signature for Google map service
         Maps for Business: Generating Valid Signatures - YouTube
        Generating an HMAC-SHA-1 Signature Using Only PL/SQL
          OAuth and the PL/SQL | Data Warehouse in the Cloud
       but I got error message from Google:
    Unable to authenticate the request. Provided 'signature' is not valid for the provided client ID. Learn more: https://developers.google.com/maps/documentation/business/webservices/auth
       I think there is something wrong with my code to generate signature, as if I remove the part regarding client and signature, it will work, can anyone help me on this problem?
    /*Procedure Get_Geocoding is used to get geocoding with accuracy level for V3 business account, you can find Google map digital signature descrirption from
    https://developers.google.com/maps/documentation/business/webservices/auth#digital_signatures
    if geocoding is 0,0, procedure returns false to indicate failure of get geocoding*/
    procedure Get_Geocoding2(P_s_Address in varchar2, P_s_Geocoding out varchar2, P_n_accuracy out number, P_b_success out boolean) is
      --private key for Google business account, this is provided by Google with client name.
      l_private_key_src varchar2(200):='xxxxxxxxxxxxxxxxxxx';
      l_private_key_b64_alter varchar2(200):= translate(l_private_key_src,'-_','+/');
      l_private_key_bin raw(2000);
      l_client_name varchar2(100):='gme-xxx';
      l_signature_mac raw(2000);
      l_signature_b64 varchar2(200);
      l_signature_b64_alter_back varchar2(200);
      l_Google_service_domain varchar2(200):='http://maps.googleapis.com';
      l_address varchar2(4000);
      l_url varchar2(32000);
      l_path varchar2(32000);
      l_response varchar2(32000);
      l_page UTL_HTTP.HTML_PIECES;
      n_actual_length number;
      json_obj json;
      json_tempobj json;
      jl_listOfValues json_list;
      json_geom_obj json;
      json_loc json;
      l_lat  VARCHAR2(40);
      l_lng  VARCHAR2(40);
      l_status VARCHAR2(255);
      json_accuracy json;
      --temp_string varchar2(10000);
      n_first_comma number;
      n_second_comma number;
      n_level_length number;
      BEGIN
    /* TODO implementation required */
    l_private_key_bin := utl_encode.base64_decode(UTL_I18N.string_to_raw(l_private_key_b64_alter, 'AL32UTF8'));
    l_address:=APEX_UTIL.URL_ENCODE(P_s_Address);
    --dbms_output.put_line(l_address);
    l_address := replace(l_address,' ','+');
    l_path := '/maps/api/geocode/json?address='||l_address||'&'||'sensor=true';
    dbms_output.put_line(l_path);
    l_signature_mac :=DBMS_CRYPTO.mac(UTL_I18N.string_to_raw(l_path, 'AL32UTF8'), DBMS_CRYPTO.hmac_sh1,l_private_key_bin);
    l_signature_b64:= UTL_RAW.cast_to_varchar2(UTL_ENCODE.base64_encode(l_signature_mac));
    l_signature_b64_alter_back:=translate(l_signature_b64,'+/','-_');
    dbms_output.put_line(l_signature_b64_alter_back);
    --get response from Google map service
    l_url:=l_Google_service_domain||l_path||'&client='||l_client_name||'&signature='||l_signature_b64_alter_back;
    --l_url:=l_Google_service_domain||l_path;
    dbms_output.put_line(l_url);
    l_page:=utl_http.request_pieces( l_url, 99999);
    for i in 1..l_page.count loop
    l_response:=l_response||l_page(i);
    end loop;
    n_actual_length:=length(l_response);
    dbms_output.put_line(n_actual_length);
    dbms_output.put_line(l_response);
    --parse JSON result
    json_obj:=new json(l_response);
    l_status := json_ext.get_string(json_obj, 'status');
    IF l_status = 'OK' then
    jl_listOfValues := json_list(json_obj.get('results'));
    json_tempobj := json(jl_listOfValues.get(1));
    json_geom_obj := json(json_tempobj.get(3));
    json_loc := json_ext.get_json(json_geom_obj, 'location');
    l_lat := to_char(json_ext.get_number(json_loc, 'lat'));
    l_lng := to_char(json_ext.get_number(json_loc, 'lng'));
    P_s_Geocoding:=l_lat||','||l_lng;
    dbms_output.put_line('##########'||P_s_Geocoding);
    case json_ext.get_string(json_geom_obj, 'location_type')
    when 'ROOFTOP' then P_n_accuracy:=9;
    when 'RANGE_INTERPOLATED' then P_n_accuracy:=7;
    when 'GEOMETRIC_CENTER' then P_n_accuracy:=5;
    else P_n_accuracy:=3;
    end case;
    P_b_success:=true;
    else
    P_b_success:=false;
    P_n_accuracy:=0;
    P_s_Geocoding:='0,0';
    end if;
      END;

  • Hide or show a column based on a parameter?

    I have a parameter that has two values linked to 2 fields and included in my SQL query.  I would like to hide or show columns based on the parameter value chosen for other fields.  How do I begin to write the expression? 

    Hi KittyCat101,
    Based on my understanding, you want to display columns dynamically based on a parameter, right?
    In your scenario, you can specify column visibility for all columns based on the expression which contains selected parameter values. So that if we select a value from the drop-down list of the parameter, the column will display based on the column visibility
    expression. For more information, please refer to this article:
    Conditionally Setting Column Visibility in SSRS.
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • How to insert into date column based on other columns?

    Hi
    I have four columns in a table called game named as
    R_Day - Type - Number
    R_Month - Type - Number
    R_Year - Type - Number
    R_Date - Type - Date
    I have around 1000 records and i want to fill R_Date column based on the data in the R_Day,R_Month,R_Year.
    How to write a query to fill the R_Date column based on other three columns.
    Thanks
    srinivas

    select
    to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
    dt from (select 23 R_Day,07 R_Month,2007 R_Year from
    dual);
    Hi,
    Update <Table Name> set R_Date=select
    to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
    from <Table Name>
    Regds.
    Nirmal
    SQL>  select * from test;
         R_DAY    R_MONTH     R_YEAR R_DATE
             1          1       2007
            21         11       2007
    SQL> update test
      2  set r_date = select to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
      3  from test;
    set r_date = select to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
    ERROR at line 2:
    ORA-00936: missing expression
    SQL> update test
      2  set r_date = to_date(r_day||'-'||r_month||'-'||r_year,'dd-mm-yyyy');
    2 rows updated.
    SQL> select * from test;
         R_DAY    R_MONTH     R_YEAR R_DATE
             1          1       2007 01-JAN-07
            21         11       2007 21-NOV-07
    NB:Please test before posting..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Create a derived column based on a value within the file name

    I am importing a CSV file which is easy enough, but I have an issue where I need to manufacture a couple of column values based on the filename of the input.  So this same process will import different types of records to the same table in sql server.
     I need to pull out the record code from the file name.  
    For instance, say I can use the same package to input two different CSV files.  One is named Input_M02_Data.csv and one named Input_B15_Data.csv.  I need to create a derrived column and store the record code there (i.e.:  M02 or B15) based
    on which file it came out of.  
    fyi-
    I also need to create a second column for Dept based off of the file name as well.  M02 is dept 45 and B15 is dept 99  which I also need to insert into this table when I import the data from the .csv file.  
    Any help is greatly appreciated!

    Hi Jason,
    According to your description, you want to add two derived columns based on the file name to also insert into table. One stores the value between two “_” within file name, another stores the department based on that column.
    If in this scenario, we can add a variable FileName that stores the filename, then add the two variables as derived columns like below in the Derived Column Transformation:
    Name:
    SUBSTRING(@[User::FileName],FINDSTRING(@[User::FileName],"_",1)+1,FINDSTRING(@[User::FileName],"_",2)-(FINDSTRING(@[User::FileName],"_",1)+1))
    Dept:
    @[User::Name] =="M02"?"dept 45":@[User::Name] =="B15"?"dept 99":"dept 00"
    The following screenshot is for your reference:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • Multi-level nested tables for repeatable XML Elements

    Hi there,
    Suppose we have a XML Schema „ASchema“ like this (XMLDB schema annotations are left out for simplicity):
    <xs:schema xmlns:xs=" .... " />
    <xs:element name=“A“>
         <xs:complexType>
              <xs:sequence>
                   <xs:element name=“B“ maxOccurs=“unbounded“/>
                        <xs:complexType>
                             <xs:sequence>
                                  <xs:element name = “C“ maxOccurs=“unbounded“/>
                             </xs:sequence>
                        </xs:complexType>
                   </xs:element>
              </xs:sequence>
         </xs:complexType>
    </xs:element>
    </xs:schema>
    After registering this schema in Oracle, I can define a table like this:
    CREATE TABLE ATable
    id NUMBER,
    doc XMLTYPE
    XMLTYPE COLUMN doc
    XMLSCHEMA “ASchema“ ELEMENT “A“
    VARARRAY doc.“XMLDATA“.“B“ STORE AS TABLE “BTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    This creates a nested table "BTable" within the table "ATable". So far so good, I can use this nested table to gain faster access on every possible subelement of Element B when I set an appropriate index.
    I now want to create another nested table for element “C“ like this:
    DROP TABLE ATable;
    CREATE TABLE ATable
    id NUMBER,
    doc XMLTYPE
    XMLTYPE COLUMN doc
    XMLSCHEMA “ASchema“ ELEMENT “A“
    VARARRAY doc.“XMLDATA“.“B“ STORE AS TABLE “BTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    VARARRAY doc.“XMLDATA“.“B“.“C“ STORE AS TABLE “CTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    But this statement fails with the error message something like „ ... no such attribute ... „
    And here's my question: is it possible to create nested tables for repeatable XML Elements that are subelements of other repeatable XML Elements ? And if so, how can I do it ?
    Thank you very much in advance
    Jan

    Found a (partial) solution myself:
    If you add the attribute xdb:storeVarrayAsTable="true" to the root element of the XML schema, Oracle XMLDB generates nested tables for all repeatable XML Elements while registering the XML schema.
    Unfortunately, the names of these nested tables are system-generated, hence it's a bit uncomfortable to set indices on them. You can find out the names of these nested tables as follows:
    select table_name, parent_table_name, parent_table_column from user_nested_tables;
    Further information on that subject is supplied in the following thread:
    Re: default tables for elements with maxoccurs > 1
    It would be nice if there was a way to name the generated nested tables via appropriate XMLDB schema annotations.
    regards
    Jan

  • How to use SQL import to set the attribute value based on another?

    Hello all,
    I want to set an attribute of a dimension based on another attribute (if matches). Let's say I have a dimension PRODUCT. And I have defined two user defined attributes MANAGER and ISVISIBLE.
    Now within a PERMIT_READ program I want to set the ISIVISIBLE to true where the MANAGER Value is selected from a table.
    Something like
    <define a cursor c1 to select all the Manager values>
    sql import c1 into -
    :MATCHSKIPERR PRODUCT_MANAGER then <PRODUCT_ISVISIBLE (PRODUCT MANAGER) = true>
    <etc>
    Obviously the above is not correct. But I am stuck as to how this can be done? Can some one on this forum please help me with correct syntax/ approach please?
    Thanks a lot.
    Pxsheth
    This statement assigns true to the isvisible attribute for every gc_dim_bu dimension (selected as part of cursor c1).
    SO FAR SO GOOD.. NOW -
    If I want to change the above so that the attribute value gets assigned based on another attribute for the dimension (say a flag). i.e.
    Set the isvisible to true where attribute flag has a certain value. How do I code this in OLAP DML?

    There are a number of ways to do this. If you want to use an attribute that has been defined within AWM as an attribute of Product then simply using the mapping tool to populate the attribute as part of the normal dimension load procedure.
    Alternatively you could create an attribute at the DML level, and assuming you are not using surrogate keys, you can then define a cursor to read the relational table to populate your attribute. Something like this:
    sql declare MKT_BASKET cursor for -
    select PRODUCT_ID, PROD_MGR , PROD_VISIBLE -
    from PRODUCT_DIM
    if SQLCODE ne 0
    then goto ERROR
    sql open MY_CURSOR
    sql fetch MY-CURSOR loop into :append PRODUCT, :PRODUCT_MANAGER, :PRODUCT_ISVISIBLE
    sql close MY_CURSOR
    sql cleanup
    update
    commit
    If you want to create a complex PERMIT function using OLAP DML then personally I would create a formula and assign a program of type BOOLEAN and have the program return a YES or NO depending on the outcome of your test. Then your PERMIT_READ still references a dimension object. For example:
    DEFINE PROD.ISVISIBLE BOOLEAN FORMULA <PRODUCT>
    EQ PRG.ISVISIBLE(PRODUCT)
    DEFINE PRG.ISVISBLE PROGRAM BOOLEAN
    The program will then return Yes or No depending on the processing you need to do.
    Hope this helps
    Keith Laker
    Data Warehouse Solution Architect
    Oracle EMEA Consulting
    BI Blog: http://oraclebi.blogspot.com/
    DM Blog: http://oracledmt.blogspot.com/
    BI on Oracle: http://www.oracle.com/bi/
    BI on OTN: http://www.oracle.com/technology/products/bi/
    BI Samples: http://www.oracle.com/technology/products/bi/samples/

  • Virtual column based partitioning

    Hi,
    we have a non-partitioned table in a production database and wish to partition it based on an expression. Since we are on 11.2 the first thing that comes to mind is virtual column based partitioning. The "problem" is that in order to partition by a virtual column, you have to create one, and adding a new column to a table could break any application that doesn't reference the existing columns by name, e.g. "SELECT *" or. "INSERT INTO table VALUES(....)".
    My question is: is it possible to somehow specify the expression on which to partition directly in the "partition by" clause rather than specifying it as a virtual column definition?
    Example:
    Instead of this..
    SQL> create table test (
      2    id             number not null,
      3    content        varchar2(10),
      4    record_type    varchar2(1) generated always as (case when (substr(content, 1, 1)='B' and not substr(content, 1, 3)='Bxy') then 'B' else 'A' end) virtual
      5  )
      6  partition by list(record_type)
      7  (
      8    partition partA values ('A'),
      9    partition partB values ('B')
    10  );
    Table created...I'd like to use something like this:
    SQL> create table test (
      2    id             number not null,
      3    content        varchar2(10)
      4  )
      5  partition by list((case when (substr(content, 1, 1)='B' and not substr(content, 1, 3)='Bxy') then 'B' else 'A' end))
      6  (
      7    partition partA values ('A'),
      8    partition partB values ('B')
      9  );
    partition by list((case when (substr(content, 1, 1)='B' and not substr(content, 1, 3)='Bxy') then 'B' else 'A' end))
    ERROR at line 5:
    ORA-00904: : invalid identifierThank you in advance for any answers.
    Regards,
    Jure

    adding a new column to a table could break any application that doesn't reference the existing columns by name, e.g. "SELECT *" or. "INSERT INTO table VALUES(....)". "Ok, i got it. You mean, in application you are using select * from yourtable; and those data is being used by a datagrid or any control, then where that application will show / handle the new column data right ?
    Yes, thats why DBA and developers do SDLC (Software Development Life Cycle); that our table will be looks like this, these will be columns, these will be their data types, these will be followed in naming convention, privileges, indexes, storage parameters, constraints, dependent objects etc. Now after creating the table, you found a need to add a column, it means there was some lapses happened at the design time/phase or business requirements are newly defined.
    So, as far as concerned of select * ... ; you have to change in the application by :
    select col1, col2, new_col from your table... (as per order of your datagrid control columns). There is no other solution, you have to change in application code at every place where you have used select * and if those statements are being merged / deals into a control)
    New column addition will hamper only at select * from... not with any INSERT/UPDATE/DELETE, because if they are running fine it means, they have well written column references. For DMLs you need not worry so far.
    By the way, what is your technology for application ? I have worked on couple of applications in ASP.NET with using datagrid which auto add/removes the columns in itself as per cursor result (not rememberring the exact property of it though)
    Regards
    Girish Sharma

Maybe you are looking for

  • Help needed in Dialog programming

    Hi, I am in a module pool program. This contains a subscreen which has a tablecontrol. Based on one of the entry in the table control. I need to stop the user to change the value. So I have coded like the below. If i_tc-value = 0.    v_scrno = sy-dyn

  • Installing XP SP2 PC hard drive in Mac

    What I want to do is take the hard drive out of my PC which is already formatted with Windows XP SP2 and put it in my Mac Pro as a second bootable drive. Assume that my drive is a SATA drive (I need to check first) that is installable in the Mac. Can

  • Cannot stop my pointer from blinking (hour glass also blinks on and off incessantly)

    Several weeks ago my pointer blinks constantly (unless it's over a hyperlink or other selection item). The hourglass also blinks along with it. I have tried everythink in the control panel, but nothing works. This question was solved. View Solution.

  • Reconnecting iPod w/o unplugging

    Once I've "ejected" my nano, I sometimes want to reconnect it with iTunes. Shocking, I know. Is there a way to reconnect without either unplugging & plugging in my ipod or closing & reopening iTunes?

  • Reset Co-PA value field effect for earlier transactions.

    Dear experts, actually my requirement is 2 billing types related quantity should not be included in to CO-PA report, for that i was done the settings in KE4W(reset the co-pa value field) It is working but effect is coming from current billing transac