Problem with calling a oracle stored procedure
Hi,
I am using the following callable statement to invoke a oracle stored procedure/function.
String myCallableStmt="{?=call IB_DDL.CREATE_DATASET(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
But I am getting the following errors which do not make sense to me
Exception in thread "main" java.lang.NullPointerException
at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java:870)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:956)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1159)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3284)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3389)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4222)
at org.jtdemo.CreateDataSet.callCreateDatasetProcedure(CreateDataSet.java:246)
at org.jtdemo.Main.main(Main.java:29)
Can anyone help me here.
Thanks in advance
Kalyan
May be I have used the word "procedure" loosely. Its infact a oracle function which returns a message of type Varchar2. Hence "{?=.....} here is used for registering the return value from the function. The remaining statement CREATE_DATASET(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?), here the first 14 are input parameters whereas the last one is the OUT parameter of the function. Hope this helps. Anways I am pasting my code below...
CallableStatement cstmt = null;
String myCallableStmt="{?=call IB_DDL.CREATE_DATASET(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
try {
System.out.print("Creating DataSet.......\n");
cstmt = targetCon.prepareCall(myCallableStmt);
cstmt.setObject("USER_ID_IN",this.USER_ID_IN);
cstmt.setObject("TABLE_NAME_IN",this.TABLE_NAME_IN);
cstmt.setObject("LAYOUT_IN",this.layoutCollection);
cstmt.setObject("DATA_TABLESPACE_IN",this.DATA_TABLESPACE_IN);
cstmt.setObject("INDEX_TABLESPACE_IN",this.INDEX_TABLESPACE_IN);
cstmt.setObject("STRING_POOL_NAME_IN",this.STRING_POOL_NAME_IN);
cstmt.setObject("NUMBER_POOL_NAME_IN",this.NUMBER_POOL_NAME_IN);
cstmt.setObject("DATE_POOL_NAME_IN",this.DATE_POOL_NAME_IN);
cstmt.setObject("LINK_POOL_NAME_IN",this.LINK_POOL_NAME_IN);
cstmt.setObject("DATASET_LEVEL_CONSTR_TYPE",this.DATASET_LEVEL_CONSTR_TYPE);
cstmt.setObject("DATASET_LEVEL_CONSTR_BODY",this.DATASET_LEVEL_CONSTR_BODY);
cstmt.setObject("POOLING_IN",this.POOLING_IN);
cstmt.setObject("SEGMENTATION_IN",this.SEGMENTATION_IN);
cstmt.setObject("DATASET_PARTITIONING_IN",this.DATASET_PARTITIONING_IN);
cstmt.registerOutParameter("DATASET_ID_OUT",OracleTypes.INTEGER);
cstmt.registerOutParameter("RETURN_MESSAGE",OracleTypes.VARCHAR);
cstmt.execute();
String returnMessage = (String)cstmt.getObject("RETURN_MESSAGE");
System.out.print(returnMessage);
}catch(SQLException e) {
e.printStackTrace();
}
Similar Messages
-
Call to Oracle stored procedure that returns ref cursor doesn't work
I'm trying to use an OData service operation with Entity Framework to call an Oracle stored procedure that takes an number as an input parameter and returns a ref cursor. The client is javascript so I'm using the rest console to test my endpoints. I have been able to successful call a regular Oracle stored procedure that takes a number parameter but doesn't return anything so I think I have the different component interactions correct. When I try calling the proc that has an ref cursor for the output I get the following an error "Invalid number or type of parameters". Here are my specifics:
App.config
<oracle.dataaccess.client>
<settings>
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.0" value="implicitRefCursor metadata='ColumnName=WINDFARM_ID;BaseColumnName=WINDFARM_ID;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Number;ProviderType=Int32'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.1" value="implicitRefCursor metadata='ColumnName=STARTTIME;BaseColumnName=STARTTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.2" value="implicitRefCursor metadata='ColumnName=ENDTIME;BaseColumnName=ENDTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.3" value="implicitRefCursor metadata='ColumnName=TURBINE_NUMBER;BaseColumnName=TURBINE_NUMBER;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.4" value="implicitRefCursor metadata='ColumnName=NOTES;BaseColumnName=NOTES;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.5" value="implicitRefCursor metadata='ColumnName=TECHNICIAN_NAME;BaseColumnName=TECHNICIAN_NAME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
</settings>
OData Service Operation:
public class OracleODataService : DataService<OracleEntities>
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("GetWorkOrdersByWindfarmId", ServiceOperationRights.All);
config.SetServiceOperationAccessRule("CreateWorkOrder", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
[WebGet]
public IQueryable<GetWorkOrdersByWindfarmId_Result> GetWorkOrdersByWindfarmId(int WindfarmId)
return this.CurrentDataSource.GetWorkOrdersByWindfarmId(WindfarmId).AsQueryable();
[WebGet]
public void CreateWorkOrder(int WindfarmId)
this.CurrentDataSource.CreateWorkOrder(WindfarmId);
Here is the stored procedure:
procedure GetWorkOrdersByWindFarmId(WINDFARMID IN NUMBER,
P_RESULTS OUT REF_CUR) is
begin
OPEN P_RESULTS FOR
select WINDFARM_ID,
STARTTIME,
ENDTIME,
TURBINE_NUMBER,
NOTES,
TECHNICIAN_NAME
from WORKORDERS
where WINDFARM_ID = WINDFARMID;
end GetWorkOrdersByWindFarmId;
I defined a function import for the stored procedure using the directions I found online by creating a new complex type. I don't know if I should be defining the input parameter, WindfarmId, in my app.config? If I should what would that format look like? I also don't know if I'm invoking the stored procedure correctly in my service operation? I'm testing everything through the rest console because the client consuming this information is written in javascript and expecting a json format. Any help is appreciated!
Edited by: 1001323 on Apr 20, 2013 8:04 AM
Edited by: jennyh on Apr 22, 2013 9:00 AMMaking the change you suggested still resulted in the same Oracle.DataAccess.Client.OracleException {"ORA-06550: line 1, column 8:\nPLS-00306: wrong number or types of arguments in call to 'GETWORKORDERSBYWINDFARMID'\nORA-06550: line 1, column 8:\nPL/SQL: Statement ignored"} System.Exception {Oracle.DataAccess.Client.OracleException}
I keep thinking it has to do with my oracle.dataaccess.client settings in App.Config because I don't actually put the WindfarmId and an input parameter. I tried a few different ways to do this but can't find the correct format. -
Calling a Oracle Stored Procedure which will take a while to complete
Hey.
I'm calling a Oracle stored procedure which goes of and do a whole lot of things and therefore takes a fair while to complete.
Currently I am doing this:
String sql = "begin concorde.start_transfer(); end;";
HibernateUtil.getSessionFactory().openStatelessSession().connection().prepareCall(sql).execute();
....Where HibernateUtil is just a mean to get to the SessionFactory. The connection I get is the same one as a JDBC, I think.
I would want to regain control of the application as soon as the procedure is called and continue with the rest of the logic.
How do I do that? Do I have to initiate it from a different thread?
ThanksIf it was me I wouldn't have a stored proc that took a while to complete. Instead I would submit a job to job queue. In terms of implementation I would call a proc that writes a record to a table. Then a process in the database polls that table and runs jobs it finds there. Then reports results somewhere.
Sometime later you collect the results.
But without that then the solution in java is obvious - create a thread. -
Calling a Oracle stored procedure in orchestrator
I am trying to execute a stored procedure using the query database IP in orchestrator. I can select data from the oracle db so i know the prereqs are setup correctly but it fails on executing the stored procedure.
The syntaxe is execute SPNAME('PARAM!','PARAM2')
The error is
Failed, Oracle failure Database error has occurred. ORA-00900: invalid SQL statement
Oracle query failure, please verify your query syntax is correct. Verify correct table names and column names etc...
The SP works fine in sql developer so im pretty sure the syntax is correct unless the Query Database IP needs a different syntax to work.simple as that. i actually tried something similar since that is how SCOM executes SP but left the execute command in there so it failed and i moved on. thanks for the reply.
Just for reference i went the powershell route and that worked as well but much more complicated then your solution. for anyone that wants to know the script is
$asm = [System.Reflection.Assembly]::LoadWithPartialName("System.Data.OracleClient")
$connectionString = "Data Source=TNSNAME;uid=USERID;pwd=PASSWORD";
$inputString1 = "PARAMETER INPUT 1";
$inputString2 = "PARAMETER INPUT 2"
$oracleConnection = new-object System.Data.OracleClient.OracleConnection($connectionString);
$cmd = new-object System.Data.OracleClient.OracleCommand;
$cmd.Connection = $oracleConnection;
$cmd.CommandText = "SP NAME";
$cmd.CommandType = [System.Data.CommandType]::StoredProcedure;
$cmd.Parameters.Add("NAME OF EXPECTED PARAMETER 1", [System.Data.OracleClient.OracleType]::NUMBER) | out-null;
$cmd.Parameters["NAME OF EXPECTED PARAMETER 1"].Direction = [System.Data.ParameterDirection]::Input;
$cmd.Parameters["NAME OF EXPECTED PARAMETER 1"].Value = $inputString1;
$cmd.Parameters.Add("NAME OF EXPECTED PARAMETER 2", [System.Data.OracleClient.OracleType]::VARCHAR2) | out-null;
$cmd.Parameters["NAME OF EXPECTED PARAMETER 2"].Direction = [System.Data.ParameterDirection]::Input;
$cmd.Parameters["NAME OF EXPECTED PARAMETER 2"].Value = $inputString2;
$oracleConnection.Open();
$cmd.ExecuteNonQuery() | out-null;
$oracleConnection.Close();
got help from http://dovetailsoftware.com/clarify/gsherman/2012/05/15/calling-oracle-stored-procedures-using-powershell/ -
XI calling an Oracle Stored Procedure which returns an Object to XI
I am currently trying to call an Oracle Packaged/Procedure from XI which accepts a couple of parameters as I/O and returns an Object as one of the parameters.
I have created the Object within the Oracle Database CREATE OR REPLACE TYPE xy_jdbc AS OBJECT
column_name type ...etc
CREATE OR REPLACE TYPE xy_tab_jdbc AS TABLE OF xy_jdbc;
One of the parameters for the stored procedure is set up as this type xy_tab_jdbc this will be populated based upon one of the parameters passed into the Package/Procedure.
Is this possible? If it is, how do I map the returned object within XI?Dear Hilary,
the JDBC adapter does not support vendor-specific or non-scalar data types.
Workaround: Change the stored proc's signature not to use an object, but the object's fields instead.
Regards,
Thilo -
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 -
Problem with output data when calling into Oracle stored procedure
I have a problem that I think I've seen posted by others, but I can't find it anywhere on the forum. Here's what it looks like:
I have a application that sends a query parameter called custID in a URL to a JSP page.
http://domain.com/decrypt.jsp?custID=ewsw
The JSP subsequently calls into the method below to run a decryption stored procedure on an Oracle db. The custId parameter works fine from most clients. However, I have seen the decryption stored procedure return invalid information on some clients in the following case:
http://domain.com/decrypt.jsp?custID='eirwx
Here is how I define my call to the DCUSTID (decryption stored procedure):
public long dCustID(String sCustID)throws SQLException {
CallableStatement cs = null;
try {
long nCustID = 0;
if(conn == null || conn.isClosed()) {getLocalConnection();}
String sp = "BEGIN DCUSTID(?,?);END;";
cs = conn.prepareCall(sp);
cs.setString(1, sCustID);
cs.registerOutParameter(2,java.sql.Types.NUMERIC);
cs.execute();
nCustID = cs.getLong(2);
return nCustID;
}finally { release(cs); }
I have not been able to find a problem with the stored procedure (although Im not counting that out). Is there any way that the jsp or the code above is corrupting the data before it gets to the stored procedure? I'm very suspicious of the single quote at the begining of the custID query string parameter.
Thanks>
The JSP subsequently calls into the method below to
run a decryption stored procedure on an Oracle db.
The custId parameter works fine from most clients.
However, I have seen the decryption stored procedure
e return invalid information on some clients in the
following case:
The back tick doesn't matter.
How do you know that the routine that you posted returns invalid information? Are you printing the value retreived before you return in the code that you posted? That is the only way to tell if that code is the problem vs some translation problem in something else.
And what do you mean by 'invalid'? It does return a numeric value right? Is it negative? Or so large that it couldn't be a key? Or what?
The input parameter to the stored proc is a varchar and not a char correct? -
Calling an Oracle stored procedure and retrieving result from OUT parameter
Hello,
I have a stored procedure that returns a string in an OUT parameter after receiving 6 IN parameters. I have tested the procedure in PL/SQL and it's producing the right output there. The problem is when I call the stored procedure from my Java method. I then get an error message telling me that I have the wrong number or types of arguments in my procedure call. I have checked that the method receives and sends the correct data in the correct order and I'm not sure what else the error message can relate to...?
The exception is called on my second try statement but I haven't been able to find out what I have done wrong there. Does anyone have any suggestions? Thanks.
the error message
java.sql.SQLException: ORA-06550: line 1, column 13: PLS-00306: wrong number or types of arguments in call to 'P_SET_GIVEN_ANSWER' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
the procedure
CREATE OR REPLACE PROCEDURE p_set_given_answer(
strfeedback OUT VARCHAR2,
intpi_id IN INTEGER,
intquestion_id IN INTEGER,
intgivenanswer IN INTEGER,
strgivenprefix IN VARCHAR2,
strgivenunit IN VARCHAR2,
strgu_id IN VARCHAR2) AS
-- some declarations
BEGIN
-- some processing and then returns the string below indicating the outcome
strfeedback = 'result';
END
the java method (the class is called dbUtil and the database connection is created in the method called getDbConnection() )
public void setGivenAnswer(int intPi_id, int intQuestion_id, int intGivenAnswer, String strGu_id, String strGivenPrefix, String strGivenUnit) {
java.sql.Connection con = null;
String query = "{call ? := p_set_given_answer(?,?,?,?,?,?)}";
try {
con = dbUtil.getDbConnection();
} catch(Exception e) {
dbConnectionExceptionMessage = "error 1:"+e.toString();
try{
CallableStatement stmt = con.prepareCall(query);
// register the type of the out param - an Oracle specific type
stmt.registerOutParameter(1, OracleTypes.VARCHAR);
// set the in params
stmt.setInt(2, intPi_id);
stmt.setInt(3, intQuestion_id);
stmt.setInt(4, intGivenAnswer);
stmt.setString(5, strGivenPrefix);
stmt.setString(6, strGivenUnit);
stmt.setString(7, strGu_id);
// execute the stored procedure
stmt.execute();
// retrieve the results
strFeedback = stmt.getString(1);
} catch (java.sql.SQLException e) {
dbConnectionExceptionMessage = "error 2:"+e.toString();
try {
con.close();
} catch (java.sql.SQLException e) {
dbConnectionExceptionMessage = "error 3:"+e.toString();
----------------------------------------Looks like you are declaring a procedure, but you are calling it like a function. A procedure has no return value, it has only parameters: "{call p_set_given_answer(?,?,?,?,?,?,?)}"
-
Problem with Update Select in Stored procedure
I am using Oracle 8. I'm writing a StoredProcedure and Oracle doesn't like the statement:
update
Leave_Coverages
set
Rate_Monthly = Rate_Monthly + (select Rate_Monthly from Leave_coverages where Leave_Coverage_ID = 10800)
where
Leave_Coverage_ID = 10799;
When I run the above statement from the command line - I have no problem. This statement in the stored procedure works:
update
Leave_Coverages
set
Rate_Monthly = Rate_Monthly + 4
where
Leave_Coverage_ID = 10799;
So essentially, I'm having trouble using a select in an update statement, but only in a Stored Procedure.Denis,
This question was answered on this forum in the last week or so but I wasn't quickly able to locate this post.
Basically Oracle prior to version 9 had an SQL parser and a separate PL/SQL parser. The PL/SQL parser had to be updated each time new features were added to the SQL parser; often it lagged behind so that there were things you could do in plain SQL but weren't supported when using the same SQL in a cursor or directly in PL/SQL (with an INTO clause or RETURNING ... INTO clause).
From Oracle 9 these two parsers have been rolled into one so that new features introduced into SQL automatically also become available when used from PL/SQL.
So the answer to your curiousity on whether it will work in 9 or 10 is: if it works in SQL it should work just fine from PL/SQL.
Cheerio,
Colin -
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 an Oracle stored procedure
Hello,
I already succeed to call a stored procedure in Oracle but only simple
ones with one output value and several inputs. I don't any idea left
so any help would be great :) Thanks
But on one procedure, i'm having a prb: I get an error:
java.sql.SQLException: ORA-06502: PL/SQL: numeric or value error:
character string buffer too smalljava.sql.SQLException: ORA-06502:
PL/SQL: numeric or value error: character string buffer too small
In the product documentation, they don't give any information about
the out/in parameters...
They just describe:
procedure creationEnteteBLC
codeTiers VARCHAR2 client code
codeDepot VARCHAR2 don't set it
dateDocument DATE document date
codeDocUtil VARCHAR2 code generated for the document
codeDocInterne NUMBER Code generated for the lines, use it to create
lines
NUMBER indicate if all was fine...
And this is my code
cs = connOracle.prepareCall("{call ? := APISOFT_DOS_" + dossier +
".GES_APPEL_EXT.CREATIONENTETEBLC(?,?,?,?,?)}");
cs.registerOutParameter(1, Types.INTEGER);
cs.setString(2, "411AGUT01");
cs.setNull(3, Types.VARCHAR);
Date date = new Date(2005, 1, 1);
cs.setDate(4, date );
String codeDocUtil ="";
cs.registerOutParameter(5, Types.VARCHAR);
cs.setString(5, codeDocUtil );
int codeDocInterne =1;
cs.registerOutParameter(6, Types.INTEGER);
cs.setInt(6, codeDocInterne );
cs.execute();
And I get
java.sql.SQLException: ORA-06502: PL/SQL: numeric or value error:
character string buffer too smalljava.sql.SQLException: ORA-06502:
PL/SQL: numeric or value error: character string buffer too small
Any help will be more than welcome...
PS: It's a strange release of Oracle.. I cannot use the metadata api
to figure out the procedures parameters.
Thanks for any help!
Stéphane TRAUMAT
scub.net
+33 (0)6 18 39 77 25Stephane,
In your code, you are registering "out" parameters, and then assigning them values. Does this mean that these parameters are "in-out" parameters?
Your code contains the following lines:
Date date = new Date(2005, 1, 1);
cs.setDate(4, date );The constructor you are using is deprecated (according to the documentation for JDK 1.4.2). Also, you should be using "java.sql.Date" class and not "java.util.Date" class.
Perhaps you could post the entire error message and stack trace you are receiving? Also, the following information may also be of help:
1. Oracle database version.
2. Java version.
3. JDBC driver.
For your information, the following Web page has links to sample code that may be helpful:
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
Good Luck,
Avi. -
How to call a Oracle Stored Procedure from Excel?
Hi,
I am new to Oracle database programming.I have an application in excel which has to update info in every row to the database.I am calling a stored procedure in excel for this.The stored procedure is as follows which is executing without a hitch in Oracle:
CREATE OR REPLACE PROCEDURE APD_MASS_UPLOAD_UNITS
(PRODUCT_ID VARCHAR2,Product_Code VARCHAR2, str_Adpt_Grp VARCHAR2,str_Adpt_Type VARCHAR2,
str_PDC VARCHAR2,str_Release_ID VARCHAR2,str_Created_by VARCHAR2,
str_Last_Updated_By VARCHAR2, dt_created_Date VARCHAR2,dt_Last_Updated_Date VARCHAR2,
StrMonth1 VARCHAR2,strMth2 VARCHAR2,StrMth3 VARCHAR2,StrMth4 VARCHAR2,
StrMth5 VARCHAR2,StrMth6 VARCHAR2,Sample Varchar2,str_message OUT Varchar2)
AS
type Month_type is table of VARCHAR2(10) index by binary_integer;
str_month Month_Type;
Fac_ID VARCHAR2(20);
Org_ID VARCHAR2(20);
Cnt_Units NUMBER;
i_POS NUMBER;
i_Month NUMBER;
i_UNITS NUMBER;
CURSOR C1 IS
SELECT * FROM TBLLINE_ADOPT_PLAN WHERE SPEC_ID = Product_ID AND
ADOPT_GROUP = str_Adpt_Grp AND ADOPT_TYPE = str_Adpt_Type
AND RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_Id);
CURSOR C2 IS
SELECT FACILITY_ID FROM TBLADOPT_GROUP_CSC WHERE ADOPT_GROUP = str_Adpt_Grp;
CURSOR C3 IS
SELECT ORG_ID FROM APD_DV_PRODUCT_V WHERE SPEC_ID = Product_ID;
CURSOR C4 IS
SELECT * FROM TBLPROD_CSC WHERE PROD_SPEC_ID = Product_ID;
Adopt_Rec C1%ROWTYPE;
Fac_Rec C2%ROWTYPE;
PMORG_REC C3%ROWTYPE;
CSC_Rec C4%ROWTYPE;
i_Count NUMBER;
Message VARCHAR2(20);
BEGIN
Message := APD_SPECID_VALIDATE(Product_ID,Product_code,Str_PDC, str_Release_ID);
IF TRIM(Message) is null then
OPEN C1;
FETCH C1 INTO Adopt_Rec;
IF C1%NOTFOUND THEN
INSERT INTO TBLLINE_ADOPT_PLAN (SPEC_ID,ADOPT_GROUP, ADOPT_TYPE,RELEASE_ID, SAMPLES,CREATED_BY,CREATED_DATE, LAST_UPDATED_BY,LAST_UPDATED_DATE,SAMPLE_ONLY_IND, GRID_TYPE_CD) VALUES
(Product_ID,str_Adpt_Grp ,str_Adpt_Type,
APD_Get_Release_ID(str_PDC,str_Release_Id), 0,str_Created_By,
TO_DATE(dt_Created_Date,'DD/MM/YYYY'),str_Last_Updated_By,
TO_DATE(dt_Last_Updated_Date,'DD/MM/YYYY'),'N','C');
END IF;
CLOSE C1;
str_Month(1) := strMonth1;
str_Month(2) := strMth2;
str_Month(3) := strMth3;
str_Month(4) := strMth4;
str_Month(5) := strMth5;
str_Month(6) := strMth6;
OPEN C2;
FETCH C2 INTO Fac_REC;
Fac_ID := Fac_Rec.FACILITY_ID;
CLOSE C2;
OPEN C3;
FETCH C3 INTO PMORG_Rec;
Org_ID := PMORG_Rec.Org_ID;
CLOSE C3;
OPEN C4;
FETCH C4 INTO CSC_Rec;
IF C4%NOTFOUND THEN
INSERT INTO TBLPROD_CSC(PROD_SPEC_ID,CSC_FACILITY_ID, PROFIT_CENTER_CD,DEFAULT_IND, CREATED_BY, CREATED_DATE, LAST_UPDATED_BY, LAST_UPDATED_DATE) VALUES
(Product_ID , Fac_ID,Org_id, 'N', str_Created_by ,
To_date ( dt_Created_Date,'DD/MM/YYYY') ,str_Last_updated_by ,
To_Date (dt_Last_Updated_Date ,'DD/MM/YYYY'));
END IF;
CLOSE C4;
IF Sample > 0 Then
UPDATE TBLLINE_ADOPT_PLAN
SET SAMPLES = Sample
WHERE SPEC_ID = Product_ID AND
ADOPT_GROUP = str_adpt_grp AND
ADOPT_TYPE = str_Adpt_Type AND
RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_Id);
END IF;
str_Message := 'Updated';
END IF;
END;
The code to call the stored procedure in Excel is as follows:
Dim Conn As New ADODB.Connection
Dim InputParam1 As New ADODB.Parameter
Dim InputParam2 As New ADODB.Parameter
Dim InputParam3 As New ADODB.Parameter
Dim InputParam4 As New ADODB.Parameter
Dim InputParam5 As New ADODB.Parameter
Dim InputParam6 As New ADODB.Parameter
Dim InputParam7 As New ADODB.Parameter
Dim InputParam8 As New ADODB.Parameter
Dim InputParam9 As New ADODB.Parameter
Dim InputParam10 As New ADODB.Parameter
Dim InputParam11 As New ADODB.Parameter
Dim InputParam12 As New ADODB.Parameter
Dim InputParam13 As New ADODB.Parameter
Dim InputParam14 As New ADODB.Parameter
Dim InputParam15 As New ADODB.Parameter
Dim InputParam16 As New ADODB.Parameter
Dim InputParam17 As New ADODB.Parameter
Dim InputParam18 As New ADODB.Parameter
Dim OutputParam As New ADODB.Parameter
Dim Mth1, Mth2, Mth3, Mth4, Mth5, Mth6 As String
Dim Rs_data As New ADODB.Recordset
Conn.ConnectionString = ("Provider=MSDAORA.1;User ID=" & "cnbg" & ";PASSWORD=" & "cnbg" & ";Data Source=" & "DAQ01" & ";Persist Security Info=False")
Conn.Open
OraCmd.ActiveConnection = Conn
OraCmd.CommandText = "APD_MASS_UPLOAD_UNITS"
OraCmd.CommandType = adCmdStoredProc
Conn.CursorLocation = adUseClient
OraCmd.Parameters.Refresh
Set InputParam1 = OraCmd.CreateParameter("Product_ID", adVarChar, adParamInput, 20)
InputParam1.Value = spec_id
Set InputParam2 = OraCmd.CreateParameter("Product_code", adVarChar, adParamInput, 20)
InputParam2.Value = str_product_code
Set InputParam3 = OraCmd.CreateParameter("str_Adpt_Type", adVarChar, adParamInput, 10)
InputParam3.Value = Adopt_Group
Set InputParam4 = OraCmd.CreateParameter("str_Adpt_Type", adVarChar, adParamInput, 10)
InputParam4.Value = Adopt_Type
Set InputParam5 = OraCmd.CreateParameter("str_pdc", adVarChar, adParamInput, 10)
InputParam5.Value = ThisWorkbook.strDbPDC
Set InputParam6 = OraCmd.CreateParameter("str_Release_ID", adVarChar, adParamInput, 10)
InputParam6.Value = str_Release_Id
Set InputParam7 = OraCmd.CreateParameter("str_created_by", adVarChar, adParamInput, 10)
InputParam7.Value = ThisWorkbook.User_Name
Set InputParam8 = OraCmd.CreateParameter("str_last_updated_by", adVarChar, adParamInput, 10)
InputParam8.Value = ThisWorkbook.User_Name
Set InputParam9 = OraCmd.CreateParameter("dt_created_date", adVarChar, adParamInput, 10)
InputParam9.Value = Sheet1.Cells(8, 2)
Set InputParam10 = OraCmd.CreateParameter("dt_Last_Updated_Date", adVarChar, adParamInput, 10)
InputParam10.Value = Sheet1.Cells(8, 2)
Set InputParam11 = OraCmd.CreateParameter("strMonth1", adVarChar, adParamInput, 10)
InputParam11.Value = Mth1
Set InputParam12 = OraCmd.CreateParameter("strMth2", adVarChar, adParamInput, 10)
InputParam12.Value = Mth2
Set InputParam13 = OraCmd.CreateParameter("strMth3", adVarChar, adParamInput, 10)
InputParam13.Value = Mth3
Set InputParam14 = OraCmd.CreateParameter("strMth4", adVarChar, adParamInput, 10)
InputParam14.Value = Mth4
Set InputParam15 = OraCmd.CreateParameter("strMth5", adVarChar, adParamInput, 10)
InputParam15.Value = Mth5
Set InputParam16 = OraCmd.CreateParameter("strMth6", adVarChar, adParamInput, 10)
InputParam16.Value = Mth6
Set InputParam17 = OraCmd.CreateParameter("Sample", adInteger, adParamInput, 10)
InputParam17.Value = 0
Set InputParam18 = OraCmd.CreateParameter("str_message", adVarChar, adParamOutput, 10)
OraCmd.Parameters.Append InputParam1
OraCmd.Parameters.Append InputParam2
OraCmd.Parameters.Append InputParam3
OraCmd.Parameters.Append InputParam4
OraCmd.Parameters.Append InputParam5
OraCmd.Parameters.Append InputParam6
OraCmd.Parameters.Append InputParam7
OraCmd.Parameters.Append InputParam8
OraCmd.Parameters.Append InputParam9
OraCmd.Parameters.Append InputParam10
OraCmd.Parameters.Append InputParam11
OraCmd.Parameters.Append InputParam12
OraCmd.Parameters.Append InputParam13
OraCmd.Parameters.Append InputParam14
OraCmd.Parameters.Append InputParam15
OraCmd.Parameters.Append InputParam16
OraCmd.Parameters.Append InputParam17
OraCmd.Parameters.Append InputParam18
Set Rs_data = New ADODB.Recordset
Set Rs_data = OraCmd.Execute
I am getting an error at this point which
ORA-06550:line 1,column 54:
PLS-00103:Encountered the symbol ">" when expecting one of the following:
. ( ) * @ % & = - + < / > at in is mod not rem
<an exponent(**)> <> or != or ~= or >= <= <> and or like
between ||
Can anyone pls help me?Thanks.You do not need to code an explicit cursor for a single fetch. An implicit cursor is less code to write, read, maintain and execute.
E.g. Instead of all this:
CURSOR C2 IS
SELECT FACILITY_ID FROM TBLADOPT_GROUP_CSC WHERE ADOPT_GROUP = str_Adpt_Grp;
OPEN C2;
FETCH C2 INTO Fac_REC;
Fac_ID := Fac_Rec.FACILITY_ID;
CLOSE C2;
Simply code this:SELECT
Fac_Rec.FACILITY_ID INTO Fac_ID
FROM BLADOPT_GROUP_CSC
WHERE ADOPT_GROUP = str_Adpt_Grp;PL/SQL procedure calls have to be made (to Oracle) as anonymous PL/SQL blocks. This means that you need to wrap the procedure call into BEGIN..END tags.
So instead of coding this:
OraCmd.CommandText = "APD_MASS_UPLOAD_UNITS"
You need to code something like:
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS; END;"
However, this will not work as APD_MASS_UPLOAD_UNITS expects a bunch of input parameters. And you're on the right track about attempting to bind your Excel variables' values to the PL/SQL procedure's parameters.
Unsure how ADO works, but typically you can bind by name or by position. Let's assume bind by position (typically in PHP):
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS( ?, ?, ?, ?, ?. ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); END;"
Then you will bind values to positions 1 to 18 (did I count the number of params right?). Something like:
OraCmd.CreateParameterByPosition( 1, adVarChar, adParamInput, 20)
Or you can bind by name. E.g.
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS( :pid, :pcode, ..etc.. ); END;"
And:
OraCmd.CreateParameterByName( 'pid', adVarChar, adParamInput, 20)
Read up on your OraCmd.CreateParameter() to see how to correctly use it.
A few more comments. 18 parameters in a call is something I would seriously reconsider. It is quite easy to get it wrong - transpose two parameters. It is very difficult to read and check. Very difficult to maintain. It is much safer to rather define a %ROWTYPE structure to pass, or a PL/SQL record structure.
You are passing date values as VARCHAR2. Rather pass the parameter as the correct data type. E.g.
create or replace procedure foo( custID number, invoiceDate date )...
And then when you call it (in your client code), you specify the date string and date format and make it into a date. E.g.
OraCmd.CommandText = "begin foo( :myCust, TO_DATE(:myDateString,:myDateFormat) ); end;" -
Problem with temporary table in stored procedure
Hi,
I have to execute a stored procedure in java , where the stored procedure has refcursor as out parameter and within the procedure the refcursor out parameter is populated from a temporary table
when iam trying to get the resultset in my program iam getting the oracle error: ora-08103 object is no longer in use.
I think this is becos the temporary table object is not available to my program
can any one please help meI don't understand this part.
Your procedure has "argSchemaName" as input parameter. Why do you have hardcoded owner name here in the cursor?
>>
CURSOR csrEligTables IS
SELECT
object_name
FROM
all_objects
WHERE
Owner = 'HI0XXX001'
AND
>>
The anonymous block that you are running also has same owner name. -
Problem with teporary table in stored procedure
Hi,
I have to execute a stored procedure in java , where the stored procedure has refcursor as out parameter and within the procedure the refcursor out parameter is populated from a temporary table
when iam trying to get the resultset in my program iam getting object is no longer in use.
I think this is becos the temporary table object is not available to my program
can any one please help meI don't understand this part.
Your procedure has "argSchemaName" as input parameter. Why do you have hardcoded owner name here in the cursor?
>>
CURSOR csrEligTables IS
SELECT
object_name
FROM
all_objects
WHERE
Owner = 'HI0XXX001'
AND
>>
The anonymous block that you are running also has same owner name. -
Calling an oracle stored procedure with output parameter
Hi,
I am trying to execute a procedure with 2 input and 1 output parameters by using SQLQuery. I tried each mode (Command, FixedQuery & FixedQueryWithOutput) with following statements.
call cm_test_prod([Param.1],[Param.2],[Param.3])
Error:"missing expression "
call cm_test_prod([Param.1],[Param.2],?)
Error:"wrong number or types of arguments in call to 'CM_TEST_PROD'"
call cm_test_prod([Param.1],[Param.2],:var)
Error:"wrong number or types of arguments in call to 'CM_TEST_PROD' "
or
Error: "not all variables bound"
If I use without output parameter, in Command mode, It works fine.
call cm_test_prod([Param.1],[Param.2])
or
call cm_test_prod('[Param.1]','[Param.2]')
works without error.
SAP XMII: Version 12.0.5 Build(126)
Oracle 10G
Any help would be greatly appreciated.
Thanks,
Tunur.
Edited by: Namik Tunur on Dec 14, 2010 3:34 PM
Edited by: Namik Tunur on Dec 14, 2010 3:36 PMHi,
@Marcelo,
I used your package just by replacing 'varchar2' instead of 'varchar(100)''. I got the error message 'ORA-00900: invalid SQL statement'. I didn't understand how we handle output parameter with this:
Query = Call MYPKG.MyProcedure(1,'Test FixedQueryWithOutput',?)
What is Query in here? If we have two output parameters, how would we get the outputs?
My procedure is:
CREATE OR REPLACE
PROCEDURE XXXXX.CM_TEST_PROD_OUTPUT(v1 in number,v2 in number, v3 out number) IS
BEGIN
update test_table set no2 = (v1+v2);
commit;
v3 := v1+v2;
END;
declare
a number;
BEGIN
cm_test_prod_output(1,6,a);
END;
if I use this
call cm_test_prod_output([Param.1],[Param.2],?)
with FixedQueryWithOutput mode,
I get the following error:
ORA-06553: PLS-306: wrong number or types of arguments in call to 'CM_TEST_PROD_OUTPUT'
@Mike,
I already tried both with quotes and without quotes, also I tried both with number output and with string output.
As I mentioned before, if I use number inputs without output in Command mode,
call cm_test_prod(http://Param.1,http://Param.2)
or
call cm_test_prod('http://Param.1','http://Param.2')
works succesfully.
Regards,
Tunur
Maybe you are looking for
-
Previewer for office files is not working from the same application: i.e. can't preview Excel files when attempting to open one from Excel, same with Word and PowerPoint. I can preview all files from Outlook, and, funny, I can preview files other tha
-
HT201262 how to reinstall main frame on macbook?
my macbook is behaving strange, I want to erase all HD and re-instal the new OS X Mavericks
-
Error AIP-50079 : Transport error: [IPT_HttpSendHostNotFound]
I was trying Tutorial 3 ( EDI X12 over AS2) from User's Guide. As per instruction, I have configured two B2B Servers. Both the servers are up and running. When I am enqueuing 850 message from Acme server, It's not going to the other server. The error
-
Ive downloaded and installed Lion. I wanted to burn it to a disk but it seems to be gone now and with no option to download. Where did it go?
-
Multiple field terminators in BULK INSERT or BCP
Can i have multiple field terminators in BULK INSERT or BCP commands i,e, define more than 1 for a file? Pls provide example.