For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Please let me know what you think. We have added SQL*Plus support. See these web pages: SQL*Plus common commands: https://www.oracle.com/database/technologies/appdev/dotnet/odtvscodesqlplus.html SQL*Plus Reference: https://www.oracle.com/database/technologies/appdev/dotnet/odtvscodesqlplusref.html More features from the changelog: Changes in version 19.3.3 Connection Dialog enhancements: Set/Change the current schema, improved proxy user connection UI Improved connection failure detection with an option to reconnect Support for macOS connections to Oracle Autonomous Database over TLS Support for database connections using LDAP Browse other schemas ("Other Users" node) in Oracle Explorer tree control SQL History and Bookmarks Limited SQL*Plus support Detection and warning of unsupported SQL*Plus commands in scripts (and child scripts) SQL*Plus CONNECT command associates the file with a connection Preservation of all session associated properties from execution to execution Autocommit On/Off setting Autocompletion of SQL*Plus commands Autocompletion of procedure/function parameters Intellisense/Autocomplete performance enhancements Syntax coloring for SQL and PL/SQL keywords and SQL*Plus commands/variables Append new results to existing results window Toolbar buttons to cancel running query and to clear results window Setting to automatically clear results window after each execution Remember previous selections in some UI elements and offer as defaults Support for REFCURSOR variables and implicit cursors Visual Studio Code theme support for Light/Dark/High Contrast themes
SQL> with t as ( 2 select xmltype('<?xml version="1.0"?> 3 <purchase_order> 4 <po_items> 5 <item> 6 <name>#Name#</name> 7 <quantity>#number#</quantity> 8 </item> 9 </po_items> 10 </purchase_order>') xml from dual) 11 select x.* 12 from t, xmltable('/' PASSING t.xml COLUMNS 13 name varchar2(20) PATH '/purchase_order/po_items/item/name', 14 qty varchar2(20) PATH '/purchase_order/po_items/item/quantity') x; NAME QTY -------------------- -------------------- #Name# #number#
SQL> with t as ( 2 select xmltype('<?xml version="1.0"?> 3 <purchase_order> 4 <po_items> 5 <item> 6 <name>#Name#</name> 7 <quantity>#number#</quantity> 8 </item> 9 <item> 10 <name>#Name2#</name> 11 <quantity>#number2#</quantity> 12 </item> 13 <item> 14 <name>#Name3#</name> 15 <quantity>#number3#</quantity> 16 </item> 17 </po_items> 18 </purchase_order>') xml from dual) 19 select x.* 20 from t, xmltable('/purchase_order/po_items/item' PASSING t.xml COLUMNS 21 name varchar2(20) PATH '/item/name', 22 qty varchar2(20) PATH '/item/quantity') x; NAME QTY -------------------- -------------------- #Name# #number# #Name2# #number2# #Name3# #number3#
NAME QTY ---------------- ----------------- #Name# #number#
VALUE PATH -------------- ------------------------------ #Name# /purchase_order/po_items/item/name #number# /purchase_order/po_items/item/quantity
SQL> with t as ( 2 select xmltype('<?xml version="1.0"?> 3 <purchase_order> 4 <po_items> 5 <item> 6 <name>#Name#</name> 7 <quantity>#number#</quantity> 8 </item> 9 </po_items> 10 </purchase_order>') xml from dual) 11 select x.val, 12 '/purchase_order/po_items/item/'||xmlquery('for $i in /* return name($i)' 13 PASSING x.col RETURNING CONTENT) path 14 from t, xmltable('/purchase_order/po_items/item/*' PASSING t.xml COLUMNS 15 val varchar2(20) PATH '.', 16 col xmltype PATH '.') x; VAL PATH -------------------- -------------------------------------------------- #Name# /purchase_order/po_items/item/name #number# /purchase_order/po_items/item/quantity
with t as ( select xmltype('<?xml version="1.0"?> <purchase_order> <po_items> <item> <name>#Name#</name> <quantity>#number#</quantity> </item> </po_items> </purchase_order>') xml from dual) select x.val, '/purchase_order/po_items/item/'||x.col path from t, xmltable('/purchase_order/po_items/item/*' PASSING t.xml COLUMNS val varchar2(20) PATH '.', col varchar2(20) PATH 'name(.)') x;
SQL> with t as ( select xmltype('<?xml version="1.0"?> <purchase_order> <po_items> <item> <name>#Name#</name> <quantity>#number#</quantity> </item> </po_items> </purchase_order>') xml from dual ) select x.* from t t, xmltable('declare function local:index-of-node ( $nodes as node()* , $nodeToFind as node() ) as xs:integer* { for $seq in (1 to count($nodes)) return $seq[$nodes[$seq] is $nodeToFind] } ; declare function local:path-to-node-with-pos ( $node as node()? ) as xs:string { fn:string-join( for $ancestor in $node/ancestor-or-self::* let $sibsOfSameName := $ancestor/../*[fn:name() = fn:name($ancestor)] return fn:concat(fn:name($ancestor), if (fn:count($sibsOfSameName) <= 1) then "" else fn:concat( "[", local:index-of-node($sibsOfSameName,$ancestor),"]")) , "/") }; element e {local:path-to-node-with-pos(//item/name[. = "#Name#"]), element name {//name}}, element e {local:path-to-node-with-pos(//item/quantity[. = "#number#"]), element name {//quantity}}' passing t.xml columns value varchar2(50) path 'name', path varchar2(50) path 'text()' ) x VALUE PATH ---------- ---------------------------------------- #Name# purchase_order/po_items/item/name #number# purchase_order/po_items/item/quantity 2 rows selected.
SQL> with t as ( select xmltype('<?xml version="1.0"?> <purchase_order> <po_items> <quantity>#number#</quantity> <item> <price>#Price#</price> <name>#Name#</name> <quantity>#number#</quantity> </item> </po_items> </purchase_order>') xml from dual ) -- -- select x.* from t t, xmltable('declare function local:index-of-node ( $nodes as node()* , $nodeToFind as node() ) as xs:integer* { for $seq in (1 to count($nodes)) return $seq[$nodes[$seq] is $nodeToFind] } ; declare function local:path-to-node-with-pos ( $node as node()? ) as xs:string { fn:string-join( for $ancestor in $node/ancestor-or-self::* let $sibsOfSameName := $ancestor/../*[fn:name() = fn:name($ancestor)] return fn:concat(fn:name($ancestor), if (fn:count($sibsOfSameName) <= 1) then "" else fn:concat( "[", local:index-of-node($sibsOfSameName,$ancestor),"]")) , "/") }; for $i in //po_items//* where ora:matches ($i, "^#\w+#$") return element e {local:path-to-node-with-pos($i), $i}' passing t.xml columns value varchar2(50) path '*', path varchar2(50) path 'text()' ) x / VALUE PATH ---------- ---------------------------------------- #number# purchase_order/po_items/quantity #Price# purchase_order/po_items/item/price #Name# purchase_order/po_items/item/name #number# purchase_order/po_items/item/quantity 4 rows selected.
WITH tab AS (SELECT xmltype('<?xml version="1.0"?> <purchase_order> <po_items> <quantity>#number#</quantity> <item> <price>#Price#</price> <name>#Name#</name> <quantity>#number#</quantity> </item> </po_items> </purchase_order>') col FROM dual ) SELECT column_value FROM tab t, xmltable(' for $i in $tmp/descendant::* where $i/text() != "" return concat(string-join($i/ancestor-or-self::*/name(), "/"),"/","#",data($i),"#") ' passing t.col AS "tmp" )
SQL> ed Wrote file afiedt.buf 1 WITH tab AS 2 (SELECT xmltype('<?xml version="1.0"?> 3 <purchase_order> 4 <po_items> 5 <quantity>#number#</quantity> 6 <item> 7 <price>#Price#</price> 8 <name>#Name#</name> 9 <quantity>#number#</quantity> 10 </item> 11 </po_items> 12 </purchase_order>') col 13 FROM dual 14 ) 15 SELECT nodepath,nodevalue 16 FROM tab t, 17 xmltable(' 18 for $i in $tmp/descendant::* 19 where $i/text() != "" 20 return <R><P>{string-join($i/ancestor-or-self::*/name(), "/")}</P><V>{$i/text()}</V></R> 21 ' passing t.col AS "tmp" columns 22 nodepath varchar2(50) path '//P', 23* nodevalue varchar2(50) path '//V') SQL> / NODEPATH NODEVALUE -------------------------------------------------- ------------------------------------------------- purchase_order/po_items/quantity #number# purchase_order/po_items/item/price #Price# purchase_order/po_items/item/name #Name# purchase_order/po_items/item/quantity #number#
office.text/text:p L?muma Nr.#numurs#
office.text/text:p #numurs#
SQL> ed Wrote file afiedt.buf 1 WITH tab AS 2 (SELECT xmltype('<?xml version="1.0"?> 3 <purchase_order> 4 <po_items> 5 <quantity>#number#</quantity> 6 <item> 7 <price>#Price#</price> 8 <name>#Name#</name> 9 <quantity>#number#</quantity> 10 </item> 11 </po_items> 12 </purchase_order>') col 13 FROM dual 14 ) 15 SELECT nodepath,nodevalue 16 FROM tab t, 17 xmltable(' 18 for $i in $tmp/descendant::* 19 where $i/text() = "#number#" 20 return <R><P>{string-join($i/ancestor-or-self::*/name(), "/")}</P><V>{$i/text()}</V></R> 21 ' passing t.col AS "tmp" columns 22 nodepath varchar2(50) path '//P', 23* nodevalue varchar2(50) path '//V') SQL> / NODEPATH NODEVALUE -------------------------------------------------- ------------------------------------------------- purchase_order/po_items/quantity #number# purchase_order/po_items/item/quantity #number#
where $i/text() = "#number#"
xmltype('<?xml version="1.0"?> <purchase_order> <po_items> <quantity>NUmber of Number: #number#</quantity> <item> <price>Unit price: #Price#</price> <name> Unit name#Name#</name> <quantity>Unit qant: #number#</quantity> </item> </po_items> </purchase_order>') col
PATH VALUE -------------------------------------- ----------- purchase_order/po_items/quantity #number# purchase_order/po_items/item/quantity #Price# purchase_order/po_items/item/quantity #Name# purchase_order/po_items/item/quantity #number#
WITH tab AS (SELECT xmltype('<?xml version="1.0"?> <purchase_order> <po_items> <quantity>NUmber of Number: #number#</quantity> <item> <price>Unit price: #Price#</price> <name> Unit name#Name#</name> <quantity>Unit qant: #number#</quantity> </item> </po_items> </purchase_order>') col FROM dual ) SELECT nodepath,regexp_substr(nodevalue,'#.*#') nodevalue FROM tab t, xmltable(' for $i in $tmp/descendant::* where $i/text() != "" return <R><P>{string-join($i/ancestor-or-self::*/name(), "/")}</P><V>{$i/text()}</V></R> ' passing t.col AS "tmp" columns nodepath varchar2(50) path '//P', nodevalue varchar2(50) path '//V')
regexp_substr(nodevalue,'#.*#')
SQL> create table test(nodepath varchar2(40),nodetext varchar2(40)); Table created. SQL> ed Wrote file afiedt.buf 1 insert into test 2 WITH tab AS 3 (SELECT xmltype('<?xml version="1.0"?> 4 <purchase_order> 5 <po_items> 6 <quantity>NUmber of Number: #number#</quantity> 7 <item> 8 <price>Unit price: #Price#</price> 9 <name> Unit name#Name#</name> 10 <quantity>Unit qant: #number#</quantity> 11 </item> 12 </po_items> 13 </purchase_order>') col 14 FROM dual 15 ) 16 SELECT nodepath,regexp_substr(nodevalue,'#.*#') nodevalue 17 FROM tab t, 18 xmltable(' 19 for $i in $tmp/descendant::* 20 where $i/text() != "" 21 return <R><P>{string-join($i/ancestor-or-self::*/name(), "/")}</P><V>{$i/text()}</V></R> 22 ' passing t.col AS "tmp" columns 23 nodepath varchar2(50) path '//P', 24* nodevalue varchar2(50) path '//V') SQL> / 4 rows created. SQL> select * from test; NODEPATH NODETEXT ---------------------------------------- ---------------------------------------- purchase_order/po_items/quantity #number# purchase_order/po_items/item/price #Price# purchase_order/po_items/item/name #Name# purchase_order/po_items/item/quantity #number# SQL> drop table test; Table dropped. SQL>
this is code in package: TYPE Var_Names IS RECORD ( v_name VARCHAR2(100), XPath VARCHAR2(500) ); TYPE Var_Name_List IS TABLE OF Var_Names; Variables Var_Name_List; this is code in body package: FUNCTION selectVariablesInList(tempXML XMLType) RETURN Var_Name_List IS BEGIN WITH tab AS (SELECT tempXML col FROM dual ) SELECT nodepath, regexp_substr(nodevalue,'#.*#') nodevalue INTO Variables FROM tab t, xmltable(' for $i in $tmp/descendant::* where $i/text() != "" return <R><P>{string-join($i/ancestor-or-self::*/name(), "/")}</P><V>{$i/text()}</V></R>' passing t.col AS "tmp" columns nodepath varchar2(50) path '//P', nodevalue varchar2(50) path '//V'); RETURN Variables; END;
SQL> ed Wrote file afiedt.buf 1 CREATE OR REPLACE type type_node 2 AS 3 object 4 ( 5 nodepath VARCHAR2(100), 6* nodevalue VARCHAR2(500) ); SQL> / Type created. SQL> ed Wrote file afiedt.buf 1 CREATE OR REPLACE type type_node_tab 2 AS 3* TABLE OF type_node; SQL> / Type created. SQL> ed Wrote file afiedt.buf 1 create or replace 2 PACKAGE test_ravi AS 3 function selectVariablesInList (tempXML XMLType) RETURN type_node_tab; 4* END test_ravi; SQL> / Package created. SQL> ed Wrote file afiedt.buf 1 create or replace 2 PACKAGE BODY test_ravi AS 3 FUNCTION selectVariablesInList(tempXML XMLType) RETURN type_node_tab 4 IS 5 v_type_node_tab type_node_tab; 6 BEGIN 7 select cast(multiset( 8 select nodepath,nodevalue from ( 9 WITH tab AS 10 (SELECT tempXML col 11 FROM dual 12 ) 13 SELECT nodepath,regexp_substr(nodevalue,'#.*#') nodevalue 14 FROM tab t, 15 xmltable(' 16 for $i in $tmp/descendant::* 17 where $i/text() != "" 18 return <R><P>{string-join($i/ancestor-or-self::*/name(), "/")}</P><V>{$i/text()}</V></R>' 19 passing t.col AS "tmp" columns 20 nodepath VARCHAR2(100) path '//P', 21 nodevalue VARCHAR2(500) path '//V')) 22 ) as type_node_tab) into v_type_node_tab from dual; 23 RETURN v_type_node_tab; 24 END; 25* END test_ravi; SQL> / Package body created. SQL> ed Wrote file afiedt.buf 1 select * from table(test_ravi.selectvariablesinlist(xmltype('<?xml version="1.0"?> 2 <purchase_order> 3 <po_items> 4 <quantity>NUmber of Number: #number#</quantity> 5 <item> 6 <price>Unit price: #Price#</price> 7 <name> Unit name#Name#</name> 8 <quantity>Unit qant: #number#</quantity> 9 </item> 10 </po_items> 11* </purchase_order>'))) SQL> / NODEPATH ---------------------------------------------------------------------------------------------------- NODEVALUE ---------------------------------------------------------------------------------------------------- purchase_order/po_items/quantity #number# purchase_order/po_items/item/price #Price# purchase_order/po_items/item/name #Name# NODEPATH ---------------------------------------------------------------------------------------------------- NODEVALUE ---------------------------------------------------------------------------------------------------- purchase_order/po_items/item/quantity #number# SQL>