473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 4242

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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...

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.