How to fetch %ROWTYPE OUT param of a stored procedure from Java program?
I have a stored procedure that has IN / OUT parameter as table_name%ROWTYPE.
From a java program how can I access this ROWTYPE variable?
I tried all possible documentation and none of the explains whether or not this is supported.
My use case expect exactly 1 record from the procedure and we would prefer not to use REF CURSOR.
Is there a way to achieve this? If so, can someone help me with it by posting the sample code to achieve this?
I tried all the possible OracleTypes to register the OutParameter and they all fail.
Looks like there isn't any equivalent of %ROWTYPE in OracleTypes either.
If you need, I can post my sample procedure that uses %ROWTYPE as OUT parameter.
I really appreciate your help in this regard.
- Karthik
Hi,
If "returning only 1 record" the showstopper for not using Ref Cursor, you might want to reconsider because as you probably know, the ref cursor is only a pointer and requires additional step to retrieve the data.
Kuassi
Similar Messages
-
How to pass the parameter values to the stored procedure from java code?
I have a stored procedure written in sqlplus as below:
create procedure spInsertCategory (propertyid number, category varchar2, create_user varchar2, create_date date) AS BEGIN Insert into property (propertyid, category,create_user,create_date) values (propertyid , category, create_user, create_date); END spInsertCategory;
I am trying to insert a new row into the database using the stored procedure.
I have called the above procedure in my java code as below:
CallableStatement sp = null;
sp = conn.prepareCall("{call spInsertCategory(?, ?, ?, ?)}");
How should I pass the values [propertyid, category, create_user, create_date) from java to the stored procedure?[i.e., parameters]
Kindly guide me as I am new to java..Java-Queries wrote:
I have a stored procedure written in sqlplus as below:FYI. sqlplus is a tool from Oracle that provides a user interface to the database. Although it has its own syntax what you posted is actually PL/SQL. -
How to call stored procedures from java program?
I have tried to run a program that calls a stored procedure on MySQL
server version 5.0.17 by using connector/j 5.0, but it always fails on the
statement: con.preparecall() ,
have looked on the internet and found out that people can all mysql
stored procedure all right in their programs, really dont know what's
wrong with this small peiece of code:
import java.sql.*;
public class TestDB {
// procedure being called is:
CREATE PROCEDURE `dbsaystorm`.`getsite` ()
BEGIN
select name from tblsite;
END
public static void main(String[] args) {
try {
//Class.forName("org.gjt.mm.mysql.Driver");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/dbname",
"user", "pwd");
* executing SQL statement here gives perfect correct results:
// PreparedStatement ps = con.prepareStatement("select name from tblsite");
// ResultSet rs =ps.executeQuery();
// but in stored procedure way...
//it fails here on this prepare call statement:
CallableStatement proc = con.prepareCall("call getsite()");
ResultSet rs =proc.executeQuery();
if (rs == null) return;
while (rs.next()){
System.out.println("site name is: "+ rs.getString(1));
rs.close();
} catch (SQLException e) {e.printStackTrace();}
catch (Exception e) {e.printStackTrace();}
}it always gives this exception:
java.lang.NullPointerException
at com.mysql.jdbc.StringUtils.indexOfIgnoreCaseRespectQuotes(StringUtils.java:959)
at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1280)
at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:3668)
at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:638)
at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:453)
at com.mysql.jdbc.Connection.parseCallableStatement(Connection.java:4365)
at com.mysql.jdbc.Connection.prepareCall(Connection.java:4439)
at com.mysql.jdbc.Connection.prepareCall(Connection.java:4413)
at saystorm.server.data.database.TestDB.main(TestDB.java:29)
where have I gone wrong?
when I commented out the statement that makes the procedure call and call preparedstatement to execute SQL select statement, it gave perfectly correct result.
it looks like there is no problem with java prog accessing MYSQL server database, but the it seems that it's just java can't call stored procedure stored on the mysql server version 5.
can it or can't it? if it can, how is that accomplished?It is a bug in the driver because it shouldn't be
returning that exception (null pointer) even if you
are doing something wrong.
Are you using the latest version of the driver?
The stored procedure runs when you run it from the
gui/command line using a MySQL tool - correct?
As suggested you should be using the brackets. What
is the data type of the 'name' field?
You could try returning another value like one of the
following
select 1, name from tblsite;
select name, 1 from tblsite;
That might get around the bug
Additionally try just the following...
select 'test' from tblsite;yes, the driver used is in connector/j 5.0--the lastest one, and the
procedure can run correctedly at either command line or GUI mode
with no problem whatsoever, the returned data type is string type,
I have not got the chance to test it again with those values you
suggested, as I have abandoned the laptop I used to write that code
initately. There have been some other really weird cases happened on
that computer. I guess that must be something wrong with the JVM
installed on it, it was upgraded from jre5.0.04 to 06, and to 09.
something within hte JVM must have been messed up(the only reasonable
explanation). Because the same code runs correctly on my new laptop,
using the same environment: jvm 5.0_09, mysql 5.0.18, connector/J 5.0.
that old laptop really was a nightmare. -
How to send a Varying Array param to a PL/SQL Stored Procedure from Java
* I am VERY new to jdbc, and even somewhat new to Java
* I'm using Java 1.5, Oracle 10g.
* I need to call the following PL/SQL Stored Procedure from Java:
procedure setEventStatus
i_deQueueStatus in deQueueStatus_type
*deQueueStatus_type is the following (an array of deQueueStatus_OBJ):
CREATE OR REPLACE TYPE deQueueStatus_OBJ as object
eventID number (20),
dequeuestatus varchar2(20)
CREATE OR REPLACE TYPE deQueueStatus_TYPE IS VARYING ARRAY(500) of deQueueStatus_obj
*I have created a Java object as follows:
public class EventQueueDeQueueStatus
long eventID;
String dequeueStatus;
EventQueueDeQueueStatus(long eventID, String dequeueStatus)
this.eventID = eventID;
this.dequeueStatus = dequeueStatus;
I have an ArrayList of these.
I need to pass this list to the Stored Procedure. How do I create a java.sql.Array so I can call CallableStatement.setArray to set the parameter? Or do I use something else? I have tried setObject with both the ArrayList and also with a primitive array, but got "Invalid Column Type" both times.
Any help would be greatly appreciated. I just got this task today, and I have to make it work by Tuesday :-( !
Thanks,
KathyKathy,
Search the archives of this forum and the JDBC forum for the terms STRUCT and ARRAY and you can find some sample code on the JDBC How-To Documents page and the JDBC Samples which can both be accessed from this page:
http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html
Good Luck,
Avi. -
How to send an array of values to stored procedures in java
can anyone tell me how ican send a two dimensional array of string values can be send to a data base at one go.
actually i am a java developer and the technolgies i am using are servlets and java data base connectivity(JDBC). the oracle developer with whom i have worked has created aprocedure for taking the two values. she has created a record and she has used the the record as an in parameter to the procedure. that particular record has two columns and i need to send it as a two dimensional array.The PL/SQL webservice functionality in Oracle WebServices can expose PL/SQL procedures as webservices.
If you are just looking for Java solution, check out JPublisher, which maps PL/SQL stored procedure into JDBC programs. -
How to edit the existing data in the XML file from java programming.
Hi all
i am able to create XML file with the sample data as below from java programming.
i need sample code on how to edit the existing data in the XML file?
for example
<?xml version="1.0"?>
<mydata>
<data1>
<key1>467</key1>
<name1>Paul</name1>
<id1>123</id1>
</data1>
<data2>
<key2>467</key2>
<name2>Paul</name2>
<id2>123</id2>
</data2>
</mydata>
i am able to insert the data in the XML.
now i need sample code on how to modify the data in the above XML file from the java programming for only key2,name2,id2 tags only. the remaining tags data in the XML file i want to keep same data except for key2,name2,id2 which are i want to modify from java code
Regards
Sunil
[points will be always rewardable]hi
u need a parser or validate the xml file for to read the xml file from java coding u need for this
xml4j.jar u can download this file from here
http://www.alphaworks.ibm.com/tech/xml4j
or we can use the SAX(simple API for XML)
some sample applications for this
http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html
http://www.developertutorials.com/tutorials/java/read-xml-file-in-java-050611/page1.html
http://www.xml-training-guide.com/e-xml44.html
let me know u need any other info
bvr -
How to call PL-SQL script/stored procedure from Java?
Assume I want to call a PL-SQL stored procedure from external Java program.
How can I do this?
Is there a simple "Hello world" example for this?
PeterThis forum is for Oracle only not for java
Ug -
How to fetch data to APEX Report using stored procedure?
hi all,
i am making a report in APEX. user selects two dates and clicks GO button - i have a Stored Procedure linked to that result region so Stored Procedure gets called.
my stored procedure does the following -
using specified dates (IN) i do query and put data into a table (this table has been created only for this report) -
i want to show all these data i entered into the table on my APEX report in the same procedure call. can i use ref cursor to return? how to do that?
currently, i use another button in APEX which basically fetches all data from table. basically, user clicks one button to generate report and then another button to get report. which is not desirable at all :(
i m using APEX 3.1.2.00.02 and Oracle 10 database.
pls let me know if you need further clarification of the problem. thanks in advance.
regards,
probashi
Edited by: porobashi on May 19, 2009 2:53 PMThanks Tony.
I am not sure what you meant by >> change the report to be based off of a query returning sql statement, no need to keep that table around.... >>
Here's my stored procedure
create or replace
PROCEDURE ABC_PROC (
START_DATE IN DATE,
END_DATE IN DATE
AS
RULE_REC MTG_OFFICER_FORECAST%ROWTYPE;
TYPE REF_CURSOR IS REF CURSOR;
TCUR REF_CURSOR;
BEGIN
DELETE FROM ABC_REPORT;
OPEN TCUR FOR
SELECT ABC_FORECAST.*
from MTG_OFFICER_FORECAST , MTG_USERS
WHERE MTG_OFFICER_FORECAST.NBR_OFFICER = MTG_USERS.NBR_OFFICER AND
MTG_OFFICER_FORECAST.NBR_INSTITUTION = MTG_USERS.NBR_INSTITUTION;
LOOP
FETCH TCUR INTO RULE_REC;
EXIT WHEN TCUR%NOTFOUND;
INSERT INTO ABC_REPORT( NBR_OFFICER, OFFICER_NAME, FORECAST_NBR_LOANS, FORECAST_LOAN_AMT, FORECAST_FEES,
ACTUAL_NBR_LOANS, ACTUAL_LOAN_AMT, ACTUAL_FEES, RATIO_NBR_LOANS, RATIO_LOAN_AMT, RATIO_FEES, NBR_INSTITUTE )
VALUES ( RULE_REC.NBR_OFFICER, RULE_REC.NAME_LOAN_OFFICER, RULE_REC.NBR_LOANS, RULE_REC.AMT_LOAN, RULE_REC.AMT_FEES,
ACTUAL_NBR_LOANS, ACTUAL_LOAN_AMOUNT, ACTUAL_FEES, SUCCESS_RATIOS_NBR_LOANS_PERC, SUCCESS_RATIOS_LOAN_AMT_PERC, SUCCESS_RATIOS_FEES_PERC, RULE_REC.NBR_INSTITUTION );
END LOOP;
CLOSE TCUR;
END ABC_PROC;
Thanks,
Probashi
Edited by: porobashi on Jun 2, 2009 11:43 AM -
How to retrieve the outer parameter of a stored procedure in XSQL page
I have to call a stored procedure in the xsql page that returns a resultset (ie. oracle table/record type) through an outer paramter. Is there any built-in xsql action tag available to get the parameter and present
it in xml on the page? please help, thanks.You cant get two resultsets out of SP like this. The workaround is to merge and bring the resultsets.
For this number of columns as well as corresponding datatypes have to be compatible. Also you will need one additional column which indicates resultset value. Then use this as filter to get your desired resultset out
create procedure GetData as
begin
select 'resultset1' as Cat,*,.. N columns from Emp
union all
select 'resultset2' as Cat,*,.. N columns from Dept
end
create table #tmp1 (Ddeptid int, deptname varchar(500),Location varchar(100))
Insert into #tmp1 (Ddeptid , deptname ,Location )
Select column1,column2,column3
from OPENROWSET('SQLOLEDB','Data Source=Server_name;Trusted_Connection=yes;
Integrated Security=SSPI','Execute yourdb..GetData')
WHERE Cat = 'resultset1'
create table #tmp (empid int , ename varchar(500),DeptId int , salary int)
Insert into #tmp (empId,ename,deptId,salary)
Select column1,column2,column3, column4
from OPENROWSET('SQLOLEDB','Data Source=Server_name;Trusted_Connection=yes;
Integrated Security=SSPI','Execute yourdb..GetData')
WHERE Cat = 'resultset2'
also see
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/11/26/select-columns-from-exec-procedure-name-is-this-possible.aspx
Another method is to populate table with relevant resultset within procedure itself and then select from the table directly outside.
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
How to access the stored procedures from Java
Hi,
There is stored procedure in oracle sql and that have two input parameters and recordset as an output parameter.
eg.
CREATE OR REPLACE PROCEDURE Test(
p_Age JUNK.Age%Type,
p_SURNAME JUNK.SURNAME%TYPE,
RC1 IN OUT P_GETALLTOPICDATAPkg.RCT1)
Now i want to execute this by using Java JDBC.I have wrote the following code,
but how to convert "String data to Clob data".
Code is :
String strSPName = "{ call Test(?,?,?) }"; oracle.jdbc.driver.OracleCallableStatement cstmt = (oracle.jdbc.driver.OracleCallableStatement)MyConn.prepareCall(strSPName);
cstmt.setInt(1, 001);
String ClobData ="AMMA AAI MA";
cstmt.setClob(2, (java.sql.Clob)ClobData); above gives error*/
cstmt.execute();
Can any body help.
nullTry using setCharacterStream (this should work in 816 I am not sure of prior Oracle/JDBC releases)
String ClobData ="AMMA AAI MA";
java.io.StringReader sr = java.io.StringReader(ClobData);
cstmt.setCharacterStream(2,sr,ClobData.length());
cstmt.execute();
Good luck -
I have a stored proc that is defined as
CREATE or REPLACE
PROCEDURE ABC
(linkid IN CHAR,
Year_in IN DATE,
Method_in IN CHAR,
Date_out OUT DATE,
average_out OUT NUMBER)
is
begin
end;
another partially completed stored proc that returns a ref
cursor defined as follows:
create or replace package zzz
as
type cursorType is ref cursor;
end;
create or replace function test return zzz.cursortype
as
date_OUT date;
Average_OUT number;
l_cursor zzz.cursorType;
CURSOR temp_cur is
SELECT l.linkid, L.routenumber, ABC(l.linkid,
to_date('01/01/2000', 'mm/dd/yyyy'),
'2',
date_OUT,
average_OUT)
FROM LINK l
WHERE l.LINKID <= '010999';
begin
open temp_cur;
end;
inside test (which I need help completing), how can I refer to
the date_out and the average_out params returned by ABC() so
that these values are in turn passed to the cursortype defined
in package zzz?
Thanks in advance.Try rewriting your abc proceudre as two functions, abc1 and
abc2, and rewriting your test function as a test procedure. See
if you can fill in the blanks prefaced by hyphens -- in the
following code:
CREATE OR REPLACE FUNCTION abc1
(linkid IN CHAR,
year_in IN DATE,
method_in IN CHAR)
RETURN DATE
IS
date_out DATE;
BEGIN
SELECT --
INTO date_out
FROM --
WHERE --;
--or
date_out := --;
RETURN date_out;
END abc1;
CREATE OR REPLACE FUNCTION abc2
(linkid IN CHAR,
year_in IN DATE,
method_in IN CHAR)
RETURN NUMBER
IS
average_out NUMBER;
BEGIN
SELECT AVG (--)
INTO average_out
FROM --
WHERE --
GROUP BY --;
--or
average_out := --;
RETURN average_out;
END abc2;
CREATE OR REPLACE PACKAGE zzz
AS
TYPE cursortype IS REF CURSOR;
PROCEDURE test
(temp_cur OUT cursortype);
END zzz;
CREATE OR REPLACE PACKAGE BODY zzz
AS
PROCEDURE test
(temp_cur OUT cursortype)
IS
BEGIN
OPEN temp_cur
FOR
SELECT l.linkid,
l.routenumber,
abc1 (l.linkid,
TO_DATE ('01/01/2000', 'mm/dd/yyyy'),
'2'),
abc2 (l.linkid,
TO_DATE ('01/01/2000', 'mm/dd/yyyy'),
'2')
FROM link l
WHERE l.linkid <= '010999';
END test;
END zzz;
SQL> VARIABLE g_ref REFCURSOR;
SQL> EXEC zzz.test (:g_ref);
SQL> PRINT g_ref -
How can I find out the name of the folder my java program is in?
Hi, I'm trying to make a little utitlity that makes a bunch of url shortcuts based on the name of the folder I run the java from.
i.e.
I have my executable jar in C:/Someplace/My Folder Name/
I'd like to be able to double click on the jar and it creates the url shortcuts for me using "My Folder Name" as a parameter.
I've done the shortcuts bit but can't figure out (=find a tut) how to read the folder name.
Thanks to anyone who can help!import java.io.*;
import java.net.*;
import java.security.*;
public class Attempt {
public static void main(String[] args) throws IOException {
System.out.println(new Attempt().getFolder());
public File getFolder() throws IOException {
ProtectionDomain domain = getClass().getProtectionDomain();
CodeSource source = domain.getCodeSource();
URL url = source.getLocation();
if (!"file".equals(url.getProtocol())){
throw new IOException("Code source location not a file:" + url);
String path = url.getPath();
//remove xxx.jar from path:
return new File(path.substring(0, path.lastIndexOf('/')));
} -
How to passing array as parameter to oracle stored procedure from JPA
Hi All,
I need to call a stored proc in Oracle that accepts an array as input parameter.
Pls let me know how should i call it from my JPA. Is this even possible without using JDBC directly?
i keep getting the ff error:
wrong number or types of arguments in call to ....
my code is something like this:
String[] myArr...
Query query = em.createNativeQuery("BEGIN myStoredProc(:arr); END;");
query.setParameter("arr", myArr);
Thanks in advance.I also fail to get this done my code till now is:
PLSQL Function:
function getHtml(pWhere VARCHAR2 DEFAULT NULL,
pColSort HTP.STRINGARRAY) return clob is
begin
errorhndl.Log(pMessage => 'called');
htp.prn('das ist der test
for i in 1 .. pColSort.count loop
htp.p('
pColSort['||i||']: '||pColSort(i));
end loop;
htp.prn('
<table> <tr> <td> max1.0 </td> <td> max2.0 </td> </tr>');
htp.prn('<tr> <td> max1.1 </td> <td> max2.1 </td> </tr> </table>');
htp.prn('test ende');
return htp.gHtpPClob;
exception
when others then
null;
end getHtml;
PLSQL TYPE: (in HTP package - self created - but could be anywhere else too)
type STRINGARRAY is table of varchar2(256) index by binary_integer;
JAVA DOA:
public class ShowReportDOAImpl implements ShowReportDOA {
private JdbcTemplate jdbcTemplate;
private SimpleJdbcCall procShowReport;
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
procShowReport = new SimpleJdbcCall(this.jdbcTemplate)
.withCatalogName("Show_Report")
.withFunctionName("getHtml")
.withoutProcedureColumnMetaDataAccess()
.declareParameters(
new SqlParameter("pWhere", Types.VARCHAR),
new SqlParameter("pColSort", Types.ARRAY, "HTP.STRINGARRAY"),
new SqlOutParameter("RETURN", Types.CLOB)
public String readReport(Long id, ParameterHelper ph) {
String[] sortCol = {"max", "michi", "stefan"};
String pWhere = "fritz";
MapSqlParameterSource parms = new MapSqlParameterSource();
parms.addValue("pWhere", pWhere);
parms.addValue("pColSort", sortCol, Types.ARRAY, "HTP.STRINGARRAY");
parms.addValue("pColSort", Arrays.asList(sortCol), Types.ARRAY, "HTP.STRINGARRAY");
Clob clob = procShowReport.executeFunction(Clob.class, parms);
String clobString = "";
try {
System.out.println("length: "+new Long(clob.length()).intValue());
clobString = clob.getSubString(1, new Long(clob.length()).intValue());
} catch (SQLException e) {
e.printStackTrace();
return clobString;
EXCEPTION IS:
org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{? = call SHOW_REPORT.GETHTML(?, ?)}]; SQL state [null]; error code [17059]; Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]; nested exception is java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:969)
org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:860)
oracle.sql.ARRAY.toARRAY(ARRAY.java:209)
oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7767)
oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7448)
oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7836)
oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4586)
org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:356)
org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:212)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:947)
org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
Please help!!
Please help!! -
How do I get the Parameters of a Stored Procedure from my Java Code?
I want to get the parameters in my Java code. How do I do this with Jdbc?
In ADO it was: myCmd.Parameters.Refresh();
Any idea what it is in Jdbc?no, what I want is to know what parameters are required by my stored proc. So basically I tell it, "My Stored Proc is name 'SomeName'. What are the parameters I need to fill for this proc?" Then it puts those in for me, and then I fill the values. That's what Cmd.Parameters.Refresh() does in VB/C++. So if I had a proc name "MyProc" with:
@Something int,
@Another varchar(25)
Then if I did cmd.StoredProc = "MyProc" (and told it where to find the DB), and then did cmd.Parameters.Refresh(), the cmd would then have those parameters with null values, so i could do:
cmd.Parameters(0) = 5
cmd.Parameters(1) = "hello"
Any idea how to do that in Java/Jdbc? -
How to use OUT variables in my stored procedure
I'm wondering if I can get some help using OUT variables in my stored procedure. Here's my code...
CREATE OR REPLACE PROCEDURE testProj.testProcedure (
v_segment_id IN VARCHAR2,
v_student_id OUT VARCHAR2,
v_current_code OUT NUMBER,
v_new_code OUT NUMBER
) AS
BEGIN
SELECT
s.student_id,
s.quad_code_id,
nc.quad_code_id
INTO
v_student_id,
v_current_quad_code,
v_new_quad_code
FROM testProj.students s
INNER JOIN testProj.new_codes nc ON s.student_id = nc.student_id
WHERE s.segment_id = v_segment_id ;
END testProcedure ;
EXECUTE testProj.testProcedure ('44') ;
When I execute that stored procedure with the above execute statement, I get this error:
Error report:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'testProcedure'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
+06550. 00000 - "line %s, column %s:\n%s"+
*Cause: Usually a PL/SQL compilation error.+
*Action:+Using Refcursor is one way you can do that ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:00.21
satyaki>
satyaki>
satyaki>create or replace procedure r_arg(
2 choice in number,
3 b in out sys_refcursor
4 )
5 is
6 str varchar2(500);
7 begin
8 str := 'select * from emp';
9 open b for str;
10 exception
11 when others then
12 dbms_output.put_line(sqlerrm);
13 end;
14 /
Procedure created.
Elapsed: 00:00:01.84
satyaki>
satyaki>
satyaki>declare
2 rec_x emp%rowtype;
3 w sys_refcursor;
4 begin
5 dbms_output.enable(1000000);
6 r_arg(1,w);
7 loop
8 fetch w into rec_x;
9 exit when w%notfound;
10 dbms_output.put_line('Employee No: '||rec_x.empno||' - '||
11 'Name: '||rec_x.ename||' - '||
12 'Job: '||rec_x.job||' - '||
13 'Manager: '||rec_x.mgr||' - '||
14 'Joining Date: '||rec_x.hiredate||' - '||
15 'Salary: '||rec_x.sal||' - '||
16 'Commission: '||rec_x.comm||' - '||
17 'Department No: '||rec_x.deptno);
18 end loop;
19 close w;
20 exception
21 when others then
22 dbms_output.put_line(sqlerrm);
23 end;
24 /
Employee No: 9999 - Name: SATYAKI - Job: SLS - Manager: 7698 - Joining Date: 02-NOV-08 - Salary: 55000 - Commission: 3455 - Department No: 10
Employee No: 7777 - Name: SOURAV - Job: SLS - Manager: - Joining Date: 14-SEP-08 - Salary: 45000 - Commission: 3400 - Department No: 10
Employee No: 7521 - Name: WARD - Job: SALESMAN - Manager: 7698 - Joining Date: 22-FEB-81 - Salary: 1250 - Commission: 500 - Department No: 30
Employee No: 7566 - Name: JONES - Job: MANAGER - Manager: 7839 - Joining Date: 02-APR-81 - Salary: 2975 - Commission: - Department No: 20
Employee No: 7654 - Name: MARTIN - Job: SALESMAN - Manager: 7698 - Joining Date: 28-SEP-81 - Salary: 1250 - Commission: 1400 - Department No: 30
Employee No: 7698 - Name: BLAKE - Job: MANAGER - Manager: 7839 - Joining Date: 01-MAY-81 - Salary: 2850 - Commission: - Department No: 30
Employee No: 7782 - Name: CLARK - Job: MANAGER - Manager: 7839 - Joining Date: 09-JUN-81 - Salary: 4450 - Commission: - Department No: 10
Employee No: 7788 - Name: SCOTT - Job: ANALYST - Manager: 7566 - Joining Date: 19-APR-87 - Salary: 3000 - Commission: - Department No: 20
Employee No: 7839 - Name: KING - Job: PRESIDENT - Manager: - Joining Date: 17-NOV-81 - Salary: 7000 - Commission: - Department No: 10
Employee No: 7844 - Name: TURNER - Job: SALESMAN - Manager: 7698 - Joining Date: 08-SEP-81 - Salary: 1500 - Commission: 0 - Department No: 30
Employee No: 7876 - Name: ADAMS - Job: CLERK - Manager: 7788 - Joining Date: 23-MAY-87 - Salary: 1100 - Commission: - Department No: 20
Employee No: 7900 - Name: JAMES - Job: CLERK - Manager: 7698 - Joining Date: 03-DEC-81 - Salary: 950 - Commission: - Department No: 30
Employee No: 7902 - Name: FORD - Job: ANALYST - Manager: 7566 - Joining Date: 03-DEC-81 - Salary: 3000 - Commission: - Department No: 20
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.48
satyaki>
satyaki>Regards.
Satyaki De.
Maybe you are looking for
-
how do I upload a single photo to a website?
-
Creation of Production Order with set Series
Document Series for Production Order (from NNM1): Series: 27 SeriesName: Primary Range: 1 - 1000 Next Number: 24 Series: 43 SeriesName: KAP Range: 1001 - 2000 Next Number: 1001 Considering the above document series, after i run the ff. code lole_DOCU
-
I cant open my iphone 3g .... needs restore and itunes cant make restore has an error on phone .... how can I solve this problem?
-
Extended Withholding Tax (India)
While testing TDS calculation at the time of payment posting I am facing a problem. TDS is not being calculated. System is asking Tax Code of TAXINN tax procedure such as input tax, output tax etc. I have done the settings of W/H type, code,recipient
-
Controlling approval status report cancel option
Dear Experts, Is it possible to control the approval status report screen based on Stored Procedure? Im having problem with users cancelling their draft documents before any approval status is decided upon the draft. Through the image