PLS-00306:NET to call Oracle stored procedure,Use Array parameters
Development Environment:Windows 2003 SP2+Oracle 10g
. NET to call Oracle stored procedure, use an array of types of parameters
Step1:(In the Oracle database define an array of types)
CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
OR
CREATE OR REPLACE type string_array is table of nvarchar2(255)
Step2:
CREATE OR REPLACE PROCEDURE Test
(i_test in string_varray,o_result out int)
IS
BEGIN
o_result:=i_test.count;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
o_result:=0;
END arraytest;
Step3:
ODP.NET(Oracle 10g)
OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
OracleCommand cmd = new OracleCommand("Test", conn);
cmd.CommandType = CommandType.StoredProcedure;
string[] str = new string[2] { "11", "222" };
cmd.ArrayBindCount=2;
OracleParameter p1 = new OracleParameter("i_test", OracleDbType.NVarChar);
p1.Direction = ParameterDirection.Input;
p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
p1.Value = str;
p1.ArrayBindSize=new int[2]{2,3};
p1.ArrayBindStatus = new OracleParameterStatus[2]{
OracleParameterStatus.Success,
OracleParameterStatus.Success
cmd.Parameters.Add(p1);
OracleParameter p2 = new OracleParameter("o_result", OracleDbType.Int32);
p2.Direction = ParameterDirection.Output;
P2.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
p2.Value=0;
cmd.Parameters.Add(p2);
int i = 0;
try
conn.Open();
cmd.ExecuteNonQuery();
i =(int) p2.Value;
catch (Exception ex)
finally
conn.Close();
Error:
Execution Failed:ORA-06550:Line 1,Column 7:
PLS-00306:Test parameters when calling the number or types of errors
ORA-06550:Line 1,Column 7:
PL/SQL:Statement ignored
Hi,
See the answer in [this thread|http://forums.oracle.com/forums/thread.jspa?threadID=909564&tstart=0]
Hope it helps,
Greg
Similar Messages
-
. NET to call Oracle stored procedure, use an array of types of parameters
. NET to call Oracle stored procedure, use an array of types of parameters
Step1:(In the Oracle database define an array of types)
CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
Step2:
CREATE OR REPLACE PROCEDURE Test
(i_test in string_varray,o_result out int)
IS
BEGIN
o_result:=i_test.count;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
o_result:=0;
END arraytest;
Step3:
Use System.Data.OracleClient
C# Code:
OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
OracleCommand cmd = new OracleCommand("Test", conn);
cmd.CommandType = CommandType.StoredProcedure;
string[] str = new string[] { "11", "22" };
OracleParameter p1 = new OracleParameter("i_test", OracleType.NVarChar);
p1.Direction = ParameterDirection.Input;
p1.Value = str;
cmd.Parameters.Add(p1);
OracleParameter p2 = new OracleParameter("o_result", OracleType.Int32);
p2.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p2);
int i = 0;
try
conn.Open();
cmd.ExecuteNonQuery();
i =(int) p2.Value;
catch (Exception ex)
finally
conn.Close();
Error:
Execution Failed:ORA-06550:Line 1,Column 7:
PLS-00306:Test parameters when calling the number or types of errors
ORA-06550:Line 1,Column 7:
PL/SQL:Statement ignored
Edited by: user10133982 on Jun 4, 2009 7:13 AM. NET to call Oracle stored procedure, use an array of types of parameters
The use of ODP.net(Oracle 10g), the error is still the same
Step1:(In the Oracle database define an array of types)
CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
Step2:
CREATE OR REPLACE PROCEDURE Test
(i_test in string_varray,o_result out int)
IS
BEGIN
o_result:=i_test.count;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
o_result:=0;
END arraytest;
Step3:
ODP.NET(Oracle 10g)
OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
OracleCommand cmd = new OracleCommand("Test", conn);
cmd.CommandType = CommandType.StoredProcedure;
string[] str = new string[2] { "11", "222" };
cmd.ArrayBindCount=2;
OracleParameter p1 = new OracleParameter("i_test", OracleDbType.NVarChar);
p1.Direction = ParameterDirection.Input;
p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
p1.Value = str;
p1.ArrayBindSize=new int[2]{2,3};
p1.ArrayBindStatus = new OracleParameterStatus[2]{
OracleParameterStatus.Success,
OracleParameterStatus.Success
cmd.Parameters.Add(p1);
OracleParameter p2 = new OracleParameter("o_result", OracleDbType.Int32);
p2.Direction = ParameterDirection.Output;
P2.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
p2.Value=0;
cmd.Parameters.Add(p2);
int i = 0;
try
conn.Open();
cmd.ExecuteNonQuery();
i =(int) p2.Value;
catch (Exception ex)
finally
conn.Close();
Error:
Execution Failed:ORA-06550:Line 1,Column 7:
PLS-00306:Test parameters when calling the number or types of errors
ORA-06550:Line 1,Column 7:
PL/SQL:Statement ignored
Edited by: user10133982 on Jun 5, 2009 7:48 AM -
Errors in calling Oracle stored procedure using java CallableStatement
Hello,
I have an oracle stored procedure below, it has been tested in PL/SQL without errors. During testing, in_c_file_type="F"; out_n_seqno_freeformat=120139596 and out_n_seqno_commaseprated is null (empty in value column).
When I run the program in Eclipse (windows xp), error messages is below: (It stopped at line 'cstme.execute();' )
Message:ORA-06550: line 1, column 26: PLS-00103: Encountered the symbol "" when expecting one of the following: . ( ) , * @ % & | = - + < / > at in is mod remainder not range rem => .. <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_ LIKE4_ LIKEC_ as between from using || indicator multiset member SUBMULTISET_ The symbol ", was inserted before "" to continue. Error code:6550 SQL statement:65000 {code} Does anyone know what cause the error? It seems like something is missing in the stored procedure. But the stored procedure passes the test in the PL/SQL. The oracla driver I used is Oracle thin driver. Oracle version is 10.2.g Thanks in advance. northcloud {code} create or replace procedure SP_GET_SEQNO_2( in_c_file_type in char, out_n_seqno_freeformat out integer, out_n_seqno_commaseprated out integer) is n_seqno_commaseprated integer; n_seqno_freeformat integer; begin if in_c_file_type ='F' THEN SELECT message_counter.nextval INTO n_seqno_freeformat FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_freeformat,empty_clob(),empty_clob()); elsif in_c_file_type ='C' THEN SELECT message_counter.nextval INTO n_seqno_commaseprated FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_commaseprated,empty_clob(),empty_clob()); else SELECT message_counter.nextval INTO n_seqno_freeformat FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_freeformat,empty_clob(),empty_clob()); SELECT message_counter.nextval INTO n_seqno_commaseprated FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_commaseprated,empty_clob(),empty_clob()); end if; out_n_seqno_freeformat := n_seqno_freeformat; out_n_seqno_commaseprated := n_seqno_commaseprated; end SP_GET_SEQNO_2; {code} ----- A part of java code I used to call the stored procedure is here. {code} String escapeString = "{call SP_GET_SEQNO_2 (? ? ?)}"; CallableStatement cstme = null; try { cstme = con.prepareCall(escapeString); cstme.setString(1, "F"); cstme.registerOutParameter(2, java.sql.Types.INTEGER); cstme.registerOutParameter(3, java.sql.Types.INTEGER); cstme.execute(); int seqNoFreeformat=0, seqNocommasepreted=0; seqNoFreeformat = cstme.getInt(2); seqNocommasepreted = cstme.getInt(3); System.out.println ("In ConvertXML.processStoredProcedure(), seqNoFreeformat= "+seqNoFreeformat+";seqNocommasepreted="+seqNocommasepreted); } catch (SQLException e) { //System.out.println ("In ConvertXML.processStoredProcedure(), SQLException: "+e); System.err.println("Message:"+e.getMessage()); System.err.println("Error code:"+e.getErrorCode()); System.err.println("SQL statement:"+e.getSQLState()); log.log(Level.INFO, log.getName() + " - SQLException : "+e); } {code}es5f2000 wrote:
jschell wrote:
That works?I dunno. The below definitely works, but like I said, I've only
ever done it with one output parameter (and that has always
been a ResultSet).
String callableQuery = "{?= call my_package.my_call(?, ?)}"
Yes I have done that and at least in terms of my code it wasn't just a result set.
But not with two. -
How to call Oracle Stored Procedure using EDQ
Can someone tell me how to use Oracle Stored Procedure call in EDQ, sample scripts/steps will be really helpful. Thanks!
It is also possible to do this using a custom processor in EDQ. The processor needs to do something very similar to the external task above (opens a DB connection, authenticates, runs a stored procedure).
If you need this, please talk us through the use case so we can determine if it is the best fit. In some ways, an external task is better as logically a stored procedure call is normally divorced from any process logic in EDQ.
Regards,
Mike -
How to call oracle stored procedure
how to call oracle stored procedure using
jdevloper.can any one help?
thanks
pullareddyConnection conn =
DriverManager.getConnection("your connect string");
CallableStatement stm=conn.prepareCall( "{?=call getDeptName(?)}");
stm.registerOutParameter(1,OracleTypes.VARCHAR);
int deptno=10;
stm.setInt(2,deptno);
stm.execute();
String dname=stm.getString(1);
stm.close();
conn.close();
getDeptName is a function:
FUNCTION
getDeptName(id IN NUMBER) RETURN VARCHAR2... -
How to call a stored procedure using its package name in Oracle
hi
we're doing a JDBC scenario where we call a stored procedure(a.prc) using its package name(b)The stored procedure has In /Out/IN-OUT parameter.
i have got 2 queries:
1- How to call the stored procedure using it's package.
2- How to capture the In/Out parameter in the response.hi Prateek
thanks for the reply.
However when i tried mapping it to Package.procedure, communication channel throws the error saying that Package.proceudre needs to be declared.
As i said , the procedure has IN-OUT parameter too.In oracle we need to write a block if we want to read the IN-OUT parameter.
How to get the IN-OUT parameter in XI? -
Calling a Stored Procedure with output parameters from Query Templates
This is same problem which Shalaka Khandekar logged earlier. This new thread gives the complete description about our problem. Please go through this problem and suggest us a feasible solution.
We encountered a problem while calling a stored procedure from MII Query Template as follows-
1. Stored Procedure is defined in a package. Procedure takes the below inputs and outputs.
a) Input1 - CLOB
b) Input2 - CLOB
c) Input3 - CLOB
d) Output1 - CLOB
e) Output2 - CLOB
f) Output3 - Varchar2
2. There are two ways to get the output back.
a) Using a Stored Procedure by declaring necessary OUT parameters.
b) Using a Function which returns a single value.
3. Consider we are using method 2-a. To call a Stored Procedure with OUT parameters from the Query Template we need to declare variables of
corresponding types and pass them to the Stored Procedure along with the necessary input parameters.
4. This method is not a solution to get output because we cannot declare variables of some type(CLOB, Varchar2) in Query Template.
5. Even though we are successful (step 4) in declaring the OUT variables in Query Template and passed it successfully to the procedure, but our procedure contains outputs which are of type CLOB. It means we are going to get data which is more than VARCHAR2 length which query template cannot return(Limit is 32767
characters)
6. So the method 2-a is ruled out.
7. Now consider method 2-b. Function returns only one value, but we have 3 different OUT values. Assume that we have appended them using a separator. This value is going to be more than 32767 characters which is again a problem with the query template(refer to point 5). So option 2-b is also ruled out.
Apart from above mentioned methods there is a work around. It is to create a temporary table in the database with above 3 OUT parameters along with a session specific column. We insert the output which we got from the procedure to the temporary table and use it further. As soon the usage of the data is completed we delete the current session specific data. So indirectly we call the table as a Session Table. This solution increases unnecessary load on the database.
Thanks in Advance.
RajeshRajesh,
please check if this following proposal could serve you.
Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
Here is an example how this could be defined.
Package:
type return_cur IS ref CURSOR;
Procedure:
PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
OPEN myReturnCur FOR SELECT val1, val2, val3 FROM dual;
Query:
DECLARE
MYRETURNCUR myPackage.return_cur;
BEGIN
myPackage.myProc(
MYRETURNCUR => ?
END;
Good luck.
Michael -
Error Calling Oracle Stored Procedure From Within Report
Hi,
I have a report that calls an oracle stored procedure which returns a ref cursor. The report is working ok in our development environment when called from our development website through .NET.
When the report is moved and accessed from our UAT website we get the following error :-
Failed to open a rowset. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for Oracle Description: One or more errors occurred during processing of command. Failed to open a rowset. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for Oracle Description: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'RHS_GET_CAND_SECTION_REFS' ORA-06550: line 1, column 7: PL/SQL: Statement ignored Native Error: Failed to open a rowset. Error in File C:\WINDOWS\TEMP\temp_d663a952-bef6-4bf7-bf1a-5e288afdb612 {9B6DFB38-A436-4940-9D80-B4C23DFFFF19}.rpt: Failed to open a rowset.
If we open the report manually we are prompted to enter database connection info. If we enter the UAT connection details the report runs ok. If we save the report and try to open it from UAT website through .NET it now opens ok.
If we then move that same report back to the development environment and open from our development website it fails with the same error above.
Both connections are using Microsoft OLE DB drivers and the Oracle databases are the same version (10.2.0.1.0).
Is the connection information being stored in actual report and somehow being used when the report is opened through .NET?
Any help appreciated
Regards
PaulHi,
Please let me know if the issue occurs with the crystal reports designer, if you are facing issues with the .NET application then a need to create a post [here|SAP Crystal Reports, version for Visual Studio;.
Regards,
Hitesh -
Calling a stored procedure using Oracle Ole Db provider
I am looking for an example of syntax used to call a stored procedure from VB.Net using the Oracle OleDB provider. I have been using the Microsoft provider MSDAORA but need to move to the Oracle provider due to upgrade. The syntax used with the MSDAORA provider does not work with the Oracle provider.
Hi,
Please refer to the Populate DataSet with Multiple REF Cursors Sample available at the following URL:
http://otn.oracle.com/sample_code/tech/windows/ole_db/oledb92/index.html
Check the PopulateProducts method available in the ViewProducts.cs file that call a database stored procedure "getProductsInfo" . This code is written in C# you may want to convert it to VB.NET syntax.
Thanks,
Jagriti
OTN IDC Team. -
How to call oracle stored procedure with OUT parameter?
I create oracle stored procedure in eclipse oepe
PROCEDURE SP_SELECT_ORA (
ID_INPUT IN VARCHAR2,
ID_OUTPUT OUT VARCHAR2,
PASSWD_OUTPUT OUT VARCHAR2,
NAME_OUTPUT OUT VARCHAR2) IS
BEGIN
SELECT EMP_ID, EMP_Passwd, EMP_Name
INTO ID_OUTPUT, PASSWD_OUTPUT, NAME_OUTPUT
FROM family
WHERE EMP_ID = ID_INPUT;
END;
and I try to call the sp in jpa like below,
@NamedNativeQueries({
@NamedNativeQuery(name = "callSelectSP", query = "call SP_SELECT_ORA(?,?,?,?)", resultClass = Members.class)
@Entity
@Table(name="family")
public class Members implements Serializable {
@Id
@Column(name = "EMP_ID")
private String ID;
@Column(name = "EMP_Passwd")
private String Passwd;
@Column(name = "EMP_Name")
private String Name;
==============
@PersistenceContext(unitName="MyFamily")
EntityManager em;
query = em.createNamedQuery("callSelectSP");
query.setParameter(1, ID);
String id_output = null;
String passwd_output = null;
String name_output = null;
query.setParameter(2,id_output);
query.setParameter(3,passwd_output);
query.setParameter(4,name_output);
query.executeUpdate();
member = (Members)query.getSingleResult();
But this query throws exception,
19:55:35,500 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 1465, SQLState: 72000
19:55:35,500 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) ORA-01465: invalid hex number
I don't know how. Pls, give me your advice. Thanks in advnace.
Best regardsThank you for your reply, Chris!
I tried this one.
@NamedNativeQueries({
@NamedNativeQuery(name = "callSelectSP", query = "exec SP_SELECT_ORA( ?, :id_output, :passwd_output, :name_output) " , resultClass = Members.class)
@Entity
@Table(name="family")
public class Members implements Serializable
===================
query = em.createNamedQuery("callSelectSP");
query.setParameter(1, ID);
String id_output = null;
String passwd_output = null;
String name_output = null;
query.setParameter("id_output", id_output);
query.setParameter("passwd_output", passwd_output);
query.setParameter("name_output",name_output);
query.executeUpdate();
On Console hibernate shew the sql and ora # like below,
19:59:25,160 INFO [stdout] (http--127.0.0.1-8080-1) Hibernate: exec SP_SELECT_ORA( ?, ?, ?, ?)
19:59:25,192 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 900, SQLState: 42000
19:59:25,192 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) ORA-00900: Invalid SQL statement
Pls, inform me your advice. Thanks in advance.
Best regards. -
Calling an Oracle stored procedure using Toplink API - Please help
Hi,
We are evaluating Toplink as a possible data access layer in large service-oriented application. The ability to call db stored procedures from within business object layer is crucial for our architechture.
I am trying to follow toplink application developer's guide examples on how to call stored procedures using toplink.
I have the folling java code:
call.setProcedureName("PR_ROMAN_TEST");
call.addNamedArgument("IN_PARAM");
call.addNamedOutputArgument("OUT_PARAM");
ValueReadQuery query = new ValueReadQuery();
query.setCall(call);
query.addArgument("IN_PARAM");
Vector params = new Vector();
params.addElement(new Integer(5));
Number result = (Number) session.executeQuery(query, params);
This generates the following SQL statement:
BEGIN PR_ROMAN_TEST(IN_PARAM=>5, OUT_PARAM=>?); END;
An attempt to execute it causes a
java.sql.SQLException: Invalid column index.
As I understand it, this exception is thrown because of the "?" in place of the out-parameter value holder.
The SQL statement that I would want toplink to generate and execute should look like:
DECLARE result number; BEGIN PR_ROMAN_TEST(IN_PARAM=>5, OUT_PARAM=>result); END;
, but how do I achieve it and how do I capture the return value, all using toplink api?
Please help
Thank you in advance,
RomanI read the conversation above. I am running into a similar kind of problem. I get the following error.
<an exponent (**)> <> or != or ~= >= <= <> and or like between || The symbol "." was subs Error Code: 6550Local Exception Stack: Exception [TOPLINK-4002] (OracleAS TopLink - 10g (9.0.4.5) (Build 040930)): oracle.toplink.exceptions.DatabaseException Exception Description: java.sql.SQLException: ORA-06550: line 1, column 38: PLS-00103: Encountered the symbol "NAME" when expecting one of the following:. ( ) , * @ % &' | = - + < / > at in is mod not range rem =>.. <an exponent (**)> <> or != or ~= >= <= <> and or like as between from using || The symbol "." was substituted for "NAME" to continue.ORA-06550: line 1, column 55: PLS-00103: Encountered the symbol "ID" when expecting one of the following:. ( ) , * @ % &' | = - + < / > at in is mod not range rem =>.. <an exponent (**)> <> or != or ~= >= <= <> and or like between || The symbol "." was subs Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 38:PLS-00103: Encountered the symbol "NAME" when expecting one of the following . ( ) , * @ % &' | = - + < / > at in is mod not range rem =>.. <an exponent (**)> <> or != or ~= >= <= <> and or like as between from using || The symbol "." was substituted for "NAME" to continue.ORA-06550: line 1, column 55:PLS-00103: Encountered the symbol "ID" when expecting one of the following: . ( ) , * @ % &' | = - + < / > at in is mod not range rem =>.. <an exponent (**)> <> or != or ~= >= <= <> and or like between || The symbol "." was subs Error Code: 6550 at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:227)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:733)
at oracle.toplink.internal.databaseaccess.DatabasePlatform.executeStoredProcedureCall(DatabasePlatform.java:1605)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:649)
at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:506)at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:131)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:115)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(CallQueryMechanism.java:194)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(CallQueryMechanism.java:175)
at oracle.toplink.queryframework.DirectReadQuery.executeNonCursor(DirectReadQuery.java:65)
at oracle.toplink.queryframework.DataReadQuery.execute(DataReadQuery.java:73)
at oracle.toplink.queryframework.ValueReadQuery.execute(ValueReadQuery.java:59)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:493)
at oracle.toplink.queryframework.ReadQuery.execute(ReadQuery.java:125)
at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1958)
at oracle.toplink.threetier.ServerSession.internalExecuteQuery(ServerSession.java:629)
at oracle.toplink.threetier.ClientSession.internalExecuteQuery(ClientSession.java:392)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1086)
at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2246)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1086)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1055)
at com.eplinc.common.persistence.toplink.TopLinkTemplate$2.readFromSession(TopLinkTemplate.java:181)
at com.eplinc.common.persistence.toplink.SessionReadCallback.doInTopLink(SessionReadCallback.java:59)
at com.eplinc.common.persistence.toplink.TopLinkTemplate.execute(TopLinkTemplate.java:110)
at com.eplinc.common.persistence.toplink.TopLinkTemplate.executeQuery(TopLinkTemplate.java:178)
at com.eplinc.common.persistence.toplink.TopLinkTemplate.executeQuery(TopLinkTemplate.java:172)
at com.epl.outletteller.dao.toplink.TopLinkOIDGeneratorDAO.generateId(TopLinkOIDGeneratorDAO.java:45)
The call I am making is as follows :
public long generateId(String name, long outletId) throws DataAccessException {
TopLinkTemplate tlTemplate = new TopLinkTemplate();
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("AUTONUM.GET_NEXT_VALUE");
call.addNamedArgument("autonum name");
call.addNamedArgument("outlet id");
call.addNamedOutputArgument("OUTPUT_1");
ValueReadQuery query = new ValueReadQuery();
query.setCall(call);
query.addArgument("autonum name");
query.addArgument("outlet id");
Object[] parameters = new Object[2];
parameters[0] = name;
parameters[1] = Long.toString(outletId);
Number uniqueNumber = (Number)tlTemplate.executeQuery(query,parameters);
return uniqueNumber.longValue();
This is my Table AUTONUM_SETTING
AUTONUM_NAME AUTONUM_TYPE START_VAL END_VAL INCREMENT_VALUE
TRAN_NUM GLOBAL 1 999999 1
TRACE_NUM OUTLET 1 999999 1
Any help would be appreciated. Thanks -
Calling Oracle Stored procedure with OUT parameter from ODI
Hi,
I called an oracle stored procedure with following anonymous block in the ODI procedure.
Declare
Status varchar2(10);
Begin
OTM.DeleteTarget('E_KPI_TARGET_VALUE', Status);
End;
I want to capture the OUT parameter STATUS value in a project level variable.
And based on its va;lue I would like to choose between 2 interfaces in my package.
Please help me in doing this.Hi,
For that kind of situation I commoly use:
1) one step with:
create or replace package <%=odiRef.getSchemaName("W")%>.pck_var
Status varchar2(10);
end;
* transaction 9, for instance
2) step
Begin
OTM.DeleteTarget('E_KPI_TARGET_VALUE', <%=odiRef.getSchemaName("W")%>.pck_var.Status);
End;
* transaction 9
3) then, at an ODI variable, use a refresh like:
select <%=odiRef.getSchemaName("W")%>.pck_var.Status from dual
at same logical shema where the package was created.
Does it make sense to you? -
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?
-
Calling Oracle stored procedure from java
The following query calls a stored procedure TRANSLATE_ZONEPATH_ID defined in a package MT by the user MTDBA. currentZone is a member variable of the class, and currently has value 1
This query works just fine when I run it from SQLPlus* connected as MTDBA.
But from java, the following piece throws exception saying "invalid column name"
String query = "SELECT MTDBA.MT.TRANSLATE_ZONEPATH_ID('"+currentZone+"') "
+ "FROM DUAL ";
try
Statement stmt = conn.createStatement();
ResultSet rst = stmt.executeQuery(query);
if (rst.next())
fullName = rst.getString(1);
stmt.close();
Anyone got any clue ?I always use CallableStatement to execute a stored procedure or function in a database (Oracle).
try this:
<code>
CallableStatement cs = dbConnection.prepareCall("{ ? =
MTDBA.MT.TRANSLATE_ZONEPATH_ID(?)}");
cs.setString(1, currentZone);
cs.registerOutParameter(1, Types.VARCHAR);
cs.executeUpdate();
fullname = cs.getString(1);
cs.close();
</code>
There is also a jdbc forum, where your should post this kind of problem :-)
Hope this help's
ThK -
Calling Oracle Stored Procedure from BC4J JSP App
I am on an extremely tight deadline and am trying to get my JSP application to use an Oracle Stored Procedure. I need to take some input from the user and send these values as parameters. Has anyone worked with Stored Procedures in JDev3.1? Please reply with some sample code if possible.
Thanks.Hi,
Someone posted a similar request the other day. Here is my response to them:
Basically, you need to create a custom method from your JSP's ViewObject, which calls the stored procedure. You can then call the ViewObject's custom method from the JSP client.
Here is how I have done it:
1. Choose the ViewObject that your JSP is based on and choose 'Edit' from the context menu.
2. On the Java tab of the ViewObject wizard, choose Generate Java File checkbox for the View Object Class and click the Finish button. A file is created under the ViewObject node in the Navigator named 'viewobjectImpl.java'.
3. Open the viewobjectImpl.java file in the code editor and create a method to call your stored procedure (see sample code below).
4. Compile the VOImpl.java file.
5. Choose the view object again, and choose Edit again from the context menu.
6. On the Client Methods tab, you should now see your method appear in the Available field. Select it and shuttle it to the Selected field.
7. Click Finish to leave the VO wizard, and rebuild your Business Components project.
8. In your JSP, call the custom method (see sample code below).
sample code for custom method calling a stored procedure from VOImpl.java file:
public int getTotalHits(String mon, String year) {
CallableStatement stmt = null;
int total;
// the call to the PL/SQL stored proc
String totalhits = "{? = call walkthru.total_hits(?,?)}";
// use the AM conxn 2 call storedproc
stmt = getDBTransaction().createCallableStatement(totalhits, 1);
try
// Bind the Statement Parameters and //Execute this Statement
stmt.registerOutParameter(1,Types.INTEGER);
stmt.setString(2,mon); stmt.setString(3,year);
stmt.execute();
total = stmt.getInt(1);
catch (Exception ex)
throw new oracle.jbo.JboException(ex);
finally
try
stmt.close();
catch (Exception nex)
return total;
sample render code for calling custom method from JSP custom bean:
public void render() {
int totalhits;
try
Row[] rows;
// Retrieve all records by default, the qView variable is defined in the base class
qView.setRangeSize(-1);
qView.first();
rows = qView.getAllRowsInRange();
// instantiate a view object for our exported method
// and call the stored procedure to get the total
ViewObject vo = qView.getViewObject();
wtQueryView theView = (wtQueryView) vo;
totalhits = theView.getTotalHits(session.getValue("m").toString(),session.getValue("y").toString());
out.println(totalhits);
} catch(Exception ex)
throw new RuntimeException(ex.getMessage());
}
Maybe you are looking for
-
Any solutions on how to delete the "ghost songs" ? P.S I deleted all the songs from itunes and restored from backup but that did nothing
-
I get the following error message when trying to instal in copy: "Creative Cloud Installer" can't be opened because the identity of the developer cannot be confirmed.
-
Facebook content is all in the middle of page and is not like that with other browsers!
The side bars on my Facebook wall is now all in the center of the page. It is not that way when I checked other browsers so apparently this is a Firebox problem
-
RoboHelp 10 and Visual Studio 2010
The company I work for is thinking about buying RoboHelp 10 to create an offline user help system for a WPF Ribbon Application being developed in Visual Studio 2010. I have been tasked with finding the recommended output format from RoboHelp 10 AND t
-
How To Make Infocube Visible in Query Designer?
hello, i'm using BIW 3.10, i've just created infocube and succesfully populated it with data. I went through all the process from datasource (from R/3 masterdata), infosource, infoobjects and so on, until i get to browse the content of the infocube u