OCCI RegisteroutParam Callable  Statement

Hi.
I have a problem with a OUT parameter in a PL/SQL , when I try to read it with occi.
In my OCCI program:
Number pnum;
Statement *stmt;
stmt = con->createStatement("BEGIN demo_proc ( :PAR_EJE_NUM );END");
stmt->registerOutParam(1,OCCINUMBER,sizeof(pnum));
int nout = stmt->executeUpdate();
PL/SQL
CREATE OR REPLACE PROCEDURE "AQ"."demo_proc"
( PAR_EJE_NUM OUT NUMBER ) IS
BEGIN
PAR_EJE_NUM := 12345;
END;
When I execute the OCCI program , an unexcepted error ocurred:
Excepcion Bloque Codigo SQLExcep
ORA-06502: PL/SQL; numeric or value error
ORA-06512: at line 1
If the number is less than 9999 , the error doesn`t occur.
Also, if I change to:
registerOutParam(1,OCCIFLOAT,100);
don`t get any error messages.
Any idea what is causing this ?
The BD is Oracle 9.2.0.2.0 and our compiler is aCC 03.39.
Thanks

seems to be a bug. Try OCCIINT and stmt->getInt(1).
The size argument for registerOutParam is ignored for numeric types.

Similar Messages

  • Using A callable statement in java

    Hi all im trying to get results back from the database using a callable statement the problem is that it is placing / infront of single quotes.I need to get rid of this because it's not returning anything
    here is my code
    CallableStatement statementOne;
    statementOne = ComparitiveAnalysisGUI.conn.prepareCall("{call graphProc(?,?,?,?,?,?,?)}");
    statementOne.setString(1,"\"date_format(calldate, '%Y-%m-%d H:59:59'),avg(billsec)\"");
    statementOne.setString(2,"Clovercdr");
    statementOne.setString(3,start);
    statementOne.setString(4,end);
    statementOne.setString(5,"Boksburg");
    statementOne.setString(6,"\"billsec > 0 and Network = " + network + "\"");
    statementOne.setString(7,"\"date_format(calldate, '%Y-%m-%d %H:M:S')\"");
    System.out.println(statementOne.toString());
    rs = statementOne.executeQuery();
    the result of the println is
    com.mysql.jdbc.CallableStatement@ec4a87: CALL graphProc('"date_format(calldate, \'%Y-%m-%d %H:59:59\'),avg(billsec)"','Clovercdr','\'2006-03-14 00:00:01\'','\'2006-03-14 23:59:59\'','Boksburg','"billsec > 0 and Network = \'SAMobile\'"','"date_format(calldate, \'%Y-%m-%d %H:M:S\')"')
    as you can see quite a mess please help if you can get the statement to look as follows
    CALL graphProc("date_format(calldate, '%Y-%m-%d %H:59:59'),avg(billsec)",'Clovercdr','2006-03-14 00:00:01','2006-03-14 23:59:59','Boksburg',"billsec > 0 and Network = 'SAMobile'","date_format(calldate, '%Y-%m-%d %H:M:S')")
    thanks Brian

    Ok in order to understand why I did what I did parhaps it would be best if you saw my Stored procedure
    create procedure graphProc(col varchar(100),company varchar(20),startTime datetime,endTime datetime,branchName varchar(20),andSection varchar(200),groupSec varchar(100))
    BEGIN
    SET @stmt := CONCAT("SELECT ",col," from ",company," where calldate between '",startTime,"' and '",endTime,"' and branchName = '",branchName,"' and ",andSection," Group by ",groupSec);
    PREPARE stmt1 from @stmt;
    EXECUTE stmt1;
    the call is for example
    call graphProc("date_format(calldate, '%Y-%m-%d %H:59:59'),avg(billsec)",'Clovercdr','2006-03-01 00:00:01','2006-03-14 23:59:59','Boksburg',"billsec > 0 and date_format(calldate, '%k') BETWEEN 7 AND 19 and Network = 'SAMobile'","date_format(calldate, '%Y-%m-%d %H:M:S')")//
    as you can see In MySQL the "date_format(calldate, '%Y-%m-%d %H:59:59'),avg(billsec)" has to be quoted like this, so it can recognise it as a single parameter, since , '%Y-%m-%d %H:59:59' is viewed as another parameter
    thaks for your reply
    Brian

  • Return records from Stored Procedure to Callable Statement

    Hi All,
    I am createing a web application to display a students score card.
    I have written a stored procedure in oracle that accepts the student roll number as input and returns a set of records as output containing the students scoring back to the JSP page where it has to be put into a table format.
    how do i register the output type of "records" from the stored function in oracle in the "registerOutParameter" method of the "callable" statement in the JSP page.
    if not by this way is there any method using which a "stored function/procedure" returning "record(s)" to the jsp page called using "callable" statement be retrieved to be used in the page. let me know any method other that writing a query for the database in the JSP page itself.

    I have a question for you:
    If the stored procedure is doing nothing more than generating a set of results why are you even using one?
    You could create a view or write a simple query like you mentioned.
    If you're intent on going the stored procedure route, then I have a suggestion. Part of the JDBC 2.0 spec allows you to basically return an object from a CallableStatement. Its a little involved but can be done. An article that I ran across a while back really helped me to figure out how to do this. There URL to it is as follows:
    http://www.fawcette.com/archives/premier/mgznarch/javapro/2000/03mar00/bs0003/bs0003.asp
    Pay close attention to the last section of the article: Persistence of Structured Types.
    Here's some important snippets of code:
    String UDT_NAME = "SCHEMA_NAME.PRODUCT_TYPE_OBJ";
    cstmt.setLong(1, value1);
    cstmt.setLong(2, value2);
    cstmt.setLong(3, value3);
    // By updating the type map in the connection object
    // the Driver will be able to convert the array being returned
    // into an array of LikeProductsInfo[] objects.
    java.util.Map map = cstmt.getConnection().getTypeMap();
    map.put(UDT_NAME, ProductTypeObject.class);
    super.cstmt.registerOutParameter(4, java.sql.Types.STRUCT, UDT_NAME);
    * This is the class that is being mapped to the oracle object. 
    * There are two methods in the SQLData interface.
    public class ProductTypeObject implements java.sql.SQLData, java.io.Serializable
        * Implementation of method declared in the SQLData interface.  This method
        * is called by the JDBC driver when mapping the UDT, SCHEMA_NAME.Product_Type_Obj,
        * to this class.
        * The object being returned contains a slew of objects defined as tables,
        * these are retrieved as java.sql.Array objects.
         public void readSQL(SQLInput stream, String typeName) throws SQLException
            String[] value1 = (String[])stream.readArray().getArray();
            String[] value2 = (String[])stream.readArray().getArray();
         public void writeSQL(SQLOutput stream) throws SQLException
    }You'll also need to create Oracles Object. The specification for mine follows:
    TYPE Detail_Type IS TABLE OF VARCHAR2(1024);
    TYPE Product_Type_Obj AS OBJECT (
      value1  Detail_Type,
      value2 Detail_Type,
      value3 Detail_Type,
      value4 Detail_Type,
      value5 Detail_Type,
      value6 Detail_Type,
      value7 Detail_Type,
      value8 Detail_Type);Hope this helps,
    Zac

  • How to get the returned value from Functions with Callable statement?

    I was glad to find that stored procedures can be invoke with Java class code by the object of Callable statement like :
    String stmt = "BEGIN departments_pkg.do_select(?,?,?); END;";
    and getting the output variables by
    populateAttribute(DEPARTMENTNAME,st.getString(2),true,false);
    But i would like to get values returned from FUNCTION other than stored procedure, how can i achieve it? Thanks a lot!

    Here is  my code
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_1202.
      MODULE subscreen_find.
      CALL SUBSCREEN SUBSEARCH INCLUDING sy-cprog dynnr.
    PROCESS AFTER INPUT.
      MODULE USER_COMMAND_1202.
      CALL SUBSCREEN SUBSEARCH.
    MODULE subscreen_find.
      case sy-ucomm.
        when 'SELECTED'.             "fcode
          case 'ZSKILL_SEARCH'.     "data element
            when '01'.                       " value range
              dynnr = 0110.
            when '02'.
              dynnr = 0111.
          endcase.
      endcase.
    ENDMODULE.
    kindly tell me what is wrong
    Edited by: Raji Thomas on Feb 8, 2010 10:20 AM

  • Parameter name passed in Set Callable Statement

    Is it not possible to pass parameter name in the callable statement while using Oracle drivers for jk 1.4??
    Thanks!

    Is it not possible to pass parameter name in the callable statement while using Oracle drivers for jk 1.4??
    Thanks!

  • Problem in callable statement

    Hi All,
    I have a get the data from table using CALLABLE statement.The problem is that that column datatype is CHAR.Is there any statement in java for to set
    CallableStatement cstmt=null;
    cstmt.setChar() ----- is it correct?

    Sorry for mistyping, I meant:
    Oracle CHAR type is mapped to Java String.
    cstmt.setString() should do.

  • Please, Not getting result set from callable statement (Code posted)

    I am posting some simple code which should get a ResultSet from a CallableStatement object using the executeQuery() Method.
    It is returning "No RsultSet was produced"
    If I modify the code and simply output the CallableableStatement using its executeUpdate() then getString() methods it works fine. Anything obviously wrong with this bit of code? Thanks.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import db.util.query.*;
    import db.util.pool.*;
    public class oracle extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    Connection con = ConnectionFactory.getConnection();
    CallableStatement cs = null;
    ResultSet rs = null;
    int intID = 1;
    try{
    cs = con.prepareCall("{? = call test1(?)}");
    cs.registerOutParameter(1, java.sql.Types.VARCHAR);
    cs.setInt(2,intID);
    /*These lines work on their own
    *cs.executeUpdate();
    *out.println("Name is : " + cs.getString(1));
    //this code is what is not working...hmm
    rs = cs.executeQuery();
    while(rs.next()){
    out.println(rs.getString("name"));
    rs.close();
    cs.close();
    //the rest of this works too.
    ConnectionFactory.releaseConnection(con);
    catch(SQLException e){
    out.println(e.getMessage());
    Here's the stored procedure. I'm just trying to do a simple test to return multiple rows. The table has numberous records with the same id which is being passed to the function.
    create or replace function test1 ( strInputID IN testtable.id%type)
    return varchar2
    is
    strOutputName testtable.name%type;
    found_it EXCEPTION;
    begin
    select name into strOutputName from testtable
    where id = strInputID;
    raise found_it;
    exception
    when no_data_found
    then
    return null;
    when found_it
    then
    return strOutputName;
    end;

    I've posted the code...it's doing a select. I think the problem is that to return multiple rows I need to return a cursor. But I've run into problems with both the MS and Oracle Drivers.
    All I really want to do is to query a database using a callable statement(function in oracle) which will return multiple rows which I can process. I have been trying to do this in a servlet.
    I can do it successfully for one column from one row, but not multiple columns from mulitple rows.
    I've been searchging for some good examples and am trying different things but can't seem to get it to work.

  • How to pass Array of Java objects to Callable statement

    Hi ,
    I need to know how can I pass an array of objects to PL/SQL stored procedure using callable statement.
    So I am having and array list of some object say xyz which has two attributes string and double type.
    Now I need to pass this to a PL/SQL Procedure as IN parameter.
    Now I have gone through some documentation for the same and found that we can use ArrayDescriptor tp create array (java.sql.ARRAY).
    And we will use a record type from SQL to map this to our array of java objects.
    So my question is how this mapping of java object's two attribute will be done to the TYPE in SQL? can we also pass this array as a package Table?
    Please help
    Thanks

    I seem to remember that that is in one of Oracle's online sample programs.
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/index.html

  • How it works (Calling Stored Procedure in DB2 Through Callable statement)

    Can anyone Please tell me what exactly happens on calling ESP(External Stored Procedure) through Callable statement Database point of view and Callable point of view also.
    eg:
    CallableStatement cstmt = con.prepareCall(
    "{call getTestData(?, ?)}");
    cstmt .executeUpdate();
    where getTestData is Stored Procedure in DB2.
    Can anyone please guide me working on this scenario..
    Message was edited by:
    Nitin_Gupta

    Check this post out:
    http://forum.java.sun.com/thread.jspa?threadID=638768&messageID=3785982
    But I think you should be getting results right? What do you mean you want it in a format other than resultset?

  • Error executing a callable statement on a pooled connection

    Hi,
    I have an Oracle function that returns a number:
    create or replace function
    S2B_STOP_STAGE (DOC_ID number, ST_ID number)
    return number ...
    and the following Java code:
    Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:weblogic:pool:madrigalPool");
    String sql = "{? = call S2B_STOP_STAGE(401,1002)}";
    CallableStatement stmt = conn.prepareCall(sql);
    stmt.registerOutParameter(1, Types.INTEGER);
    stmt.execute(sql);
    res = stmt.getInt(1);
    When the execute(sql) statement is executed, a SQLException is thrown:
    java.sql.SQLException: ORA-01008: not all variables bound
    at weblogic.jdbc.pool.PreparedStatement.execute(PreparedStatement.java:121)
    Does anybody have an idea about what may be wrong? I am using Oracle
    8.1.6, the thin driver classes12-81620.zip, and WebLogic 6.0 sp2.
    Thanks,
    Vladimir

    I found out what was wrong. I should have used execute() instead of execute(sql)
    on the callable statement...
    Sorry for the problem.
    Vladimir
    "vladimir" <[email protected]> wrote:
    >
    Hi,
    I have an Oracle function that returns a number:
    create or replace function
    S2B_STOP_STAGE (DOC_ID number, ST_ID number)
    return number ...
    and the following Java code:
    Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:weblogic:pool:madrigalPool");
    String sql = "{? = call S2B_STOP_STAGE(401,1002)}";
    CallableStatement stmt = conn.prepareCall(sql);
    stmt.registerOutParameter(1, Types.INTEGER);
    stmt.execute(sql);
    res = stmt.getInt(1);
    When the execute(sql) statement is executed, a SQLException is thrown:
    java.sql.SQLException: ORA-01008: not all variables bound
    at weblogic.jdbc.pool.PreparedStatement.execute(PreparedStatement.java:121)
    Does anybody have an idea about what may be wrong? I am using Oracle
    8.1.6, the thin driver classes12-81620.zip, and WebLogic 6.0 sp2.
    Thanks,
    Vladimir

  • Statement closed when using callable statements with oracle xe

    hi all, i've got this problem with oracle express edition 10g. I am using also oc4j v10.1.2.0.2. When working with a normal oracle database it was working fine (i think the code was the same, it's some time since i last tried, but you can see the code is very simple).
    So i just create a callable statement like this:
    CallableStatement cs = con.prepareCall(sentencia.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE, ResultSet.HOLD_CURSORS_OVER_COMMIT);
    and then when trying to access the statement to register an out parameter like this
    cs.registerOutParameter(1, parámetros[0].getTipo());
    it gives this error:
    java.sql.SQLException: Statement was closed
    It's puzzling me because, as i said before, i think the same code was working ok with a normal oracle database.
    Any idea what can it be?
    cheers

    Ah okay, sorry I've re-read your post.
    I believe you need to create a clob object that encapsulates your xml file.
    I've never done this but I would image it involves creating a class that implements the clob interface and passing an instantiation of this class to the callablestatement.
    Let me know how you get on.

  • Callable Statement throws exception..pls help

    When I use Callable Statement calling my function which returns Y if person is employee or nothing if not I get this error..
    Procedure not createdORA-06550: line 1, column 22:
    PLS-00103: Encountered the symbol "CHCK_EMP_STATUS" when expecting one of
    the following:
    . ( * @ % & = - + ; < / > at in mod not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between is null is not || is dangling
    The symbol "." was substituted for "CHCK_EMP_STATUS" to continue.
    Here is my code..
    import java.sql.*;
    import java.io.*;
    public class FunctionTest
         public static void main(String args[])
              Connection conn = null;
              CallableStatement stmt = null;
              ResultSet rs=null;
         try
         Class.forName("oracle.jdbc.driver.OracleDriver");
         conn = DriverManager.getConnection("........");
         stmt = conn.prepareCall("{call function chck_emp_status(?,?)}");
              stmt.setString(1,"137897");
              stmt.registerOutParameter(2,Types.VARCHAR);
              stmt.execute();
              String s = stmt.getString(1);
              stmt.close();
              conn.commit();
              conn.close();
              }//try
              catch(Exception e)
         System.out.println("Procedure not created"+e.getMessage());
              finally
         }//main
    Please help...

    This is the function
    CREATE OR REPLACE function chck_emp_status (id number) return varchar2
    as
    emp_id          number;
    results          varchar(2);
    cursor emp_status is
         select id
         from emp
         where emp_status = 'A'
    and emp_id = id;
    begin
         open emp_status;
         fetch emp_status into emp_id;
         if emp_id%notfound THEN
              results := '';
         else
              results := 'Y';
         end if;
         close emp_id;
         return results;
    end;

  • What may be the cause of this error java.sql.SQLException: invalid sql type passed to callable statement in iplanet ussing JNDI

     

    Hi,
    The possibilities can be of various reasons, with the sql statements,
    xml descriptors, data sources, improper drivers anything. To crack down
    the solution, kindly let me know the error messages and what exactly are
    you trying to accomplish.
    Thanks & Regards
    Raj
    manimaran t wrote:
    what may be the cause of this error java.sql.SQLException: invalid sql
    type passed to callable statement in iplanet ussing JNDI
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • Callable statement problem-very urgent

    Hi Friends,
    i have 2 tables, in that two tables one column have same attribute column. when i update the first table through OAF page, i wanted to effect updated value in second table of that common field also. i wrote PL/SQL Procedure and called that into OAF by using callable statements. here first time i updated in the page, updated value is effecting into the first table while second table not effected the updated value. again i am trying to update the page this time in second table effected with first time updation value,while first table updated correctly. suppose i updated again in the page this time in second table effected with second time updation value, while first table updated correctly.this process continuing...
    example – I want to update forecast(this field is in two tables) value filed. Now forecast value is 10 in both tables , I updated as 20. this 20 updated value effected first table while second table forecast field is not effected.
    Again I am going to update value 30 in the place of 20. this 30 updated value effected first table while second table forecast field is 20(firstupdated value) effected.
    Again I am going to update value 40 in the place of 30. this 40 updated value effected first table while second table forecast field is 30(secondupdated value) effected this process continuing...
    Can any one help me out this problem
    This is I have written in AM-
    public void Callable()
    String forecast="";
    String name="";
    String product="";
    String business="";
    XXProgsVOImpl vo = getXXProgsVO1();
    RowSetIterator rowsetiterator=vo.getRowSetIterator();
    rowsetiterator.reset();
    while(rowsetiterator.hasNext())
    Row row = rowsetiterator.next();
    forecast=row.getAttribute("Forcast").toString();
    name=row.getAttribute("Name").toString();
    product=row.getAttribute("Product").toString();
    business=row.getAttribute("Business").toString();
    String s="BEGIN do_update(?,?,?,?);End;";
    OADBTransaction dbtrans=getOADBTransaction();
    OracleCallableStatement cs=(OracleCallableStatement)dbtrans.createCallableStatement(s,4);
    try
    cs.setString(1, forecast);
    cs.setString(2, name);
    cs.setString(3, product);
    cs.setString(4, business);
    cs.execute();
    dbtrans.commit();
    cs.close();
    catch(SQLException e)
    System.out.println(e.getMessage());
    Thanks and Regards,
    vamshi

    Hi Sumit and Thiago,
    Thanks for your information, my Both VO's are coming from EO'S. but first VO I have done some calculation on columns, that calulated value parameter passing to second page. this calculated value is the database column in second table. here when i update the calculated value in updated page , i want to effect this in second page table.
    do you have any work around this..
    Thanks and Regards,
    vamshi

  • Callable Statement Syntax

    I am using the callable statement to invoke a MS SQL Server stored procedure that will return a result set. I have several questions:
    1) According to the Java documentation I should be using the following format for a prepareCall that will return a result paramater with 4 input paramaters:
    { ? = call SP_ABC(?, ?, ?, ?)}
    In my particular case the stored procedure will return 14 pieces of data in a result set. Do I need to write code for 14 registerOutParameter fields? Is the syntax mentioned above accurate for the 14 pieces of data or do I need to repeat the question marks (?) 14 times? What shoud the syntax be for my prepareCall statement?

    The ? in the sql syntax refer to variables passed to the procedure as either in or in/out parameters. You need to write code to register any OUT variables (including any return value).
    The data returned from the SP will be returned as a ResultSet which is processed in the normal way.
    So assuming that you have a procedure declared as:
    create proc p @1 int, @2 int OUTPUT as ...then your code would look like this:
    statement = connection.prepareCall("{?=call p (?,?}");
    // register the return code
    statement.registerOutParameter(1,Types.INTEGER);
    // register the OUTPUT var @2
    statement.registerOutParameter(3,Types.INTEGER);
    // Set the input param @1
    statement.setInt(2,0);
    rs = statement.executeQuery();
    // Get the return code
    int rc = statement.getInt(1);
    // Get the output param @2
    int out = statement.getInt(3);
    // process the result set
    while(rs.next()) {...}Dave

Maybe you are looking for

  • Cannot install windows 7 (downgrade from Windows 8.1 on Lenovo U330 Touch)

    Hello. I wanted to downgrade my new Lenovo U330 Touch from Windows 8.1 to Windows 7 (x64 Home Premium). I followed the instructions from this previous forum post... https://forums.lenovo.com/t5/IdeaPad-Y-U-V-Z-and-P-series/U330-Touch-Downgrading-to-W

  • SUS invoice "check payment" status

    Hi We are implementing MM-SUS scenario with SRM7.0 and ECC6 EhP 4 back end. When we process invoice from SUS its fairly replicated and posted in ERP and payment is made against the invoice in ERP. Now wehn I click on "Check payment status" button in

  • Not able to export files in any format from PP 5.5 new installation.

    Hi all. Hoping someone can help. I just recentlyinstalled a full licensed education version of CS5.5. I was previously running a trial version. I have been trying to export a project, yet everytime I try and export, it crashes at around 2%. I have tr

  • OBIA 10g on 64bit OS

    I want to install following component on windows 2008 64 bit.Are there versions are compatible with 64bit OS?      Oracle BI applications 7.9.6.2      OBIEE 10.1.3.4.1      Informatica 8.6.1      DAC 10.1.3.4.1

  • Is VMWare Fusion 2.0.5 compatible with Snow Leopard?

    Anyone knows if VMWare Fusion 2.0.5 is compatible with Snow Leopard?