Executing stored procedure via java
Hi all,
i have a problem calling a stored procedure in my java code. I found an example at OTN which seems not to be correct. i had the following VB-code to translate to java:
Set k = Server.CreateObject("ADODB.command")
With k
.activeconnection = Db
.CommandType = 4
.CommandText = "Get_SK"
Set vret = .createparameter("vRet", 131, 2) 'Output
.Parameters.append vret
.Execute
End With
In my java code:
CallableStatement sproc_stmt = null;
try {
sproc_stmt = lsession.connection().prepareCall("{ ? = call TCSDBOWNER.Get_SK}");
sproc_stmt.registerOutParameter(1,OracleTypes.NUMERIC);
sproc_stmt.setFetchSize(10);
sproc_stmt.execute();
The call generates an id for inserting new rows in the DB. executing the code shown above i got the following error:
wrong number or types of parameter/arguments
Is there anybody who can help me? Best regards,
ak
Hi,
thanks for your reply.
I have the description of this procedure (As you can see in my posting above) So it is definetly a procedure with one input parameter.
Yes ist it a callable statement as the other one before. So the first one:
CallableStatement sproc_stmt = lsession.connection().prepareCall("{call Get_SK(?)}");
sproc_stmt.registerOutParameter(1,Types.NUMERIC,1);
ResultSet sproc_result = sproc_stmt.executeQuery();
Works fine. No more problems with that. It is a procedure with one OUT_PARAMETER and no INPUT_PARAMETER.
So, the only thing to change (I thought is):
sproc_stmt = lsession.connection().prepareCall("{ call Get_SKS(?,?)}");
sproc_stmt.setInt(2,1);
sproc_stmt.registerOutParameter(1,OracleTypes.NUMERIC);
ResultSet sproc_result = sproc_stmt.executeQuery();
But this seems not that obvious. I got an error:
java.sql.SQLException: ORA-01722: invalid number
ORA-06512: at "SYS.DBMS_SYS_SQL", line 826
ORA-06512: at "SYS.DBMS_SQL", line 39
ORA-06512: at "TCSDBOWNER.GET_SKS", line 44
ORA-06512: at line 1
So it seems something is wrong with this output parameter!?
Any more help? Regards,
ak
Similar Messages
-
Calling stored procedure via java
Hi all,
i have a problem calling a stored procedure in my java code. I found an example at OTN which seems not to be correct. I know there had been a lot of posting regarding this isue but i did not find the solution.
I had the following VB-code to translate to java:
Set k = Server.CreateObject("ADODB.command")
With k
.activeconnection = Db
.CommandType = 4
.CommandText = "Get_SK"
Set vret = .createparameter("vRet", 131, 2) 'Output
.Parameters.append vret
.Execute
End With
In my java code:
CallableStatement sproc_stmt = null;
try {
sproc_stmt = lsession.connection().prepareCall("{ ? = call TCSDBOWNER.Get_SK}");
sproc_stmt.registerOutParameter(1,OracleTypes.NUMERIC);
sproc_stmt.setFetchSize(10);
sproc_stmt.execute();
The call generates an id for inserting new rows in the DB. executing the code shown above i got the following error:
wrong number or types of parameter/arguments
Is there anybody who can help me? Best regards,
akHi again,
this was really ugly:
Re: Executing stored procedure via java
Thanks all, regards,
ak -
Problem in calling Oracle stored procedure from Java.
I am trying to invoke the Oracle stored procedure from Java. The procedure does not take any parameters and does not return anything. If I call it from SQL prompt it is working perfectly. I am calling it in my program as follows.
callable_stmt=con.prepareCall("{call pkg_name.proc_name()}");
callable_stmt.execute();
The problem is the control-of-flow is getting strucked in the second line I wrote. It is not giving any error also.
Please clarify me what's wrong with my code?
Seenu.And how long does the stored procedure take to run from your client machine when running it via sqlplus?
-
Error while calling stored procedure from Java
Hi Guys,
How are you everybody? I hope everything is goin fine on your side. I have one issue in PL/SQL while calling below stored procedures from Java.
Problem Description: We have a stored procedure PROCEDURE BULK_INSERTS (
V_SESSION_ID_TAB IN T_SESSION_ID_TAB_TYPE,
V_SERVICE_TYPE_TAB IN T_SERVICE_TYPE_TAB_TYPE,
V_SERVICE_LOCATION_TAB IN T_SERVICE_LOCATION_TAB_TYPE,
V_SERVICE_CALL_NAME_TAB IN T_SERVICE_CALL_NAME_TAB_TYPE,
V_SERVICE_CALL_START_TIME_TAB IN T_SERVICE_CALL_ST_TAB_TYPE,
V_SERVICE_CALL_END_TIME_TAB IN T_SERVICE_CALL_ET_TAB_TYPE,
V_SERVICE_CALL_DURATION_TAB IN T_SERVICE_CALL_DUR_TAB_TYPE,
V_STATUS_TAB IN T_STATUS_TAB_TYPE,
V_NOTES_TAB IN T_NOTES_TAB_TYPE
) and we are getting ora errors while calling this stored procedure from java.
All tab types are declared locally, at package level.
Here is error which occur while calling this sp:
{call BULK_PKG.BULK_INSERTS(?,?,?,?,?,?,?,?,?)}
And the parameter types we are using are:
SESSION_ID - NUM_TAB_TYPE
SERVICE_TYPE - VAR_TAB_TYPE
SERVICE_LOCATION - VAR_TAB_TYPE
SERVICE_CALL_NAME - VAR_TAB_TYPE
SERVICE_CALL_START_TIME - DATE_TIME_TAB_TYPE
SERVICE_CALL_END_TIME - DATE_TIME_TAB_TYPE
SERVICE_CALL_DURATION - NUM_TAB_TYPE
STATUS - VAR_TAB_TYPE
NOTES - VAR_TAB_TYPE
And the Exception stack trace is:
ERROR (com.att.retail.r2d2.persistence.dao.ExternalServiceCallDAO.saveExternalServiceCallInfo(ExternalServi
ceCallDAO.java:143)@ExecuteThread: '252' for queue: 'weblogic.kernel.Default') {Error attempting to save collected ESC data}
java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1030)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:191)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:944)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1222)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3381)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3482)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:3856)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1373)
at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:98)
at com.att.retail.r2d2.persistence.dao.ExternalServiceCallDAO.doBulkInsert(ExternalServiceCallDAO.java:220)
at com.att.retail.r2d2.persistence.dao.ExternalServiceCallDAO.saveExternalServiceCallInfo(ExternalServiceCallDAO.java:138)
Please help my guys out of this. I will really appreciate all suggestions and advices.
Thank you everybody.I am trying to pass parameter to test my procedure but it is giving this error : ORA-06531: Reference to uninitialized collection
ORA-06512: at line 12
Here is example for my test procedure:
declare
v_session_id_tab SESSION_ID_TAB_TYPE;
v_service_type_tab SERVICE_TYPE_TAB_TYPE ;
v_service_location_tab SERVICE_LOCATION_TAB_TYPE ;
v_service_call_name_tab SERVICE_CALL_NAME_TAB_TYPE;
v_service_call_start_time_tab SERVICE_CALL_ST_TAB_TYPE;
v_service_call_end_time_tab SERVICE_CALL_ET_TAB_TYPE;
v_service_call_duration_tab SERVICE_CALL_DUR_TAB_TYPE;
v_status_tab STATUS_TAB_TYPE;
v_notes_tab NOTES_TAB_TYPE;
begin
v_session_id_tab(1) := 1;
v_service_type_tab(1) := 'db';
v_service_location_tab(1) := 'local';
v_service_call_name_tab(1) := 'Name of call';
v_service_call_start_time_tab(1) := SYSDATE;
v_service_call_end_time_tab(1) := SYSDATE;
v_service_call_duration_tab(1) := 100;
v_status_tab(1) := 'Z';
v_notes_tab(1) := 'NOTES';
BULK_INSERTS (v_session_id_tab,v_service_type_tab, v_service_location_tab,v_service_call_name_tab,v_service_call_start_time_tab,v_service_call_end_time_tab,
v_service_call_duration_tab, v_status_tab, v_notes_tab);
end;
I declare all types at schema level.
Please give your comments.
Thank you -
Calling stored procedure from Java raises ORA-1722 exception
Hi,
As the title says, when I call the stored procedure from java I got the exception ORA-1722 (invalid number) but I've checked and rechecked my procedure on SQL-Developer and It's alright it works nice and clean !
What's happening? is there something I'm missing?
The way I call the stored procedure is:
public void execProcedure(String procedure) {
CallableStatement cs;
try {
cs = conn.prepareCall(procedure);
cs.execute();
} catch (SQLException ex) {
Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
where
String procedure = "{call validateinfo}"I really need help on this, it's frustraiting me 'cause I need to finish a system but this little big problem is killing me ...
Thanks any advice is very welcome :)Thanks for your help. Haven't tested the SP with a DB access client... which one do you recommend to use?
The SP is the following:
create or replace
PROCEDURE validateInfo IS
var number;
BEGIN
UPDATE temp_desarrollo
SET status = '1';
COMMIT;
// Some string validations ...
//This one just checks if the value of "monto" is a number
//This update goes good
UPDATE temp_desarrollo tmp
SET cve_status = Decode(cve_status, NULL, '15', cve_status||',15')
WHERE IsNumber(tmp.monto) = 'F';
COMMIT;*/
//This one just checks if the value of "monto" is greater than 0
//if not, change de add to cve_status an errorValue
UPDATE temp_desarrollo tmp
SET cve_status = Decode(cve_status, NULL, '14', cve_status||',14')
WHERE (cve_status NOT LIKE '%15%' OR cve_status IS NULL)
AND to_number(tmp.monto) <= 0;
COMMIT;
//More string validations
EXCEPTION
WHEN OTHERS THEN
var := SQLCODE;
insert into excepciones values(to_char(var));
END;I've deleted much code from the SP since I know there's nothing to do with the excepcion, just that UPDATE statement is the one giving me the exception.
If those two UPDATES statements work with the same field (monto) why the first one is succeding and the second one not?
Cheers,
Federico
P.S. the "isNumber" function is as follows, just in case.
create or replace
function IsNumber(val1 varchar2) return varchar2 is
n number := null;
begin
n := to_number(val1,'9999999999999999.99');
return 'T';
exception
when others then
return 'F';
end; -
Getting exception whil calling an oracle stored procedure from java program
Dear All,
I encounter this error in my application when I call only the stored procedure but the view is executing fine from the application and my environment is as follow:
Java 1.4
oracle 10g
oracle jdbc driver:9.2.0.8.0
websphere portal 6.0.0.1
this error is occur from time to time randomly, when it happens, the only workaround is to restart the server..Does anyone have any idea about this error?
Unable to execute stored Procedure in Method
java.lang.NullPointerException
at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java(Compiled Code))
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1140)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java(Compiled Code))
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java(Compiled Code))
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3606)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5267)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecute(WSJdbcPreparedStatement.java:632)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.execute(WSJdbcPreparedStatement.java:427)
And sometime I am getting this exception
Unable to execute stored Procedure in Method
java.lang.ArrayIndexOutOfBoundsException: 27787320
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java(Compiled Code))
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1134)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java(Compiled Code))
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java(Compiled Code))
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3606)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5267)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecute(WSJdbcPreparedStatement.java:632)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.execute(WSJdbcPreparedStatement.java:427)
Thanks
Jayspacetorrent escribió:
for (int x=0; x <result.size(); x++){
System.out.println(result.get(x));
I can't do this, because result object is a Map, and I need write the Key of the Value to obtain.
So I can do:
result.get("res");And I odtain a *$Proxy3* Object -
DB2 Stored Procedure from Java-JDBC
Hi All,
I am using DB2 stored procedure which have been written in COBOL. I have two types of stored procedures. First types of stored procedure takes IN parameter and returns OUT parameter. These stored procedures are working fine. The second type of stored procedure takes IN parameter and returns a CURSOR. According to Database team (who wrote these stored procedure) claims that they can see data in a cursor when they test these stored procedure directly in the database. However, when I run these stored procedures from Java code it returns NULL ResultSet. Here is the code:
public SearchResult getAllBenefitHEDType(SearchParameter searchParam) throws DAOException {
log.debug(" getAllBenefitHEDType method - entering ");
HashMap searchParametersMap = searchParam.getHashMap();
SearchResult searchResult = new SearchResult();
String type = (String) searchParametersMap.get(UDFConstant.LOOKUP_SEARCH_TYPE);
HashMap resultParametersMap = new HashMap();
ArrayList resultSetDTO = new ArrayList();
try {
conn = this.getConnection();
conn.setAutoCommit(false);
System.out.println("getAllBenefitHEDType Step 1");
CallableStatement cs = conn.prepareCall("{call TEST.APS003(?)}"); // Stored Procedure with one IN parameter.
cs.setString(1,type);
boolean retVal = cs.execute(); // this should return true if ResultSet is available.. in my case it is returning false.
// I tried with getting the Object
ResultSet rs = (ResultSet) cs.getObject(1); // this should give me a valid result set ... in my case I am getting null
if (rs!=null) {
System.out.println("getAllBenefitHEDType Step 4A Result Set Not Null");
} else {
System.out.println("getAllBenefitHEDType Step 4A Result Set Is Null");
// I tried getting the resultset
ResultSet rs1 = cs.getResultSet(); // this should give me a valid result set ... in my case I am getting null
if (rs1!=null) {
System.out.println("getAllBenefitHEDType Step 4D Result Set Not Null");
} else {
System.out.println("getAllBenefitHEDType Step 4D Result Set Is Null");
while (rs.next()) {
System.out.println("getAllBenefitHEDType Step 5");
LookupDTO lookupDTO = new LookupDTO();
// the following code populate the Lookup DTOs from ResultSet.A few comments...
1) Creating tables, particularly tables whose names seem to imply that they are temporary tables, on the fly in a stored procedure is a bad idea. That is not the way to work with Oracle, though it is a common practice in other databases like SQL Server. There is undoubtedly a better way to do this in Oracle if you can explain what you're trying to accomplish from a business standpoint.
2) If you are going to use dynamic SQL, you almost always want to use bind variables, not literals. One of the quickest ways to kill an Oracle database's performance is to not use bind variables.
3) As has already been mentioned, assuming FH_INICIO is a DATE column, you need to put an explicit TO_DATE around your strings in order to convert them to dates. Otherwise, Oracle's implicit cast depends on the session's NLS_DATE_FORMAT, which is likely to be different in different client applications and from different client machines.
Justin -
Creating Stored Procedure in Java
Hi All,
I would like to ask how to create a stored procedure in Java.
My project now is to create a program that will open a DB2 SQL File (Creating Table and Stored Procedure) and then Execute it.
Executing the CREATE TABLE command is not that difficult since I can break the execution down by statement (divide by ";" in the SQL file).
The logic I applied here are:
1. Open the SQL file and store the contents into a String object.
2. Call the executeUpdate(string_sql_fileContent) method of Statement Object.
Example: SQL File contect to be executed.
===========================================================
CREATE TABLE MDMTEST.sample
(firstname CHARACTER(40),
middlename CHARACTER(40),
lastname CHARACTER(40),
idNo SMALLINT NOT NULL
DATA CAPTURE NONE;
#SYNC 10;
ALTER TABLE MDMTEST.sample
LOCKSIZE ROW
APPEND OFF
NOT VOLATILE;
#SYNC 20;
ALTER TABLE MDMTEST.sample
ADD PRIMARY KEY
(idNo
#SYNC 30;
RUNSTATS ON TABLE MDMTEST.sample
AND INDEXES ALL
SHRLEVEL REFERENCE;
===========================================================
I can divide this by ";" and execute them by statement.
But my problem is when creating Stored Procedure... Since in stored procedure there are so many stub-statements...
Example: Content of SQL File for creating stored procedure.
===========================================================
CREATE PROCEDURE MDMTEST.DROP_ALL_OBJECTS ( )
SPECIFIC MDMTEST.SQL051109115453000
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
MODIFIES SQL DATA
INHERIT SPECIAL REGISTERS
BEGIN
Delete Statement;
Insert Statement;
Update Statement;
END;
===========================================================
Take note there are three statements inside the CREATE..BEGIN.. and END.. (namely Delete, Insert, and Update Statements).
How can I execute the command for creating the procedure in Java? I believe that creating stored procedures in other databases are almost the same...
So... anyboby who have tried creating stored procedure in Java?
Please help me in this... I wanna pass the subject hehe..I have used these files as a sample:
Java Program:
import java.io.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import my.db.components.*;
public class ProcedureUploader {
private MyDBConnection dbConn=new MyDBConnection();
private Statement statement;
public ProcedureUploader() {
try{
dbConn.connectDB ("206.206.206.206","12345","DEV","mdmtest","mdmtest");
this.statement=dbConn.getStatement ();
}catch(SQLException sqle){
sqle.printStackTrace();
public String getContents(String fileName) throws IOException{
File inputFile = new File(fileName);
FileReader in = new FileReader(inputFile);
int c; String contents="";
while ((c = in.read()) != -1) contents+=(char) c;
in.close();
return contents;
public void executeSQLCommand(String file) throws IOException{
String command="";
try{
command=getContents(file);
statement.executeUpdate(command);
System.out.println("Command Execution Successful.");
}catch(Exception ex){
System.out.println("There is a problem executing the command. Please check the SQL file and re-execute again.");
ex.printStackTrace();
public static void main(String args[]) throws IOException{
ProcedureUploader uploader=new ProcedureUploader();
uploader.executeSQLCommand("C:\\I2\\Development\\ProcedureUploader\\sample.sql");
SQL File:
CREATE PROCEDURE MDMTEST.sampleProc ( )
SPECIFIC MDMTEST.sampleProc
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
MODIFIES SQL DATA
INHERIT SPECIAL REGISTERS
delete from SAMPLE;
commit;
select * from SAMPLE;;
#SYNC 10;
===========================================================
The problem is that ... there will be an error:
===========================================================
There is a problem executing the command. Please check the SQL file and re-execute again.
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: delete from SAMPLE;;PECIAL REGISTERS
;<psm_repeat>
at com.ibm.db2.jcc.c.fg.e(fg.java:1596)
at com.ibm.db2.jcc.c.fg.b(fg.java:1160)
at com.ibm.db2.jcc.b.gb.h(gb.java:217)
at com.ibm.db2.jcc.b.gb.b(gb.java:46)
at com.ibm.db2.jcc.b.w.b(w.java:40)
at com.ibm.db2.jcc.b.vb.f(vb.java:118)
at com.ibm.db2.jcc.c.fg.m(fg.java:1155)
at com.ibm.db2.jcc.c.fg.a(fg.java:1865)
at com.ibm.db2.jcc.c.fg.c(fg.java:517)
at com.ibm.db2.jcc.c.fg.executeUpdate(fg.java:501)
at ProcedureUploader.executeSQLCommand(ProcedureUploader.java:44)
at ProcedureUploader.main(ProcedureUploader.java:54)
===========================================================
But still the procedure will be created but until the first ";" only... OR.. creates a stored procedure having the following lines only.
===========================================================
CREATE PROCEDURE MDMTEST.sampleProc ( )
SPECIFIC MDMTEST.sampleProc
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
MODIFIES SQL DATA
INHERIT SPECIAL REGISTERS
delete from SAMPLE;
=========================================================== -
How to customize events, execute stored procedures using JSF and ADF BC
As a java beginner, I started with developing simple web application using JSF and ADF business component through visual and declarative approach. I need to know how to customize events, execute stored procedures, invoke functions on triggering events associated with rich controls. for eg. how to write customized functions on button click or checkbox click events to achieve business requirement and can be modified whenever required.
Edited by: 792068 on Aug 31, 2010 9:40 PMWhich business layer is prefered to create interactive data model: 1. ADF business components or 2. Enterprise JavaBeans using Java persistance API (JPA) or 3. Toplink 4. Portlets
which minimizes writing low level codes and how much OOPS knowledge is required for creating above business layer binding data to viewcontroller layer? -
Execute Stored Procedures from Stellent
Can we execute stored procedures from stellent 7.5.2 ?
By using java, I dont find any method to execute stored procedure from WorkSpace interface.
Please guide me to solve this..
Appreciate your help and efforts.May not be exactly what you're looking for, but I hope this helps:
http://www.corecontentonly.com/Blog/Calling-A-Stored-Procedure-From-Oracle-Fusion-ECM-Stellent
For java based execution basically:
1. Create your stored proc in the db
2. Create a component
3. Create a query resource
4. In your java code use the createResultSet method of the Workspace object and pass in the name of your query resource and then the current databinder object -
Can you get values back from a stored procedure via OUTPUT parameters?
Can you get values back from calling a stored procedure via OUTPUT parameters/variables? I call the SP via a SQL statement from a script either in a WF or DF.
I thought I read some reference that DI could not get the values from OUTPUT parameters but I could not find it again (don't know if it is in any of the documentation or referred to in a forum.
I did try a couple of tests but it did not reutrn any values via OUTPUT. But before I give up I thought I'd see if you could and maybe I needed to change something.This isn't exactly an answer to your question, but I'll point out that, given that you're resorting to a SQL script in the first place, there's no reason you can't also turn the output parameters into a regular result or record set. (The following uses T-SQL, although I think it's pretty generic.)
declare @param1 int, param2 varchar(100), @return int;
exec @return = proc @param1 = @param1 output, @param2 = @param2 output;
select @param1 as param1, @param2 as param2;
That is, to get from output parameters to a "regular" output from the SQL script isn't much of a leap...
Jeff Prenevost
BI Consultant
Ann Arbor, MI -
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 can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?
Hi
I have a stored procedure. It can be executed like this
exec test @p = 1;
exec test @p = 2
exec test @p = n;
n can be hundred.
I want the sp being executed in parallel, not sequence. It means the 3 examples above can be run at the same time.
If I know the number in advance, say 3, I can create 3 different Execution SQL Tasks. They can be run in parallel.
However, the n is not static. It is coming from a table.
How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?
I think about using script task. In the script, I get the value of n, and the list of p, from the table, then running a loop with. In the loop, I create a threat and in the threat, I execute the sp like : exec test @p = p. So the exec test may
be run parallel. But I am not sure if it works.
Any idea is really appreciated.Hi nam_man,
According to your description, you want to call stored procedures in parallel, right?
In SSIS, we can create separate jobs with different stored procedures, then set the same schedule to kick the jobs off at the same time. In this way, we should be careful to monitor blocking and deadlocking depending on what the jobs are doing.
We can also put all stored procedures in SSIS Sequence container, then they will be run in parallel.
For more information about SSIS job and Sequence container, please refer to the following documents:
http://www.mssqltips.com/sqlservertutorial/220/scheduling-ssis-packages-with-sql-server-agent/
https://msdn.microsoft.com/en-us/library/ms139855(v=sql.110).aspx
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .
Hi Srinath,
The below blog might be useful
http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
regards,
Harish -
Problem in writting oracle stored procedure in java
Hi,
Can anybody please suggest me how can I access oracle stored procedure in Java.
Thanksplease find the examples in the below url.
http://javaalmanac.com/egs/java.sql/pkg.html
Maybe you are looking for
-
I like to work with multiple windows open on the same screen at once. Now the smallest allowed width of the window takes up over half the screen (I have a 13 inch macbook)! This restriction is here whether or not I am zoomed in or out. Can I get arou
-
Cannot resolve symbol error even with class imported
Hi I'm trying to print out a java.version system property but keep getting a cannot resolve symbol error symbol: class getProperty location: class java.lang.System I've looked at the API and getProperty() is a method of lang.System Can anyone throw a
-
Syncing iPhone 3 with old op software to more than 1 computer
My husband has an iPhone 3GS and it is currently synced to an old Mac. He can no longer update his phone op software because his Mac is too old. I want to sync his phone to my Windows computer running windows 7 so I can update his phone. Can I do thi
-
Edit non-functional in Rel. 2 SQL Workshop Object Browser
Using IExplorer 6. Recently upgraded to HTMLDB Rel. 2. Thus far everything I've tried works fine except for the Object Browser code display and editing function. First problem: the code display for Packages, Functions, Views etc. does not wrap. Secon
-
Listen to port 25 and save incoming email as txt files
Hi I am new to JavaMail. I would apreciate some advice. I would like to use JavaMail to listen on a port such as 25 like a standard SMTP mail server, JavaMail would recieve the mails and convert them to txt file and save them on the Operating System.