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(?,?,?,?,?,?,?)}"

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 AM

    Making 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?
    Thanks

    If 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.

  • I have created stored procedure with %rowtype as IN OUT parameter.I want to

    i have created stored procedure with %rowtype as IN OUT parameter.I want to call it in java program

    Hi Avi,
    I have the same problem as the person asking before me, so I'll try and clarify:
    I have a Java client and a PL/SQL database procedure that looks something along the lines of:
    Create of Replace procedure myProc(myRow IN myTable%Rowtype)
    It's very easy to pass a parameter into this procedure from another procedure within the database because creating another myTable%Rowtype is not a problem.
    However, Java doesnt know what "Rowtype" is.
    I was wondering how I would pass a "rowtype" from Java.
    I was thinking along the lines of creating an object in the DB like that:
    Create Type myObj AS myTable%Rowtype (<-- is that even allowed?)
    And then create a procedure in the DB with the header:
    Create of Replace procedure myProc(myRow IN myObj)
    And then, in my Java,just create a STRUCT of my DB object and pass it to the DB:
    myCallableStatement.setObject(1, myStruct);
    Would that work?
    Is there a better way?
    Thanks,
    Dan

  • Dynamically calling stored procedure and getting result set c++

    Hello,
    I am trying to write some c++ code that will dynamically bind values to a stored procedure and excute the procedure and get back a resultset. The problem I am running into is how to get back the resultset. Any help or example would be highly appreciated.

    int main(int argc, char* argv[])
    OCIError* pOciError;
    char* pConnectChar = "dbname";
    char* pUsernameChar = "scott";
    char* pPasswordChar = "tiger";
    int answer;
    OCIStmt* pOciStatement;
    char* sqlCharArray = "BEGIN :success := sp_ListEmp; END;";
    int id;
    char ename[40];
    OCIEnv* g_pOciEnvironment = NULL;
    OCIServer* g_pOciServer = NULL;
    OCISession* g_pOciSession = NULL;
    OCISvcCtx* g_pOciServiceContext = NULL;
    sb2* pIndicator=0;
    sb2* pIndicator2=0;
    sb2* pIndicator3=0;
    OCIDefine* pOciDefine;
    OCIDefine* pOciDefine2;
    OCIBind* pBind;
    OCIStmt* cursor;
    answer = OCIInitialize(OCI_THREADED, NULL, NULL, NULL, NULL);
    answer = OCIEnvInit(&g_pOciEnvironment, OCI_DEFAULT, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciSession, OCI_HTYPE_SESSION, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciServer, OCI_HTYPE_SERVER, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
    answer = OCIServerAttach(g_pOciServer, pOciError, (unsigned char *)pConnectChar, strlen(pConnectChar),
    OCI_DEFAULT);
    answer = OCIAttrSet(g_pOciSession, OCI_HTYPE_SESSION, (unsigned char *)pUsernameChar, strlen(pUsernameChar),
    OCI_ATTR_USERNAME, pOciError);
    answer = OCIAttrSet(g_pOciSession, OCI_HTYPE_SESSION, (unsigned char *)pPasswordChar, strlen(pPasswordChar),
    OCI_ATTR_PASSWORD, pOciError);
    answer = OCIAttrSet(g_pOciServiceContext, OCI_HTYPE_SVCCTX, g_pOciServer, 0, OCI_ATTR_SERVER, pOciError);
    answer = OCIAttrSet(g_pOciServiceContext, OCI_HTYPE_SVCCTX, g_pOciSession, 0, OCI_ATTR_SESSION, pOciError);
    answer = OCISessionBegin(g_pOciServiceContext, pOciError, g_pOciSession, OCI_CRED_RDBMS, OCI_DEFAULT);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)(&pOciStatement), OCI_HTYPE_STMT, 0, NULL);
    answer = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray, strlen(sqlCharArray),
    OCI_NTV_SYNTAX, OCI_DEFAULT);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)(&cursor), OCI_HTYPE_STMT, 0, NULL);
    answer = OCIBindByPos(pOciStatement,&pBind, pOciError, 1, &cursor, 0,SQLT_RSET,
    pIndicator2, 0,NULL, 0,0,OCI_DEFAULT);
    answer = OCIStmtExecute(g_pOciServiceContext, pOciStatement, pOciError, 1, 0, NULL, NULL,
    OCI_COMMIT_ON_SUCCESS);
    answer = OCIDefineByPos(cursor,&pOciDefine, pOciError,2,&id,sizeof(int),
    SQLT_INT,pIndicator, 0, 0,OCI_DEFAULT);
    answer = OCIDefineByPos(cursor,&pOciDefine2, pOciError,1,ename,40,
    SQLT_STR,pIndicator3, 0, 0,OCI_DEFAULT);
    if (answer == 0)
    while ((answer = OCIStmtFetch(cursor,pOciError, 1,OCI_FETCH_NEXT,OCI_DEFAULT)) == 0)
    printf("fetched id %d and name %s\n",id,ename);
    answer = OCIHandleFree(pOciError, OCI_HTYPE_ERROR);
    return 0;

  • 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
    Jay

    spacetorrent escribi&oacute;:
    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

  • 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

  • Oracle stored Procedure and Packages in CR4E

    Hi,
    I want to use Stored Procedure in CR4E. I don't know how to use Stored Procedures and packages in Crystal Reports for Eclipse. In the data source explorer I can only see the Tables, Views and Stored Procedures but not packages from my Schema and when I can only drag & drop the Tables and Views into the Field Explorer, I can't drag & Drop the Stored Procedures.
    I managed to attached the stored procedure from CR studio. I opened the report in CR4E and I can see the stored procedure and can preview the data. When I try to run the report and override the datasource, it throws oracle error saying "ORA-01008: Not all variables bound". When I tried to use the option
    DBOptions._doNotVerifyDB
    while replacing connection I get the this error
    java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
         at java.lang.Boolean.compareTo(Boolean.java:26)
         at com.crystaldecisions.sdk.occa.report.lib.ClonableMap.hasContent(ClonableMap.java:112)
         at com.crystaldecisions.client.helper.CloneUtil.hasContent(CloneUtil.java:135)
         at com.crystaldecisions.sdk.occa.report.data.ConnectionInfo.hasContent(SourceFile:151)
         at com.crystaldecisions.client.helper.CloneUtil.hasContent(CloneUtil.java:135)
         at com.crystaldecisions.sdk.occa.report.data.Table.hasContent(SourceFile:286)
         at com.crystaldecisions.sdk.occa.report.data.Procedure.hasContent(SourceFile:212)
         at com.crystaldecisions.sdk.occa.report.lib.ArrayListMerger.haveMatchingContent(ArrayListMerger.java:232)
         at com.crystaldecisions.sdk.occa.report.lib.ArrayListMerger.mergePass(ArrayListMerger.java:138)
         at com.crystaldecisions.sdk.occa.report.lib.ArrayListMerger.merge(ArrayListMerger.java:86)
         at com.crystaldecisions.sdk.occa.report.lib.ControllableList.copyTo(ControllableList.java:68)
         at com.crystaldecisions.sdk.occa.report.data.Database.copyTo(SourceFile:105)
         at com.crystaldecisions.sdk.occa.report.lib.ControllableHelper.copyToPreservingReferences(ControllableHelper.java:153)
         at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.a(SourceFile:2556)
         at com.crystaldecisions.sdk.occa.report.application.b9.onDataSourceChanging(SourceFile:315)
         at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(SourceFile:971)
         at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(SourceFile:4078)
         at com.crystaldecisions.sdk.occa.report.application.bv.new(SourceFile:121)
         at com.crystaldecisions.sdk.occa.report.application.bv.int(SourceFile:91)
         at com.crystaldecisions.proxy.remoteagent.UndoUnitBase.performDo(SourceFile:151)
         at com.crystaldecisions.proxy.remoteagent.UndoUnitBase.a(SourceFile:106)
         at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(SourceFile:2159)
         at com.crystaldecisions.sdk.occa.report.application.DatabaseController.mapFields(SourceFile:4061)
         at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(SourceFile:3914)
         at com.crystaldecisions.sdk.occa.report.application.DatabaseController.replaceConnection(SourceFile:3880)
         at
    Please advice if Stored procedures and packages are supported in CR4E ?

    Hi, Jack76,
    According to the [CR4E Release Notes|http://help.sap.com/businessobject/product_guides/cr4E/en/cr4e_relnotes_en.pdf] (available from the [CR4E Download page|http://www.businessobjects.com/campaigns/forms/downloads/crystal/eclipse/datasave.asp]), stored procedures are supported, as long as they don't use parameters that need null values.
    I don't see any references to packages.
    Bryan

  • 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();
              }

  • Help me in calling stored procedure and getting results

    hi
    i have a SP like this
    CREATE OR REPLACE PACKAGE P1 AS
    TYPE g_con_ref_cursor is REF CURSOR ;
    TYPE g_con_error IS RECORD
      error_code NUMBER,
      error_desc varchar2(2000)
    PROCEDURE PROC_CURSOR
    (i_str_userid  IN VARCHAR2,
      o_cur_ref_cur OUT g_con_ref_cursor,
      o_rec_error   OUT g_con_error,
      o_num_status  OUT NUMBER);
    END;
    and i now i am trying to call this SP using my java program
    i am able to register the out put params for 2nd and 4 th variable
    my doubt is how i can register the output param for g_con_errorand how i can get result from this ????
    my java program is like this
    Connection connection = DatabaseHelper.prepareConnection();
    CallableStatement proc = connection.prepareCall("{ call P1.PROC_CURSOR(?, ?, ?, ?) }");
    proc.setString(1,"jn26557");
    proc.registerOutParameter(2,oracle.jdbc.driver.OracleTypes.CURSOR);
    proc.registerOutParameter(3,Types.STRUCT,); //HOW TO SET  THIS ?????
    proc.registerOutParameter(4,oracle.jdbc.driver.OracleTypes.NUMERIC);
    proc.execute();
    plz help me in this
    i have no idea how to do it
    any help would be appreciated
    Thanks in advance
    Jaya Prakash Nalajala

    You have the requirements to build the stored procedure, what have you got so far?
    Post your attempt and any errors or issues that you might be experiencing. Writing the whole procedure for you (without the table structure even) is going to be difficult.

  • 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,
    Roman

    I 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

  • 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 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

    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 25

    Stephane,
    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.

Maybe you are looking for