Skip to Main Content

DevOps, CI/CD and Automation

Announcement

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!

Count Distinct-Values ORA-01762: vopdrv: view query block not in FROM

883286Aug 26 2011 — edited Aug 26 2011
Greetings,
I am experiencing consistent errors using SQL*Plus XQuery processor and the processor internal to the 11g database using XMLQUERY and XMLTABLE using count and distinct-values functions. In other cases where I have encountered bugs in these processors I have mostly been able to work around them. I encountered this problem using 11.2.0.1 and upgraded to 11.2.0.2 hoping for resolution. However, simple use of count and distinct-values fails.

I am experiencing this error using a variety of documents both from XMLTYPE tables/columns and XDB repository. The example I provide below is from the following book:

XQuery
By: Priscilla Walmsley
Publisher: O'Reilly Media, Inc.
Pub. Date: March 30, 2007

SQL> select * from v$version;
Enter
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

5 rows selected.

SQL> set xquery baseuri "/home/learn/"
SQL> xquery doc ("catalog.xml")
2 /
Enter
Result Sequence
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<catalog>
<product dept="WMN">
<number>557</number>
<name language="en">Fleece Pullover</name>
<colorChoices>navy black</colorChoices>
</product>
<product dept="ACC">
<number>563</number>
<name language="en">Floppy Sun Hat</name>
</product>
<product dept="ACC">
<number>443</number>
<name language="en">Deluxe Travel Bag</name>
</product>
<product dept="MEN">
<number>784</number>
<name language="en">Cotton Dress Shirt</name>
<colorChoices>white gray</colorChoices>
<desc>Our <i>favorite</i> shirt!</desc>
</product>
</catalog>


1 item(s) selected.

SQL> xquery
2 let $depts := doc ("catalog.xml")/catalog/product/@dept
3 return count ($depts)
4 /
Enter
Result Sequence
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4

1 item(s) selected.

SQL> edit
Wrote file afiedt.buf

1 xquery
2 let $depts := doc ("catalog.xml")/catalog/product/@dept
3* return count (distinct-values ($depts))
SQL> /
ERROR:
ORA-01762: vopdrv: view query block not in FROM


SQL> select column_value from xmltable ('declare base-uri "/home/learn/"; (: :)
2 let $depts := doc ("catalog.xml")/catalog/product/@dept
3 return count ($depts)
4 ');
Enter
COLUMN_VALUE
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4

1 row selected.

SQL> edit
Wrote file afiedt.buf

1 select column_value from xmltable ('declare base-uri "/home/learn/"; (: :)
2 let $depts := doc ("catalog.xml")/catalog/product/@dept
3 return count (distinct-values ($depts))
4* ')
SQL> /
select column_value from xmltable ('declare base-uri "/home/learn/"; (: :)
*
ERROR at line 1:
ORA-01762: vopdrv: view query block not in FROM


Any assistence will be greatly appreciated.

Best Regards
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 23 2011
Added on Aug 26 2011
1 comment
1,896 views