Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> 17021 Missing defines error after dbms_xmlquery getXML(), Solaris9, Oracle 10G

17021 Missing defines error after dbms_xmlquery getXML(), Solaris9, Oracle 10G

From: Tomasz Romanowski <tromanow_at_hotmail.com>
Date: 21 Oct 2004 10:25:16 -0700
Message-ID: <84e67408.0410210925.78331604@posting.google.com>


All I'm trying to do is tu run a basic, sample program to XML-format some data using the dbms_xmlquery PL/SQL package. Enviro details: Solaris 9, Oracle 10.03G. After the call to dbms_xmlquery.getXML an exception is thrown with an error code of 17021. According to the documentation this is a jdbc error (btw. that's all that Oracle documentation has to say about it) but a java program that uses the same XSU API runs just fine. See the PL/SQL and the java sources below.

PL/SQL (produces "ex caught 17021 Missing defines"): set serveroutput on
declare
  queryCtx DBMS_XMLquery.ctxType;
  result CLOB;
  errorNum integer;
  errorMsg varchar2(512);
  xmlstr varchar2(32767);
  line varchar2(2000);

begin
  queryCtx := DBMS_XMLQuery.newContext(

       'select customer_number from customer');

  dbms_xmlquery.setMaxRows(queryCtx, 1);   DBMS_XMLquery.setRaiseException(queryCtx, true);

  result := dbms_xmlquery.getXML(queryCtx);   xmlstr := dbms_lob.substr(result,32767);   loop
    exit when xmlstr is null;
    line := substr(xmlstr,1,instr(xmlstr,chr(10))-1);     dbms_output.put_line('| '||line);
    xmlstr := substr(xmlstr,instr(xmlstr,chr(10))+1);   end loop;
  DBMS_XMLQuery.closeContext(queryCtx); -- you must close the query handle..

exception
  when others then
    dbms_xmlquery.getexceptioncontent(queryctx, errorNum, errorMsg);

     dbms_output.put_line('ex caught ' || to_char(errorNum) || ' ' ||
       errorMsg);

end;
/

Java (runs fine):
import oracle.jdbc.driver.*;
import oracle.xml.sql.query.OracleXMLQuery; import java.lang.*;
import java.sql.*;

// class to test the String generation
class testXMLSQL {

   public static void main(String[] argv)    {

     try{    

// create the connection
Connection conn = getConnection("user","password");
// Create the query class.
OracleXMLQuery qry = new OracleXMLQuery(conn, "select customer_number from customer"); qry.setMaxRows(1); qry.setRaiseException(true);
// Get the XML string
String str = qry.getXMLString();
// Print the XML output
System.out.println(" The XML output is:\n"+str);
// Always close the query to get rid of any resources..
qry.close(); }catch(SQLException e){ System.out.println(e.toString()); }

   }

   // Get the connection given the user name and password..!    private static Connection getConnection(String username, String password)

     throws SQLException
   {

// register the JDBC driver..

       DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());

// Create the connection using the OCI8 driver

       Connection conn =
        DriverManager.getConnection("jdbc:oracle:oci8:@",username,password);

      return conn;

   }
} Received on Thu Oct 21 2004 - 12:25:16 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US