building XPath with the XML with the Namespace using PL SQL

All trying to build the path to each node, when the XML code with no namespace, the following code works very well provide the result

1 ~/

2 ~ /Person/

3 ~ /Person/ âge /

4 ~ /Person/ homecity /

5 ~ /Person/ nom /

6 ~ /Person/ AccueilGuides/lat /

7 ~ /Person/ AccueilGuides/name /

8 ~ /Person/ homecity / long /

But when the XML is changed to

<person xmlns="urn:person" xmlns:lat="urn:lat">
<name>Rob</name>
<age>37</age>
<homecity>
    <name>London</name>
    <lat>123.000</lat>
    <long>0.00</long>
</homecity>
</person>"

The result of the code below the performance translates into just below result

1~/
 2~/person/

In the XML file above, XML namespace is not constant and varies for each XML. My requirement is to analyze the complete XML code, where I can read the XML with namespace and get the result that is mentioned below

1~/
2~/person/
3~/person/age/
4~/person/homecity/
5~/person/name/
6~/person/homecity/lat:lat/
7~/person/homecity/name/
8~/person/homecity/long/

Can you please help me solve the issue mentioned. Thanks in advance. -Code snippet below:

DECLARE
  l_File VARCHAR2(32000) := '<person>
<name>Rob</name>
<age>37</age>
<homecity>
    <name>London</name>
    <lat>123.000</lat>
    <long>0.00</long>
</homecity>
</person>';
 
 l_Where_Clause VARCHAR2(100) := '/*';
 l_Append_Var   VARCHAR2(100) := '/';
 
 TYPE Ty_Paths IS TABLE OF VARCHAR2(1000) INDEX BY PLS_INTEGER;
 l_Ty_Paths      Ty_Paths;
 l_Ty_Paths_Temp Ty_Paths;
 
 TYPE Ty_Verifier IS TABLE OF VARCHAR2(1000) INDEX BY VARCHAR2(1000);
 l_Ty_Varifier Ty_Verifier;
 
l_Prev_Query_Rec VARCHAR2(100);
l_Index_Num      NUMBER := 0;
l_Cur_Exec_Row   NUMBER := 0;
BEGIN
 l_Ty_Paths(Nvl(l_Ty_Paths.COUNT, 0) + 1) := l_Append_Var;
 l_Cur_Exec_Row := 1;
 
 --Dbms_Output.put_line('Before entering the loop');
 
 LOOP
   l_Ty_Paths_Temp.DELETE;
  SELECT DISTINCT REPLACE(l_Append_Var || '/' || t.Xml || '/', '//', '/') BULK COLLECT
   INTO   l_Ty_Paths_Temp
  FROM   (SELECT Xmltype(Extract(VALUE(e), '/').Getstringval()) .Getrootelement() AS Xml
           FROM   TABLE(Xmlsequence(Extract(Xmltype(l_File), l_Where_Clause))) e) t;
 
  l_Ty_Varifier(Nvl(l_Ty_Varifier.COUNT, 0) + 1) := l_Append_Var;
  --Dbms_Output.put_line('L_TY_PATHS_TEMP.Count::'||L_TY_PATHS_TEMP.Count);
  IF l_Ty_Paths_Temp.COUNT > 0 THEN
     l_Index_Num := Nvl(l_Ty_Paths.COUNT, 0) + 1;
     FOR i IN l_Ty_Paths_Temp.FIRST .. l_Ty_Paths_Temp.LAST LOOP
        l_Ty_Paths(l_Index_Num) := l_Ty_Paths_Temp(i);
        --Dbms_Output.put_line('L_INDEX_NUM::'||L_INDEX_NUM);
        --Dbms_Output.put_line('L_TY_PATHS(L_INDEX_NUM)::'||L_TY_PATHS(L_INDEX_NUM));
        l_Index_Num := l_Index_Num + 1;
     END LOOP;
  END IF;
  --Dbms_Output.put_line('L_TY_PATHS.Count::'||L_TY_PATHS.Count);
  --Dbms_Output.put_line('L_TY_PATHS.Count::'||L_CUR_EXEC_ROW);
 
  IF (NOT l_Ty_Paths.EXISTS(l_Cur_Exec_Row + 1)) OR (l_Cur_Exec_Row = l_Ty_Paths.COUNT) THEN
     --Dbms_Output.put_line('Exiting');
     EXIT;
  ELSE
     --Dbms_Output.put_line('Inside the Else part');
 
     l_Cur_Exec_Row := l_Cur_Exec_Row + 1;
     l_Append_Var   := l_Ty_Paths(l_Cur_Exec_Row);
     l_Where_Clause := l_Ty_Paths(l_Cur_Exec_Row) || '*';
  END IF;
 
  --To Display the record:
     --Dbms_Output.put_line(L_TY_PATHS.Count);
  END LOOP;
  IF l_Ty_Paths.COUNT > 0 THEN
    FOR i IN l_Ty_Paths.FIRST .. l_Ty_Paths.LAST LOOP
      Dbms_Output.Put_Line(i || ' record is ' || l_Ty_Paths(i));
   END LOOP;
 END IF;
 
END;

Thank you.

If you have patterns, it may be easier to work directly on them.

Here's the idea:

(1) install "Oracle XML DB manageability Packages", available on the code page for the XML DB sample: http://download.oracle.com/otn/samplecode/xdb_util.zip

This is a set of utilities which allows us to annotate the XML schemas, to deal with the underlying or storage structure, and (this is the interesting part here) a few views of dictionary to describe the relational XSD structure.

(it is now an integrated 12 c btw)

(2) enter these two schemas:

Start

() dbms_xmlschema.registerSchema

schemaURL-online "pacs.002.001.03S2.xsd."

schemaDoc-online xmltype (bfilename('TEST_DIR','pacs.002.001.03S2.xsd'), nls_charset_id ('AL32UTF8'))

local-online true

genTypes-online fake

genTables-online fake

enableHierarchy-online dbms_xmlschema. ENABLE_HIERARCHY_NONE

options-online dbms_xmlschema. REGISTER_BINARYXML

);

end;

/

Start

() dbms_xmlschema.registerSchema

schemaURL-online "SCTCvfBlkCredTrf.xsd."

schemaDoc-online xmltype (bfilename('TEST_DIR','SCTCvfBlkCredTrf.xsd'), nls_charset_id ('AL32UTF8'))

local-online true

genTypes-online fake

genTables-online fake

enableHierarchy-online dbms_xmlschema. ENABLE_HIERARCHY_NONE

options-online dbms_xmlschema. REGISTER_BINARYXML

);

end;

/

(3) the following query built all the paths of node defined by the main schema (SCTCvfBlkCredTrf.xsd), as well as the namespaces:

with schema_list (schema_url, schema_owner) as)

Select 'SCTCvfBlkCredTrf.xsd', 'OTN' from dual

Union of all the

Select sd.dep_schema_url, sd.dep_schema_owner

of schema_list sl

Join dba_xml_schema_dependency on sd.schema_url = sl.schema_url sd

and sd.schema_owner = sl.schema_owner

),

namespace_mapping (target_namespace, prefix) as long as)

Select target_namespace

, « ns » || ROW_NUMBER() (order target_namespace) as a prefix

of user_xml_schema_namespaces

where schema_url in (select schema_url from schema_list)

),

() schema_nodes

is_attr

node_name

max_occurs

element_id

parent_element_id

target_namespace

schema_url

) as)

Select 0

element_name as node_name

xmlcast)

XMLQUERY ('/ XS: ELEMENT / ' @maxOccurs passing returning content element)

as varchar2 (10)

)

element_id

parent_element_id

target_namespace

schema_url

of user_xml_schema_elements

where schema_url in (select schema_url from schema_list)

Union of all the

Select 1

attribute_name as node_name

null

null

element_id

target_namespace

schema_url

of user_xml_schema_attributes

where schema_url in (select schema_url from schema_list)

)

Select the level

sn.node_name

sn.max_occurs

connect_by_isleaf as is_leaf

sys_connect_by_path)

-case when ns.prefix is not null and is_attr = 0 then ns.prefix | ':' end |

-case when sn.is_attr = 1 then ' @' end |

SN. NODE_NAME

, '/'

) as xpath

-, target_namespace

of schema_nodes sn

outer join ns namespace_mapping let ns.target_namespace = sn.target_namespace

Connect prior sn.element_id = sn.parent_element_id

Start with sn.schema_url = "SCTCvfBlkCredTrf.xsd".

and sn.parent_element_id is null

;

LEVEL MAX_OCCURS IS_LEAF XPATH NODE_NAME
----- ------------------ ---------- ------- ----------------------------------------------------------------------------------------------------------
1 SCTCvfBlkCredTrf 0 /ns2:SCTCvfBlkCredTrf
2 1 SndgInst /ns2:SCTCvfBlkCredTrf / ns2:SndgInst
2 1 RcvgInst /ns2:SCTCvfBlkCredTrf / ns2:RcvgInst
2 1 SrvcId /ns2:SCTCvfBlkCredTrf / ns2:SrvcId
2 1 TstCode /ns2:SCTCvfBlkCredTrf / ns2:TstCode
2 FType 1 /ns2:SCTCvfBlkCredTrf / ns2:FType
2 FileRef 1 /ns2:SCTCvfBlkCredTrf / ns2:FileRef
2 1 FileDtTm /ns2:SCTCvfBlkCredTrf / ns2:FileDtTm
2 1 OrigFRef /ns2:SCTCvfBlkCredTrf / ns2:OrigFRef
2 1 OrigFName /ns2:SCTCvfBlkCredTrf / ns2:OrigFName
2 1 OrigDtTm /ns2:SCTCvfBlkCredTrf / ns2:OrigDtTm
2 1 FileRjctRsn /ns2:SCTCvfBlkCredTrf / ns2:FileRjctRsn
2 1 FileBusDt /ns2:SCTCvfBlkCredTrf / ns2:FileBusDt
2 1 FileCycleNo /ns2:SCTCvfBlkCredTrf / ns2:FileCycleNo
2 FIToFIPmtStsRptS2 1 /ns2:SCTCvfBlkCredTrf 0 / ns2:FIToFIPmtStsRptS2
3 GrpHdr 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:GrpHdr
4 MsgId 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:GrpHdr / ns1:MsgId
4 CreDtTm 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:GrpHdr / ns1:CreDtTm
4 InstgAgt 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:GrpHdr / ns1:InstgAgt
5 FinInstnId 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:GrpHdr / ns1:InstgAgt / ns1:FinInstnId
6 BIC 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:GrpHdr / ns1:InstgAgt / ns1:FinInstnId / ns1:BIC
3 OrgnlGrpInfAndSts 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts
4 OrgnlMsgId 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:OrgnlMsgId
4 OrgnlMsgNmId 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:OrgnlMsgNmId
4 OrgnlNbOfTxs 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:OrgnlNbOfTxs
4 OrgnlCtrlSum 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:OrgnlCtrlSum
4 GrpSts 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:GrpSts
4 StsRsnInf 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:StsRsnInf
5 Orgtr 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:StsRsnInf / ns1:Orgtr
6 id 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:StsRsnInf / ns1:Orgtr / ns1:Id
7 OrgId 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:StsRsnInf / ns1:Orgtr / ns1:Id / ns1:OrgId
8 1 BICOrBEI /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:StsRsnInf / ns1:Orgtr / ns1:Id / ns1:OrgId / ns1:BICOrBEI
5 ARS 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:StsRsnInf / ns1:Rsn
6 Cd 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:StsRsnInf / ns1:Rsn / ns1:Cd
6 Prtry 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:StsRsnInf / ns1:Rsn / ns1:Prtry
4 NbOfTxsPerSts 2 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:NbOfTxsPerSts
5 1 DtldNbOfTxs /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:NbOfTxsPerSts / ns1:DtldNbOfTxs
5 1 DtldSts /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:NbOfTxsPerSts / ns1:DtldSts
5 1 DtldCtrlSum /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:OrgnlGrpInfAndSts / ns1:NbOfTxsPerSts / ns1:DtldCtrlSum
3 TxInfAndSts boundless 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts
4 StsId 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:StsId
4 OrgnlInstrId 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlInstrId
4 OrgnlEndToEndId 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlEndToEndId
4 OrgnlTxId 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlTxId
4 TxSts 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:TxSts
4 StsRsnInf 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:StsRsnInf
5 Orgtr 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:StsRsnInf / ns1:Orgtr
6 id 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:StsRsnInf / ns1:Orgtr / ns1:Id
7 OrgId 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:StsRsnInf / ns1:Orgtr / ns1:Id / ns1:OrgId
8 1 BICOrBEI /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:StsRsnInf / ns1:Orgtr / ns1:Id / ns1:OrgId / ns1:BICOrBEI
5 ARS 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:StsRsnInf / ns1:Rsn
6 Cd 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:StsRsnInf / ns1:Rsn / ns1:Cd
6 Prtry 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:StsRsnInf / ns1:Rsn / ns1:Prtry
4 InstdAgt 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:InstdAgt
5 FinInstnId 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:InstdAgt / ns1:FinInstnId
6 BIC 1 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:InstdAgt / ns1:FinInstnId / ns1:BIC
4 OrgnlTxRef 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlTxRef
5 IntrBkSttlmAmt 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlTxRef / ns1:IntrBkSttlmAmt
CTL 6 1 /ns2:SCTCvfBlkCredTrf/ns2:FIToFIPmtStsRptS2/ns1:TxInfAndSts/ns1:OrgnlTxRef/ns1:IntrBkSttlmAmt/@Ccy
5 1 IntrBkSttlmDt /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlTxRef / ns1:IntrBkSttlmDt
5 DbtrAgt 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlTxRef / ns1:DbtrAgt
6 FinInstnId 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlTxRef / ns1:DbtrAgt / ns1:FinInstnId
7 1 BIC /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlTxRef / ns1:DbtrAgt / ns1:FinInstnId / ns1:BIC
5 CdtrAgt 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlTxRef / ns1:CdtrAgt
6 FinInstnId 0 /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlTxRef / ns1:CdtrAgt / ns1:FinInstnId
7 1 BIC /ns2:SCTCvfBlkCredTrf / ns2:FIToFIPmtStsRptS2 / ns1:TxInfAndSts / ns1:OrgnlTxRef / ns1:CdtrAgt / ns1:FinInstnId / ns1:BIC

In fact, you would be generally extracted from mapping data in a separate query so that you can use it to build the dynamic with XMLNamespaces clause of the namespace.

NB1: Also note that not all roads are needed, only those which IS_LEAF = 1 or MAX_OCCURS = "unlimited" or MAX_OCCURS > '1', then you can add a filter predicate in the query directly.

NB2: The query does support all the features of XSD, for example, I've relied on the default behavior for attributes 'element_form_default' and 'attribute_form_default '.

Tags: Database

Similar Questions

  • Sending E-Mail with an attachment using PL/SQL

    Hello

    I am trying to send an E-Mail with an attachment using pl/sql on Oracle 9i.
    I found the code from the link below.
    http://www.orafaq.com/wiki/Send_mail_from_PL/SQL
    but the attachment it sends is defined in the pl/sql block.
    I want to attach a file in a different location. How can I do this?

    Thanks in advance

    If the attachment is also on the server (it must be on the server), you can load into a BLOB and which attach to your e-mail (you will need to create an Oracle Directory that points to the file to be attached).

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:255615160805 #68529763836665
    This thread is big enough, a ctrl + f there might give you some clues.

    Currently I do not have the mail api available on here, but I still have it on a "test/playground DB", so I'll take a look later, when I have time and place.

  • OutOfMemoryError: Limit superior GC exceeded when loading directly the source using IKM sql for sql. Growing ODI_MAX_HEAP do not solve the problem.

    OutOfMemoryError: GC overhead limit at execution a loading interface directly sql for sql with no work table.

    I get the error message: error: exception OutOfMemoryError: higher GC limit exceeded when executing an interface making a direct using IKM SQL for SQL command load Append, source a 150millions lines table.

    I have increased the ODI_MAX_HEAP and the interface run longer and failed. I'm already at: ODI_MAX_HEAP = 12560 m I tested with ODI_MAX_HEAP = 52560 m and still error.

    I am following up to the memory of the server and I still have available memory...

    Apart from the problem of memory I know that this type of load should be possible because the step of data load on LKM SQL to Oracle is able to load the work table $ CAN. Ideally, I want to emulate this behavior by using SQL for SQL IKM.

    1 - What is the right path to follow here? (change the parameters of memory or modify the IKM?)


    2 - ideas on how to solve the OutOfMemoryError: GC overhead limit exceeded error? (GC means Garbage Collector)

    Execution of the IKM interface in the Simulator generates this code:

    Load (Source) command:

    Select

    source - tbl.col1 COL1,

    source - tbl.col2 COL2,

    source-tbl. "' COL3 ' COL3

    of public.source - tbl AS source-tbl

    where

    (1 = 1)

    Default command (Destination):

    insert into the source-tbl

    (

    col1,

    col2,

    COL3

    )

    values

    (

    : COL1,.

    : COL2.

    : COL3

    )

    My experience is very limited with ODI so I don't know about changing the code to the KMs

    Thanks in advance.

    Find a work around the error of generals limit exceeded GC:

    -in my case I was running without the IDE so that changes made to the odiparams.sh were not useful.

    -This means that I need to change the JVM settings to:

    $ODI_HOME/oracledi/client/odi/bin/odi.conf

    AddVMOption - XX: MaxPermSize = NNNNM

    $$ODI_HOME/oracledi/client/ide/bin/ide.conf

    AddVMOption - XmxNNNNM

    AddVMOption - XmsNNNNM

    Where NNNN is a higher value.

  • Parse the JSON using PL/SQL string

    I created a script that reads data from the Mobile App DB (which is based on MongoDB) of Oracle SQL Developer. The result is the string JSON stored in l_response_text VARCHAR2 (32767);

    The string has the format such as:


    [{"Postcode":"47100","OutletCode":"128039251","MobileNumber":"0123071303","_createdAt":"2014-11-10 06:12:49.837","_updatedAt":"2014-11-10 06:12:49.837"}, {"Postcode":"32100","OutletCode":"118034251", ..... ]
    
    
    
    
    

    However, I need to analyze this l_response_text such that each table will in his column in a table called appery_test. appery_test table has the same number of columns pairs JSON and in the same order (e.g. name of the first column is 'postal Code')

    I searched and I found most of the results on the analysis of the Oracle in JSON table and not the other way around. I found, however, that link which is somewhat similar to my problem. However, the library suggested in the answer doesn't have an example on how to use it to insert JSON into conventional table using PL/SQL.

    N.B.: I use g 11 and not 12 c. If the functions built by are not available for me.

    Thank you very much

    Sorry, I am a novice in this area too.

    However, it worked for me:

    declare

    l_list json_list;

    l_data CLOB;

    Code postal clob;

    l_val json_value;

    Start

    -json data recovery

    Select the data in l_data from jsons where id = 1;

    l_list: = json_list (l_data);

    I'm looping 1.l_list.count

    l_val: = json_ext.get_json_value (json (l_list.get (i)), 'Postcode');

    DBMS_LOB.CREATETEMPORARY (zip, true, 2);

    json_value.get_string (l_val, postal code);

    -Put some things

    dbms_output.put_line (DBMS_LOB. GetLength (Postcode));

    dbms_output.put_line (dbms_lob.substr (postal code, 20, 1));

    DBMS_LOB.freeTemporary (Postcode);

    end loop;

    end;

    47328

    9J / / 4AAQSkZJRgABAQAA

    Added dbms_lob.freetemporary (postcode);

  • Apex - disable the button using PL/SQL code

    Hi all

    I use a PL/SQL code to get a DB value, depending on the value that I need to disable the buttons on the Page.

    I tried code below

    IF : P2_FLAG == ' not THEN

    HTP.script ("document.getElementById ("SUBMIT") .disabled = false;", "Javascript");

    END IF;

    It is said screw the page saying - the/apex/f requested URL was not found on this server

    I use Apex 5.0, please need your contributions.

    Hello

    However, if you want to show/hide the button, you can use conditions:

    Open the properties of the button and put Conditions such as "Item = value '.

    Point - P2_FLAG

    Value - N

    To turn on or off, you must run ajax with jquery to get the DB value before charge and then print button.

    It may be useful

    Sunil Bhatia

  • create the cookie using pl sql and retrieve values

    Hello
    I am currently in an urgent need to create cookies to BE oracle and also read the values of the. I tried to use code below. his display error
    code
    DECLARE
    ourcookie owa_cookie.cookie;
    BEGIN
    ourCookie: = owa_cookie.get('SESSION2');
    END;
    /

    BEGIN

    owa_util.mime_header ("text/html", FALSE ");

    -Create a cookie
    (owa_cookie). Send
    name = > 'SESSION. "
    value = > '344444',.
    expires = > sysdate + 2,.
    path = > ' / ');


    owa_util.http_header_close;

    EXCEPTION
    WHEN OTHER THEN NULL;

    END;


    But when I'm reading the cookie that I created, I am unable to exercise

    -It's for reading cookies
    DECLARE
    ourcookie owa_cookie.cookie;
    BEGIN
    ourCookie: = owa_cookie.get('SESSION2');
    END;
    /

    error:
    ORA-06502: PL/SQL: digital error or value
    ORA-06512: at "SYS." OWA_UTIL", line 325
    ORA-06512: at "SYS." OWA_COOKIE', line 36
    ORA-06512: at "SYS." OWA_COOKIE', line 140
    ORA-06512: at line 4 level

    842106 wrote:

    Now according to the guidelines of your comment, I created a simple OWA environment and run the code below. Now I get not found error of data

    ORA-01403: no data found
    ORA-06512: at line 23

    The error is caused the cookie is not found.

    The following is not valid - as there is no browser to receive the cookie:

    (owa_cookie). Send
    name-online "SESSION1"
    value-online '344433',
    expires => it sysdate + 2,.
    => path ' / '.
    );

    The following code must set the CGI environment - and add the cookie to the environment for the following code to read (as shown in the code example that I posted in the 2nd thread I talked to you):

    / * Initialization * /.
    OWA.cgi_var_name (1): = 'something ';
    OWA.cgi_var_val (1): = "other";
    OWA.init_cgi_env (1, owa.cgi_var_name, owa.cgi_var_val);
    / * End initialization * /.

    Of course, the following code will fail with a NO_DATA_FOUND there is no cookie.

    ourCookie: = owa_cookie.get('SESSION1');
    v_session: = ourCookie.vals (1);

    So it is not possible to create a true cookie and retrieve the value of CGI environment or apex not?

    Yes. But the web browser is non-existent. Then, you need create the CGI environment, which would have created the web server, before you call your allowed web code PL/SQL.

    In other words, if your initialization code of CGI should pretend that it is the web server, he received the call from web browser, it received the cookie (s) from the web browser - and now she needs to create the CGI (including cookies) environment for this web browser, and then call the procedure PL/SQL referenced by the browser in the URL, he argued.

  • How can we make the Partition on the result using only sql?

    Hello

    How to make the partition on sql result using the query.

    sample
    BPREF_NO     BILL_MONTt AVG_IND     partition
    Q12345     1/31/2009     2     part1
    Q12345     2/28/2009     2     part1
    Q12345     3/31/2009     2     part1
    Q12345     4/30/2009     2     part1
    Q12345     5/31/2009     2     part1
    Q12345     6/30/2009     1     part1
    Q12345     7/31/2009     2     part1
    Q12345     9/30/2009     1     part2
    Q12345     10/31/2009     2     part2
    Q12345     11/30/2009     2     part2
    Q12345     1/31/2010     1     part3
    Q12345     2/28/2010     2     part3
    Q12345     3/31/2010     2     part3
    Q12345     11/30/2011     2     part4
    Q12345     2/29/2012     2     part5
    Q12345     3/31/2012     2     part5
    Q12345     4/30/2012     2     part5
    Q12345     5/31/2012     2     part5
    Q12345     7/31/2012     2     part6
    I want to create the partition column using the query
    from the logic below

    If bill_month is the sequence then it must create a partition and if the breaks we need to introduce the new partition.

    just for example...
    January 31, 2009 to July 31, 2009 is called part1
    August 30, 2009 to November 30, 2009 called part2
    like wise...

    is it possible to make the partition of the query itself.

    Please guide me in this regard

    Thanks in advance

    Iqbal
    with testdata as (
    select 'Q12345' BPREF_NO, to_date('1/31/2009','MM/DD/YYYY') BILL_MONTt,2 AVG_IND from dual union all
    select 'Q12345', to_date('2/28/2009','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('3/31/2009','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('4/30/2009','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('5/31/2009','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('6/30/2009','MM/DD/YYYY'),1 from dual union all
    select 'Q12345', to_date('7/31/2009','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('9/30/2009','MM/DD/YYYY'),1 from dual union all
    select 'Q12345', to_date('10/31/2009','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('11/30/2009','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('1/31/2010','MM/DD/YYYY'),1 from dual union all
    select 'Q12345', to_date('2/28/2010','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('3/31/2010','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('11/30/2011','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('2/29/2012','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('3/31/2012','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('4/30/2012','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('5/31/2012','MM/DD/YYYY'),2 from dual union all
    select 'Q12345', to_date('7/31/2012','MM/DD/YYYY'),2 from dual
    )
    
    select
      BPREF_NO
    , AVG_IND
    , BILL_MONTt
    , 'part'||
      sum (partition) over (partition by BPREF_NO order by BILL_MONTt)
      partition
    from (
    select
      BPREF_NO
    , AVG_IND
    , BILL_MONTt
    , case
      when months_between (BILL_MONTt, lag(BILL_MONTt) over (partition by BPREF_NO order by BILL_MONTt)) = 1 then
      0 else 1 end partition
    from testdata
    )
    
    BPREF_NO AVG_IND BILL_MONTT PARTITION
    Q12345 2 01/31/2009 part1
    Q12345 2 02/28/2009 part1
    Q12345 2 03/31/2009 part1
    Q12345 2 04/30/2009 part1
    Q12345 2 05/31/2009 part1
    Q12345 1 06/30/2009 part1
    Q12345 2 07/31/2009 part1
    Q12345 1 09/30/2009 part2
    Q12345 2 10/31/2009 part2
    Q12345 2 11/30/2009 part2
    Q12345 1 01/31/2010 part3
    Q12345 2 02/28/2010 part3
    Q12345 2 03/31/2010 part3
    Q12345 2 11/30/2011 part4
    Q12345 2 02/29/2012 part5
    Q12345 2 03/31/2012 part5
    Q12345 2 04/30/2012 part5
    Q12345 2 05/31/2012 part5
    Q12345 2 07/31/2012 part6 
    
  • Mail send the program using PL SQL

    Hi all

    I wrote a PL SQL to send emails of concurrent with attachment.

    Here, it has separate Application server and database server.
    I am able to send a file from the database server (Ex: .trc files).

    But I need to send application server .out files.

    When I run of concurrent all files in the application server only recovers.
    Please help me solve the problem.

    Operating system: HP 64 bit
    RDBMS: 10.2.0.4.0
    Oracle Applications: 11.5.10.2


    Please advice.

    Thanks in advance,
    Roselyne

    Hi Flo,
    I checked your Quary. Better, you can create a common shared drive .it will help.

    for your reference, please visit http://thalaimuthu.com

    Thank you
    Muthu

  • In the instructions using 1 SQL = 1

    I just said our DBA that we have to go through our code and remove the 'WHERE 1 = 1' in our SQL statements on a SQL 2000 database. He says it's a performance issue when nothing else will succeed him (no AND).

    For example (the wrong way):
    SELECT this_ID FROM thistable WHERE 1 = 1

    Compared to...
    SELECT this_ID FROM thistable WHERE 1 = 1 AND this_ID = 1001

    Microsoft has said that it is causing a performance hit when there is no clauses from the place WHERE, said.

    Some of these SQL statements are big enough and there is no practical way to make a CFIF beforehand.

    Everyone knows a performance hit like that? If so, how much of a sudden? The main table in the DB has about 2 million documents with full-text indexes.

    Thank you
    Rob in Tampa



    Tell him to make his g * use of the dam and set up the database as a real dba should
    and even if harping on things that affect performance as much as you
    Blow up near the server.

    "TPA_Dude" wrote in message
    News:e6khe4$S0A$1@forums. Macromedia.com...
    > MikerRoo.
    > Thank you for your quick response. I enabled for debugging
    > my
    > IP, so I'll start to write execution time for individual applications.
    > I
    > didn't know I could see the plan, so thank you. I don't know who will help you
    > much.
    >
    > Thanks again to everyone.
    > Rob
    >

  • drop and re-create the table using dynamic sql

    The following procedure should drop the table and re-create it. Currently, I get the dbms_output of the query. If I run the query only, it works well. but through the procedure, it does not work. Please help me

    PROCEdure emp_backup is
    sql_txt varchar2(10000);
    begin
         begin
         EXECUTE IMMEDIATE 'drop table emp_backup ' ;
         exception
         when others then
         null;
    
         sql_txt:= 'CREATE TABLE emp_backup as ' ||
                     'select * from emp  '||
                     'where dep_no=10 ' ;
         dbms_output.put_line(sql_txt);
         EXECUTE IMMEDIATE sql_txt;
    Exception
    when others then
    Null;
    
    End;

    Daniel wrote:
    I'm getting following error ORA-01031: insufficient privileges

    What is the command to grant privileges to this

    GRANT CREATE TABLE TO <>
    

    Detaching Frank, however, and echoing my previous comment, let them down and to re-create the tables makes no sense. It is logical to truncate a table if you test a load. If you build a data warehouse, it makes sense to delete and re-create a partition if you rerun a load for a particular date and that you have daily partitions. Deletion and recreation of a table in a stored procedure is not a reasonable way to test a system (nor is there a reasonable way to approach change control issues that will inevitably produce when you need to change the structure of a table).

    Justin

  • Problems with Insert by using dynamic Sql

    Hello
    I use the following procedure to read a BLOB after download tab-delimited text files and insert the data in a table called TBL_TMP. The columns of the table are the following: T1, T2, T3, T4, T5, T6, T7, T8, T9. I have different text files.

    Some files could fill the table until the column T8 (v_data_array (8)) and others could fill the columns up to T9 (v_data_array (9)). So I try to change this procedure in order to take account of the text file that will fill in column T9 (v_data_array (9)) but the only thing is fails for text files that fill will alone up to T8.

    The error was: ORA-01403: no data found. I tried using NVL (v_data_array (9), 'NULL'), but it does not work. How the procedure can be modified to accept two text files containing data up to columns T8 and T9.

    Thanks in advance.
    CREATE OR REPLACE PROCEDURE pr_file_upload
      (name_in IN varchar2)
    IS
    v_blob_data       BLOB; --will hold the binary structure
    v_blob_len        NUMBER; --The length of the BLOB in bytes
    v_position        NUMBER; --Will store the current position of the pointer in the blob
    v_raw_chunk       RAW(10000); --Incremental raw chunks of the BLOB will be read in the loop
    v_char            CHAR(1); --Stores the current character of the BLOB
    c_chunk_len       NUMBER := 1; --Stores the current length of the raw chunks in bytes.
    v_line            VARCHAR2 (32767) := NULL;  --Stores the value of the current line in the loop
    v_data_array      wwv_flow_global.vc_arr2;  --apex array size of 32,000
    v_name_in         VARCHAR2 (50);
    BEGIN
    
    
    -- Read data from APEX_APPLICATION_FILES view in APEX
    SELECT blob_content INTO v_blob_data
    FROM APEX_APPLICATION_FILES WHERE filename = name_in;
    
    
    v_blob_len := dbms_lob.getlength(v_blob_data);
    v_position := 1;
    
    -- Read and convert binary to char
    WHILE ( v_position <= v_blob_len ) LOOP
     v_raw_chunk := dbms_lob.substr(v_blob_data,c_chunk_len,v_position);
     v_char :=  chr(fn_hex_to_decimal(rawtohex(v_raw_chunk)));
     v_line := v_line || v_char;
     v_position := v_position + c_chunk_len;
    -- When a whole line is retrieved
     IF v_char = CHR(10) THEN
    -- Convert tab CHR(9) to : to use wwv_flow_utilities
       v_line := REPLACE (v_line, CHR(9), ':');
    -- Convert each column separated by : into array of data
       v_data_array := wwv_flow_utilities.string_to_table (v_line);
    -- Insert data into target table
       EXECUTE IMMEDIATE 'insert into TBL_TMP (t1, t2, t3, t4, t5, t6, t7, t8, t9)
        values (:1,:2,:3,:4,:5,:6,:7,:8,:9)'
        USING
          v_data_array(1),
          v_data_array(2),
          v_data_array(3),
          v_data_array(4),
          v_data_array(5),
          v_data_array(6),
          v_data_array(7),
          v_data_array(8),
          NVL(v_data_array(9),'NULL');   -- Need help here.  This is empty when reading text files that fills up to column T8.
    
    
    -- Clear out
       v_line := NULL;
      END IF;
     END LOOP;
    END;
    /

    NVL (v_data_array (9), 'NULL') will not work. Use:

    CASE WHEN v_data_array.EXISTS(9) THEN v_data_array(9) END
    

    SY.

  • Skip a page and print on the back using PL/SQL?

    Morning people,
    Greetings from Toronto. I have a report that was written in PL/SQL (not Oracle or SQL reports * most) and its job very well. The totals are correct and I have two sets of totals. A total for the Department in particular and, finally, a total of the entire company. The user of course wish the two totals for each same Department if he or she chooses to print only service (using a setting). So, it's not a problem.

    I just want to be the total final (company-wide) on the last page. Now, it is relatively simple in the reports of the Oracle, as well as SQL * more reports where I could probably use Skip. Y at - it a simple way to do or what I must count lines based on pagesize? So, for example, if the size of my page is 53 and my last record Department stops at line 35, I have to insert empty rows using UTF_FILE. Put_line in a FOR loop. This method would probably work ut I wonder if there's ways more interesting or easier to do?

    This issue does not have to decide at this moment and I know its Monday. :-) Any help would be appreciated.

    Concerning
    REDA

    Published by: Raj404261 on June 8, 2009 10:22

    Try:

        -- etc --
        UTL_FILE.FFLUSH (id);
        UTL_FILE.PUT_LINE(id,CHR(12));
        -- Write totals:
        -- etc --
    

    : p

  • using XPath with SQL to extract XML data

    Given the data like this:
    <?xml version="1.0"?>
    <ExtendedData>
       <Parameter name="CALLHOLD"><BooleanValue>true</BooleanValue></Parameter>
    
      <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
    
      <Parameter name="ALLCF"><BooleanValue>true</BooleanValue></Parameter>
    
      <Parameter name="RealProv"><BooleanValue>false</BooleanValue></Parameter>
    
    </ExtendedData>
    I usually use extractValue as shown below, for example function to extract the value for the last parameter in the above data, for example:
    select extractValue(extended_data,'/ExtendedData/Parameter[@name="RealProv"]/BooleanValue') "my_column_alias" from table
    Any ideas on how can I return the value of the parameter xsi: Nil for that node:
    <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
    I would like to extract the
    true
    in
    xsi:nil="true"
    ...

    Thank you

    Published by: HouseofHunger on May 15, 2012 14:13

    Published by: HouseofHunger on May 15, 2012 14:13

    ExtractValue() has a third parameter, that we can use to declare the namespace mappings:

    SQL> with sample_data as (
      2    select xmltype('
      3  
      4    true
      5    
      6    true
      7    false
      8  ') doc
      9    from dual
     10  )
     11  select extractvalue(
     12           doc
     13         , '/ExtendedData/Parameter[@name="BARRING_PASSWORD"]/@xsi:nil'
     14         , 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
     15         )
     16  from sample_data
     17  ;
    
    EXTRACTVALUE(DOC,'/EXTENDEDDAT
    --------------------------------------------------------------------------------
    true
     
    

    If you are on 11.2.0.2 and upward, extractvalue() is obsolete.
    Must use XMLCast/XMLQuery instead:

    SQL> with sample_data as (
      2    select xmltype('
      3  
      4    true
      5    
      6    true
      7    false
      8  ') doc
      9    from dual
     10  )
     11  select xmlcast(
     12           xmlquery('/ExtendedData/Parameter[@name="BARRING_PASSWORD"]/@xsi:nil'
     13            passing doc
     14            returning content
     15           ) as varchar2(5)
     16         )
     17  from sample_data
     18  ;
    
    XMLCAST(XMLQUERY('/EXTENDEDDAT
    ------------------------------
    true
     
    

    Note: the prefix xsi is predefined when using Oracle's XQuery, so in this case we must explicitly declare.

    Published by: odie_63 on May 15, 2012 15:23

  • Why get ORA-00942 during the validation of PL/SQL cursor

    The database is 10 gr 2.

    ST_PKG_UTILITIES contains a procedure called "p_insert_update_person_info".

    The procedure includes a cursor that selects a view 'CDS_CIS_ETHNICITY '.

    I am logged in as the owner of the schema of the package. The view lies in another schema, but I have the right to SELECT on the view.

    When I try to compile the package, I get "ORA-00942: table or view does not exist", pointing to the CDS_CIS_ETHNICITY view.

    However, if I SELECT directly from the view using a SQL window, it returns information without problem.

    Code view is a SELECT statement on a table across a db_link. However, given that I can select directly from the view, I am not clear why I would get the error because the view is selected, within PL/SQL.

    Note that the table was originally, on the same server that the schema that I am now, so no db_link was necessary. When the schema of the table has been moved to a new server, we added the db_link. However, the package was never changed, we were careful to reproduce the names of objects that are used by the package, when building the db_link.

    Ideas on this issue would be appreciated.

    Thank you
    VP

    Published by: user618800 on December 9, 2008 14:53

    Hello

    Grant privileges directly to the owner of the whole.

    Looks like the privileges that you have about this point of view have been granted to a role, and the owner of the package has this role.
    Roles do not count inside stored procedures. You must have privileges granted directly to the owner (or to the PUBLIC, which probably does not apply in this case).

  • Displays the dates of diff using PL/SQL expression for the item "display only"?

    Hello
    I have a single display element -: P2_FROM_Date. If his game, Fri, sat or Sun I want to put the date of the last Monday date. If its Mon, Mar or sea, it must be this date of Monday.

    Ex: Today is Friday and last Monday was 18.
    So yesterday, today, tomorrow and Sunday, the date appear as June 18, 2012.
    Since Monday to Wednesday, the date has to be the next that is Monday, June 24, 2012

    I tried under 'Source' from the element using PL/SQL expression and the body of the PL/SQL function. Does not

    Can anyone help?

    Thanks and greetings
    Umer

    1. you must set 'used source' "Always".
    2 If you use a PLSQL function as source type body should set a 'RETURN' statement like this:

    declare
    lv_date number;
    begin
    select to_char(sysdate,'D') into lv_date from dual;
    if lv_date=2 then
      return to_char(sysdate-1);
    end if;
    end;
    

    Published by: mario1977 on June 27, 2012 11:44

Maybe you are looking for

  • iPhone 6s won't save contacts numbers

    I have problems adding the telephone number of the appellants as new contact on my phone.  When I click on the number to add to contacts, the number is not saved in my contacts list.  The phone will recognize the number with the correct name, but it

  • Keep the faces when restoring iCloud

    Hello I use Photos on El Capitan 10.11.3 1.3. Recently my hard drive died, and I decided to clean install OS X on a new and then manually copy the files from a Time Machine backup needed. I chose to start a new photo library as well and synchronize i

  • in Lightroom color management

    I use Lightroom and mediocre results of my new iP8720 printer.  How can I turn off color management in the printer?

  • How to turn on help and support

    How can I turn on help and support, Windows XP

  • Eception error message blackBerry smartphones wait :(

    Hello... Im having loads of trouble with my 8900... I did a battery pull, but when I rebooted, I got the message eception waiting: net rim.device.api.system unsupported operation exception when I pressed ok, I couldn't see my sms, email, facebook or