473,473 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help with returning XML from Oracle function to JSP

Greetings,

(I am an Oracle newbie -- been working with SQLServer for quite some
time, however. I'm using Oracle9i and Oracle9i JDeveloper v9.0.3.1
(build 1107) for my programming environment).

I'm trying to get an Oracle function to return XML to a JSP page, but
am having some problems (mostly Oracle errors). Let me start by
showing you what I've done so far.

I have a test table, PERSON, with the following basic structure:

Name Null? Type
--------------------- -------- ---------------
PERSON_ID NOT NULL NUMBER(19)
FNAME NOT NULL VARCHAR2(30)
LNAME NOT NULL VARCHAR2(30)

I have successfully called an Oracle function and received a "static"
return value in my JSP page, with the following excerpt of code (the
function exemplifed here as "myFunc()"):
<%@ page import="java.sql.*"%>

<%
Connection oCn = null;
CallableStatement oCallStmt = null;
String sRetVal = null;

Class.forName("oracle.jdbc.driver.OracleDriver").n ewInstance();
oCn = DriverManager.getConnection(sDBConn, sDBUser, sDBPass);

oCallStmt = oCn.prepareCall("{? = call myFunc()}");
oCallStmt.registerOutParameter(1, java.sql.Types.VARCHAR);

oCallStmt.execute();

sRetVal = oCallStmt.getString(1);

oCallStmt.close();
oCn.close();
%>

Now I have created a new Oracle function named "getXMLTest" as
follows:

01 FUNCTION getXMLTest
02 RETURN CLOB
03
04 AS
05
06 oXML CLOB;
07
08 BEGIN
09 SELECT
10 XMLElement("Person",
11 XMLAttributes(Person_ID AS ID),
12 XMLForest
13 (
14 FNAME AS "FirstName",
15 LNAME AS "LastName"
16 )
17 )
18 INTO oXML
19 FROM PERSON;
20
21 RETURN oXML;
22 END;
Here's where the trouble starts. First of all, when I try to compile
the function, I get the following errors in JDeveloper:

- Error(10,65530): PL/SQL: SQL Statement ignored
- Error(11,15): PL/SQL: ORA-00932: inconsistent datatypes: expected
NUMBER got -

When I take the SELECT statement by itself and run it in SQL*Plus, it
outputs the XML just fine. So what is going wrong here?

I had intended on using the above JSP (with one mod, defining the
registerOutParameter as java.sql.TsDBHost.Clob) to handle the returned
XML. Am I even on the right track here? I want to be able to
navigate and manipulate the XML in the JSP page as a document object.

Any helpful direction would be MOST appreciated.

Thanks,
Bryan Jackson
Jul 19 '05 #1
0 4247

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William Buchanan | last post by:
Hi I have the following stored proc in interbase (which might contain errors - i'm doing it off the top of my head), which I would like to convert into oracle. Can you help? What I want back is...
4
by: Roger Redford | last post by:
Dear Experts, I'm attempting to marry a system to an Oracle 817 datbase. Oracle is my specialty, the back end mainly, so I don't know much about java or javascript. The system uses javascript...
1
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this...
6
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query...
0
by: schan | last post by:
Hi there, I was wondering if someone could shed some light on a problem I have no idea on how to fix. I created an Excel Add-In that uses an ADO connection to an Access database on a file...
0
by: bw171 | last post by:
Hopefully, I frame this problem/question correctly. I have some code written/updated in visual studio 2003. This code when setup on other machines where I have installed the Oracle 9i client, and...
0
by: anuptosh | last post by:
Hi, I have been trying to run the below example to get a Oracle Array as an output from a Java code. This is an example I have found on the web. But, the expected result is that the code should...
0
by: Alex | last post by:
Hi, I am a complete beginner with Oracle 9i and XML within it, not XML alone though. I am trying to do a regular SELECT statement using the SQL Scratchpad within the Oracle Enterprise Manager and...
0
by: Bryan Jackson | last post by:
Greetings, (I am an Oracle newbie -- been working with SQLServer for quite some time, however. I'm using Oracle9i and Oracle9i JDeveloper v9.0.3.1 (build 1107) for my programming environment)....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.