Naming the parameters of a callable statement

Hi!
I am having some kind of a problem here. I am currently working on a software with a database.OK, simple.
The problem is that we have different kind of databases (oracle, Sybase, DB2) AND different schema!
We are obviously trying to keep the persistence layer as cut from the rest as possible.
The problem is that in some cases, we may call a callable statement but the actual callable statement in the database is not the same as the one that would be called in a similar case with another schema.
Therefore, we are looking for a way to set the parameters of a callable statement by a name, not an index.
Instead of
setString(1,"aValue");
some
setString("FirstParameter", "aValue");
PLease help!
Cheers!
Chris

I think there is a driver that does that.Thanks for replying so quickly, could you tell me what
that driver would be ?Like I said I don't think it is going to help because it is for a specific data base. I you need to support more than one.
I think it is either Oracle (if you use the Oracle specific JDBC classes - cast to them) or one of the third party drivers.
>
I was thinking of the wrapper too but I, as the
(different)schemas are still changing and the callable
statement too, I think it will be very error prone
during the developpement cycle.
So I'd like to avoid to have to maintain a
"correspondance table" between each callable statement
and it's parameters...
And that is my idea. Developement cycles are always error prone so I am not sure that it matters.

Similar Messages

  • Help with Callable Statements

    Hi,
    I am working on a problem which requires me to insert record into the database (mySQL) using Callable Statements.
    For this I have written 2 Stored Procedures (SP) which are as follows:
    CREATE DEFINER=`root`@`localhost` PROCEDURE `GeneratePcId`()
    BEGIN
    select max(pc_id)+1 from price;
    END $$
    CREATE DEFINER=`root`@`localhost` PROCEDURE `InsertPrice`(pc_id INT, pc_level INT, price INT, from_date DATE, to_date DATE)
    BEGIN
    INSERT INTO price VALUES (pc_id, pc_level, price, from_date, to_date);
    END $$
    The frist SP returns a number that adds 1 to the max of pc_id column which is the PK and max means the last row value.
    This value I want to use as a value for inserting the new row into the table. I have worked on this and the program chunk is here:
               // Create CallableStatement object 
                CallableStatement genid = conn.prepareCall("{? = call GeneratePcId()}");
                genid.registerOutParameter(1, Types.INTEGER);
                //ResultSet rs = (ResultSet)genid.executeQuery();
                //rs.next();
                genid.executeUpdate();
                int number = genid.getInt(1);
                CallableStatement cstmt = conn.prepareCall("{call InsertPrice (?, ?, ?, ?, ?)}");     
                // Bind values to the parameters           
                cstmt.setInt(1, number );           
                cstmt.setInt(2, 8);           
                cstmt.setInt(3, 600);           
                cstmt.setDate(4, Date.valueOf("2008-01-01"));           
                cstmt.setDate(5, Date.valueOf("2008-02-02"));       But when I run this program I get the following error:
    java.lang.NullPointerException at com.mysql.jdbc.CallableStatement$CallableStatementParamInfo.iterator(CallableStatement.java:324)
    at com.mysql.jdbc.CallableStatement.setInOutParamsOnServer(CallableStatement.java:1938)
    at com.mysql.jdbc.CallableStatement.execute(CallableStatement.java:749)
    at com.mysql.jdbc.CallableStatement.executeUpdate(CallableStatement.java:808)
    at CallableStatementExercise.query(CallableStatementExercise.java:36)
    at CallableStatementExercise.main(CallableStatementExercise.java:13)
    Line 13 points to genid.executeUpdate();
    Can anybody please advise me what the problem is?
    Shall be really grateful.
    Templar_Knight
    Message was edited by:
    templar_knight

    mervin,
    Find the following sample code regarding your issue,
    CallableStatement cstmt = (java.sql.Connection).prepareCall("{call getTestData(?)}");
                   cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
                   cstmt.registerOutParameter(2, java.sql.Types.DECIMAL);
                   ResultSet rs = cstmt.executeQuery();
    //. . . retrieve result set values with rs.getter methods
                   java.lang.Integer x = cstmt.getInt(1);
                   java.math.BigDecimal n = cstmt.getBigDecimal(2);
    I think your issue is resolved.

  • 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

  • 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

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

  • SSIS The parameterized sql statement yields metadata which does not match the main SQL statement

    Hi all,
    I'm getting the above error when trying to execute a custom lookup.  What I'm trying to do is lookup the minimum promotional price between date ranges.  The SQL executes fine in SSMS
    SELECT refTable.PRICE
    FROM ( SELECT MIN(PRICE) AS PRICE ,
    NAME ,
    ITEMRELATION ,
    FROMDATE ,
    TODATE
    FROM [dbo].[AllCustPrices]
    GROUP BY NAME ,
    ITEMRELATION ,
    FROMDATE ,
    TODATE
    ) [refTable]
    WHERE [refTable].[NAME] = ?
    AND [refTable].[ITEMRELATION] = ?
    AND ? BETWEEN [refTable].[FROMDATE]
    AND [refTable].[TODATE]
    but errors in SSIS?

    Apologies, totally forgot i posted a question on here.  I still haven't resolved this.  full error text is TITLE: Package Validation Error
    Package Validation Error
    ADDITIONAL INFORMATION:
    Error at Data Flow Task [Lookup MIN Price [440]]: The parameterized SQL statement yields metadata which does not match the main SQL statement.
    Error at Data Flow Task [SSIS.Pipeline]: "Lookup MIN Price" failed validation and returned validation status "VS_ISBROKEN".
    Error at Data Flow Task [SSIS.Pipeline]: One or more component failed validation.
    Error at Data Flow Task: There were errors during task validation.
     (Microsoft.DataTransformationServices.VsIntegration)
    BUTTONS:
    OK
    If I take off the MIN function and just put * SSIS is quite happy, it does not like MIN for some reason?
    I'm really stumped with this... checked metadata for third parameter which is W/C Date DT_DBTIMESTAMP which is same as FROMDATE, TODATE where i'm using BETWEEN...

  • 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

  • Callable Statement Exception

    Hi,
    I am very new to Java SQL Callable Statement.
    The following is the program that i wrote to execute a Stored Procedure stored in MS SQL Server 2000.
    In my program I am actually retrieving back the value that I've passed to the MS SQL Server.
    ========================================
    import java.sql.*;
    import java.sql.Types;
    public class CallableTester
         private Connection connection;
         public CallableTester(Connection conn)
              connection = conn;
         public void executeInsert ()
         CallableStatement stmt = null;
         String sqlstmt;
         int rows;
         try {
              sqlstmt = "{ ? = call product(?, ?, ?, ?) }";
              stmt = connection.prepareCall(sqlstmt);
              stmt.setString(1, "61");
              stmt.setString(2, "62");
              stmt.setString(3, "63");
              stmt.setString(4, "67");
              stmt.registerOutParameter(1, Types.VARCHAR);
              stmt.executeUpdate();
              connection.commit();
              System.out.println("The value inserted are " + stmt.getString(1));
              stmt.close();
              System.out.println(sqlstmt);
         catch (Exception e){
              e.printStackTrace();
    =========================================
    The is no syntax error.
    When I run the program, I've got the following exception
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect
    or syntax error
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:2567)
    at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedState
    ment.java:217)
    at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(JdbcOdbcPrepare
    dStatement.java:139)
    at CallableTester.executeInsert(CallableTester.java:38)
    at DatabaseConnection.makeConnection(DatabaseConnection.java:22)
    at Start.main(Start.java:16)
    =========================================
    My database has a table named Product with the following fields and properties.
    Field id of type varchar
    Field name of type varchar
    Field costPrice of type decimal
    Field sellPrice of type decimal.
    =========================================
    The stored procedure for this table is
    CREATE PROCEDURE product @id varchar(8) = 8, @name varchar(50) = "productName", @costprice decimal = 88, @sellprice decimal =168 AS
    INSERT INTO PRODUCT VALUES(@id, @name, @costprice, @sellprice, @desc)
    GO
    =========================================
    Can anyone please to help me? I have been trying to solve this problem few days but I really can't.
    Your help will be appreciated.
    Thank you very much.

    I've reproduced your code with some modifications to make it work, I've tested it against a Sybase DB which is close enough to MS SQL Server.
    First the procedure. Note that I create and write to a temp table you can ignore this.
    create proc dmjtest
      @id varchar(8) = '8',
      @name varchar(50) = 'Dave Jenkins',
      @costPrice decimal = 1.23,
      @sellPrice decimal = 4.56
    as
    begin
      declare @rc int
      select @rc = 0
      create table #t (
        id varchar(8),
        name varchar(50),
        costPrice decimal,
        sellPrice decimal
      insert #t values (@id, @name, @costPrice, @sellPrice)
      if @@error = 0 select @rc = 1
      drop table #t
      return @rc
    endNow for the java code
    import java.sql.*;
    import java.sql.Types;
    public class CallableTester
      private Connection connection;
      public CallableTester(Connection conn) {
        connection = conn;
      public void executeInsert () {
        CallableStatement stmt = null;
        String sqlstmt;
        int rows;
        try {
          stmt = connection.prepareCall("{ ? = call dmjtest(?, ?, ?, ?) }");
          stmt.registerOutParameter(1, Types.INTEGER);
          stmt.setString(2, "1");
          stmt.setString(3, "product 1");
          stmt.setDouble(4, 63.0);
          stmt.setDouble(5, 67.0);
          stmt.executeUpdate();
          connection.commit();
          System.out.println("The return value is " + stmt.getInt(1));
          stmt.close();
        catch (Exception e){
          e.printStackTrace();
    }

  • Callable statement doubt-urgent

    hi all,i got a problem in callable statements.i know how to pass parameters to a procedure using a callable statement.but this time i need to pass a table name as a parameter.the problem is if i get that variable as a IN parameter in the procedure then how do you put that parameter in place of table name inside the procedure.heres a example,the pocedure is in oracle
    i am passing variable a from java
    create or replace procedure (a in varchar2)
    begin
    select * from <the parameter passed through a> where <condition>
    end;
    how can this be done.the select statement is given only as a example.the errors in the select are not emphasized here.the focus is on the table name.if there is any other way to do this do let me know.please reply fast.this is urgent.any kind of help is welcome.bye thiyagu.

    In some databases the SQL used in your stored procedure can reference 'variables' that contain the values to be used at statement execution time. This will be covered in your database's SQL reference. If this is not supported by your database you will have to perform a 'switch' based on the table name passed and select the SQL statement to be executed.

  • Memory leak in Callable Statement

    We are using Weblogic 6.1 and Oracle 8.1.7 for an application we are developing.
    Usage of callable statement seems to be resulting an a memory leak. The program runs
    in a loop and after processing 200 records, java.lang.outofMemory Exception is thrown
    We are unable to figure out a reason for the same.
    The code snippet is as below
    try
    //dbConn = ImportPODBConnect.getDBConnection(dsJNDIName, dsURL); //connect
    to DB <br>
    dbConn = DBConnect.getDBConnection(dsJNDIName, dsURL);
    //query = POQueries.selectPO(poId); //get the required
    query statement from the POQueries utility class
                             Print.log(" in getPO() ----> ********* before 1st stmt " + System.currentTimeMillis());
                        cstmt = dbConn.prepareCall("{ ? = call PO_HEADER_PROC(?)}");
                        cstmt.registerOutParameter(1, OracleTypes.CURSOR);
                   cstmt.setFloat(2, poId);
                   // execute and retrieve the result set
                   cstmt.execute();
                   getPORs = (ResultSet)cstmt.getObject(1);
                             Print.log(" in getPO() ----> ********* after 1st stmt " + System.currentTimeMillis());
                             if (!getPORs.next()) //if nothing returned then
    throw an exception
                                  Print.log("Unable to get the required PO:" + poId);
                                  throw new Exception("Unable to get the required PO:" + poId);
                             else //set all the variables
    of the PO header objects from the result set
                                  pohSl = new POHeaderSl();
                                  pohSl.setOvUserName(getPORs.getString("OVA_USER_NAME"));
                                  pohSl.setOvCompanyName(getPORs.getString("OVA_COMPANY_NAME"));
                                  pohSl.setAgent(getPORs.getString("AGENT"));
                                  pohSl.setApprovalCode(getPORs.getString("APPROVAL_CODE"));
                                  pohSl.setBrand(getPORs.getString("BRAND"));
                                  pohSl.setBusinessSegment(getPORs.getString("BUSINESS_SEGMENT"));
                                  pohSl.setBusinessSubSegment(getPORs.getString("BUSINESS_SUB_SEGMENT"));
                                  pohSl.setBuyDate(getPORs.getString("BUY_DATE"));
                                  pohSl.setCareContentLabel(getPORs.getString("CARE_CONTENT_LABEL"));
                                  pohSl.setCartonMarkings1(getPORs.getString("CARTON_MARKINGS_1"));
                                  pohSl.setCartonMarkings2(getPORs.getString("CARTON_MARKINGS_2"));
                                  pohSl.setCartonMarkings3(getPORs.getString("CARTON_MARKINGS_3"));
                                  pohSl.setCartonMarkings4(getPORs.getString("CARTON_MARKINGS_4"));
                                  pohSl.setComments(getPORs.getString("COMMENTS"));
                                  pohSl.setCommissionPerUnit(getPORs.getString("COMMISSION_PER_UNIT"));
                                  pohSl.setCompanyId(getPORs.getString("COMPANY_ID"));
                                  pohSl.setCompulsoryString(getPORs.getString("COMPULSORY_STRING"));
                                  pohSl.setConTimestamp(getPORs.getString("CON_TIMESTAMP"));
                                  pohSl.setCurrency(getPORs.getString("CURRENCY"));
                                  pohSl.setCustomerBillToNumber(getPORs.getString("CUSTOMER_BILL_TO_NUMBER"));
                                  pohSl.setCustomerLcBank(getPORs.getString("CUSTOMER_LC_BANK"));;
                                  pohSl.setCustomerLcDate(getPORs.getString("CUSTOMER_LC_DATE"));
                                  pohSl.setCustomerLcExpiryDate(getPORs.getString("CUSTOMER_LC_EXPIRY_DATE"));
                                  pohSl.setCustomerLcNumber(getPORs.getString("CUSTOMER_LC_NUMBER"));
                                  pohSl.setCustomerPoNumber(getPORs.getString("CUSTOMER_PO_NUMBER"));
                                  pohSl.setCustomerSaleDept(getPORs.getString("CUSTOMER_SALE_DEPT"));
                                  pohSl.setCustomerShipToNumber(getPORs.getString("CUSTOMER_SHIP_TO_NUMBER"));
                                  pohSl.setCustomerSo(getPORs.getString("CUSTOMER_SO"));
                                  pohSl.setDateLastModifiedErp(getPORs.getString("DATE_LAST_MODIFIED_ERP"));
                                  pohSl.setDateLastModifiedOv(getPORs.getString("DATE_LAST_MODIFIED_OV"));
                                  pohSl.setDateOfActivation(getPORs.getString("DATE_OF_ACTIVATION"));
                                  Print.log(" ******** inside getPO() ----- > ****** built Header" + System.currentTimeMillis()
                                  if(getPORs != null)
                                       getPORs.close();
                                       getPORs = null;
                                  if(cstmt != null)
                                       Print.log("In the close");
                                       cstmt.close();
                                       cstmt = null;
                        catch (Exception e)
                             System.out.println(" in dataAccess.getPO() ----- > " + e.toString());
                             throw new Exception(e.toString()); //if there are any exceptions
    then throw back the exceptions
                        finally //finally block to release any connections
    and statement objects
                             if(getPORs != null)
                                  getPORs.close();
                                  getPORs = null;
                             if (pstmt!=null)
                                  pstmt.close();
                                  pstmt = null;
                             if (cstmt!=null)
                                  cstmt.close();
                                  cstmt = null;
                             if (dbConn!=null)
                                  dbConn.close();
                                  dbConn = null;
                        return poSl; //return the PO object
    Can anyone help with this?

    hi
    This may happen when you open resultset objects and not close them properly.
    Try to ensure that, you should close the objects in individual try catch
    blocks so that one failure will not cause other close's to be skipped.
    You can try one more thing, I don't see you are using any LONG/ LONG
    RAW/BLOB/CLOB columns from your code here. If the table which you are trying
    to retrieve data from has this type of data you will benefit from using some
    tuning parameters here and may be able to avoid out of memory exceptions,
    take a look at the url,
    http://e-docs.bea.com/wls/docs61/oracle/advanced.html#1158561
    especially, try using,
    weblobic.oci.selectBlobChunkSize and set it to something low. you can set
    these properties on the connection pool.
    sree
    "Murali" <[email protected]> wrote in message
    news:[email protected]...
    >
    >
    We are using Weblogic 6.1 and Oracle 8.1.7 for an application we aredeveloping.
    Usage of callable statement seems to be resulting an a memory leak. Theprogram runs
    in a loop and after processing 200 records, java.lang.outofMemoryException is thrown
    >
    We are unable to figure out a reason for the same.
    The code snippet is as below
    try
    //dbConn = ImportPODBConnect.getDBConnection(dsJNDIName, dsURL);//connect
    to DB <br>
    dbConn = DBConnect.getDBConnection(dsJNDIName, dsURL);
    //query = POQueries.selectPO(poId); //getthe required
    query statement from the POQueries utility class
    Print.log(" in getPO() ----> ********* before 1st stmt " +System.currentTimeMillis());
    >
    cstmt = dbConn.prepareCall("{ ? = call PO_HEADER_PROC(?)}");
    cstmt.registerOutParameter(1, OracleTypes.CURSOR);
    cstmt.setFloat(2, poId);
    // execute and retrieve the result set
    cstmt.execute();
    getPORs = (ResultSet)cstmt.getObject(1);
    Print.log(" in getPO() ----> ********* after 1st stmt " +System.currentTimeMillis());
    >
    if (!getPORs.next()) //if nothing returnedthen
    throw an exception
    Print.log("Unable to get the required PO:" + poId);
    throw new Exception("Unable to get the required PO:" + poId);
    else //set all thevariables
    of the PO header objects from the result set
    pohSl = new POHeaderSl();
    pohSl.setOvUserName(getPORs.getString("OVA_USER_NAME"));
    pohSl.setOvCompanyName(getPORs.getString("OVA_COMPANY_NAME"));
    pohSl.setAgent(getPORs.getString("AGENT"));
    pohSl.setApprovalCode(getPORs.getString("APPROVAL_CODE"));
    pohSl.setBrand(getPORs.getString("BRAND"));
    pohSl.setBusinessSegment(getPORs.getString("BUSINESS_SEGMENT"));
    pohSl.setBusinessSubSegment(getPORs.getString("BUSINESS_SUB_SEGMENT"));
    pohSl.setBuyDate(getPORs.getString("BUY_DATE"));
    pohSl.setCareContentLabel(getPORs.getString("CARE_CONTENT_LABEL"));
    pohSl.setCartonMarkings1(getPORs.getString("CARTON_MARKINGS_1"));
    pohSl.setCartonMarkings2(getPORs.getString("CARTON_MARKINGS_2"));
    pohSl.setCartonMarkings3(getPORs.getString("CARTON_MARKINGS_3"));
    pohSl.setCartonMarkings4(getPORs.getString("CARTON_MARKINGS_4"));
    pohSl.setComments(getPORs.getString("COMMENTS"));
    pohSl.setCommissionPerUnit(getPORs.getString("COMMISSION_PER_UNIT"));
    pohSl.setCompanyId(getPORs.getString("COMPANY_ID"));
    pohSl.setCompulsoryString(getPORs.getString("COMPULSORY_STRING"));
    pohSl.setConTimestamp(getPORs.getString("CON_TIMESTAMP"));
    pohSl.setCurrency(getPORs.getString("CURRENCY"));
    pohSl.setCustomerBillToNumber(getPORs.getString("CUSTOMER_BILL_TO_NUMBER"));
    pohSl.setCustomerLcBank(getPORs.getString("CUSTOMER_LC_BANK"));;
    pohSl.setCustomerLcDate(getPORs.getString("CUSTOMER_LC_DATE"));
    pohSl.setCustomerLcExpiryDate(getPORs.getString("CUSTOMER_LC_EXPIRY_DATE"));
    pohSl.setCustomerLcNumber(getPORs.getString("CUSTOMER_LC_NUMBER"));
    pohSl.setCustomerPoNumber(getPORs.getString("CUSTOMER_PO_NUMBER"));
    pohSl.setCustomerSaleDept(getPORs.getString("CUSTOMER_SALE_DEPT"));
    pohSl.setCustomerShipToNumber(getPORs.getString("CUSTOMER_SHIP_TO_NUMBER"));
    pohSl.setCustomerSo(getPORs.getString("CUSTOMER_SO"));
    pohSl.setDateLastModifiedErp(getPORs.getString("DATE_LAST_MODIFIED_ERP"));
    pohSl.setDateLastModifiedOv(getPORs.getString("DATE_LAST_MODIFIED_OV"));
    pohSl.setDateOfActivation(getPORs.getString("DATE_OF_ACTIVATION"));
    Print.log(" ******** inside getPO() ----- > ****** built Header" +System.currentTimeMillis()
    if(getPORs != null)
    getPORs.close();
    getPORs = null;
    if(cstmt != null)
    Print.log("In the close");
    cstmt.close();
    cstmt = null;
    catch (Exception e)
    System.out.println(" in dataAccess.getPO() ----- > " + e.toString());
    throw new Exception(e.toString()); //if there are anyexceptions
    then throw back the exceptions
    finally //finally block to release anyconnections
    and statement objects
    if(getPORs != null)
    getPORs.close();
    getPORs = null;
    if (pstmt!=null)
    pstmt.close();
    pstmt = null;
    if (cstmt!=null)
    cstmt.close();
    cstmt = null;
    if (dbConn!=null)
    dbConn.close();
    dbConn = null;
    return poSl; //return the PO object
    Can anyone help with this?

  • How to use Callable statements.

    Hi.
    I'm just new in using JSP. I just want to ask how to call stored procedures (ex. from SQL Server) using the Callable statements. A sample code will be very helpful......
    Ex. I have these parameters for my stored proc:
    name = "sentiments"; //value will always vary
    add = "NJ"; //value will always vary
    stored proc name is => usp_updateFile
    Thank you very much for your time.

    See http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html#JDBC2013_4

  • Regarding callable statement

    Hi all,
    I have a stored procedure which executes in sql query analyzer in 2 seconds.
    It executes without any error. after execution of the stored procedure i get near about 4000 records.
    Now i am trying to call the stored procedure using the callable statement.
    It hangs on the line :
    callablestatement.prepareCall("{call myproc}");at this lines nothing happens, nor i get any kind of exception. but my page just hangs. and nothing happens.

    Hi
    Do u write callablestatement.prepareCall or sqlConnection.prepareCall ();
    Have a look at the syntax for this at the following link.
    http://java.sun.com/j2se/1.3/docs/api/java/sql/CallableStatement.html
    Further you need to register any out parameters using registerOutParameter ()
    and use
    callablestmt.execute () to execute your stored proc.
    HTH, Do revert back.
    VJ

  • Calling a procedure/function in CO using Callable Statement

    Hi,
    Please help me in understanding this:
    __method1__
    BEGIN
    :1 := Package.Function(
    param1 => :2"
    ,param2 => :3"
    ,param3 => :4"
    ,param4 => :5"
    END;
    method2
    BEGIN
    Package.Function(:1, :2, :3, :4, :5);"
    END;
    Whats the significance of using method1?
    I have seen the callable statements written as in method1 but, the parameters passed are not in order and not all params are passed.
    When i tried writing similar code, I got "Invalid Column Index" exception. Please let me know how to overcome this.
    Thanks

    Hi,
    You can call a function using Callable Statement as
    public String checkprimarycontact(String pri_loc_id,String org_id,String party_id)
    int p_location_id = 0;
    int p_org_id = 0;
    int p_party_id = 0;
    p_location_id = Integer.parseInt(pri_loc_id);
    p_org_id = Integer.parseInt(org_id);
    p_party_id = Integer.parseInt(party_id);
    String priflag = "";
    try
    Connection conn1 = getOADBTransaction().getJdbcConnection();
    CallableStatement cstmt1 = conn1.prepareCall("{? = call GET_PRIMARY_FUNCTION(?,?,?)}");
    cstmt1.registerOutParameter(1,Types.VARCHAR);
    cstmt1.setInt(2,p_location_id);
    cstmt1.setInt(3,p_org_id);
    cstmt1.setInt(4,p_party_id);
    cstmt1.execute();
    priflag = cstmt1.getString(1);
    catch(Exception e1)
    e1.printStackTrace();
    return priflag;
    Thanks,
    Gaurav

  • 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

  • What are the parameters in Call transaction method?

    Hi ABAPER'S,
        Please give me what are the parameters in call transaction method?
    Thanks,
    Prakash

    Processing batch input data with CALL TRANSACTION USING is the faster of the two recommended data transfer methods. In this method, legacy data is processed inline in your data transfer program.
    Syntax:
    CALL TRANSACTION <tcode>
    USING <bdc_tab>
    MODE  <mode>
    UPDATE  <update>
    <tcode> : Transaction code
    <bdc_tab> : Internal table of structure BDCDATA.
    <mode> : Display mode:
    A
    Display all
    E
    Display errors only
    N
    No display
    <update> : Update mode:
    S
    Synchronous
    A
    Asynchronous
    L
    Local update
    A program that uses CALL TRANSACTION USING to process legacy data should execute the following steps:
    Prepare a BDCDATA structure for the transaction that you wish to run.
    With a CALL TRANSACTION USING statement, call the transaction and prepare the BDCDATA structure. For example:
    CALL TRANSACTION 'TFCA' USING BDCDATA
    MODE 'A'
    UPDATE 'S'.
    MESSAGES INTO MESSTAB.
    IF SY-SUBRC <> 0.
    <Error_handling>.
    ENDIF.
    The MODE Parameter
    You can use the MODE parameter to specify whether data transfer processing should be displayed as it happens. You can choose between three modes:
    A Display all. All screens and the data that goes in them appear when you run your program.
    N No display. All screens are processed invisibly, regardless of whether there are errors or not. Control returns to your program as soon as transaction processing is finished.
    E Display errors only. The transaction goes into display mode as soon as an error in one of the screens is detected. You can then correct the error.
    The display modes are the same as those that are available for processing batch input sessions.
    The UPDATE Parameter
    You use the UPDATE parameter to specify how updates produced by a transaction should be processed. You can select between these modes:
    A Asynchronous updating. In this mode, the called transaction does not wait for any updates it produces to be completed. It simply passes the updates to the SAP update service. Asynchronous processing therefore usually results in faster execution of your data transfer program.
    Asynchronous processing is NOT recommended for processing any larger amount of data. This is because the called transaction receives no completion message from the update module in asynchronous updating. The calling data transfer program, in turn, cannot determine whether a called transaction ended with a successful update of the database or not.
    If you use asynchronous updating, then you will need to use the update management facility (Transaction SM12) to check whether updates have been terminated abnormally during session processing. Error analysis and recovery is less convenient than with synchronous updating.
    S Synchronous updating. In this mode, the called transaction waits for any updates that it produces to be completed. Execution is slower than with asynchronous updating because called transactions wait for updating to be completed. However, the called transaction is able to return any update error message that occurs to your program. It is much easier for you to analyze and recover from errors.
    L Local updating. If you update data locally, the update of the database will not be processed in a separate process, but in the process of the calling program. (See the ABAP keyword documentation on SET UPDATE TASK LOCAL for more information.)
    The MESSAGES Parameter
    The MESSAGES specification indicates that all system messages issued during a CALL TRANSACTION USING are written into the internal table <MESSTAB> . The internal table must have the structure BDCMSGCOLL .
    You can record the messages issued by Transaction TFCA in table MESSTAB with the following coding:
    (This example uses a flight connection that does not exist to trigger an error in the transaction.)
    DATA: BEGIN OF BDCDATA OCCURS 100.
    INCLUDE STRUCTURE BDCDATA.
    DATA: END OF BDCDATA.
    DATA: BEGIN OF MESSTAB OCCURS 10.
    INCLUDE STRUCTURE BDCMSGCOLL.
    DATA: END OF MESSTAB.
    BDCDATA-PROGRAM = 'SAPMTFCA'.
    BDCDATA-DYNPRO = '0100'.
    BDCDATA-DYNBEGIN = 'X'.
    APPEND BDCDATA.
    CLEAR BDCDATA.
    BDCDATA-FNAM = 'SFLIGHT-CARRID'.
    BDCDATA-FVAL = 'XX'.
    APPEND BDCDATA.
    BDCDATA-FNAM = 'SFLIGHT-CONNID'.
    BDCDATA-FVAL = '0400'.
    APPEND BDCDATA.
    CALL TRANSACTION 'TFCA' USING BDCDATA MODE 'N'
    MESSAGES INTO MESSTAB.
    LOOP AT MESSTAB.
    WRITE: / MESSTAB-TCODE,
    MESSTAB-DYNAME,
    MESSTAB-DYNUMB,
    MESSTAB-MSGTYP,
    MESSTAB-MSGSPRA,
    MESSTAB-MSGID,
    MESSTAB-MSGNR.
    ENDLOOP.
    The following figures show the return codes from CALL TRANSACTION USING and the system fields that contain message information from the called transaction. As the return code chart shows, return codes above 1000 are reserved for data transfer. If you use the MESSAGES INTO <table> option, then you do not need to query the system fields shown below; their contents are automatically written into the message table. You can loop over the message table to write out any messages that were entered into it.
    Return codes:
    Value
    Explanation
    0
    Successful
    <=1000
    Error in dialog program
    > 1000
    Batch input error
    System fields:
    Name:
    Explanation:
    SY-MSGID
    Message-ID
    SY-MSGTY
    Message type (E,I,W,S,A,X)
    SY-MSGNO
    Message number
    SY-MSGV1
    Message variable 1
    SY-MSGV2
    Message variable 2
    SY-MSGV3
    Message variable 3
    SY-MSGV4
    Message variable 4
    Error Analysis and Restart Capability
    Unlike batch input methods using sessions, CALL TRANSACTION USING processing does not provide any special handling for incorrect transactions. There is no restart capability for transactions that contain errors or produce update failures.
    You can handle incorrect transactions by using update mode S (synchronous updating) and checking the return code from CALL TRANSACTION USING. If the return code is anything other than 0, then you should do the following:
    write out or save the message table
    use the BDCDATA table that you generated for the CALL TRANSACTION USING to generate a batch input session for the faulty transaction. You can then analyze the faulty transaction and correct the error using the tools provided in the batch input management facility.

Maybe you are looking for

  • GL account linkage with activity group for AVC- Funds management

    Hi, I have activated (BCS) funds management in my system. My client wants that system will give error message for some expense GL accounts and for other expense GL accounts it will only give information message. For that i have created new activity g

  • Error in Jdeveloper using WebCenter Framework

    Hi All, I am creating a sample application using webcenter framework in Jdeveloper. As i have installed the extensions of webcenter from HELP->Check For Updates -> webcenter extension. It was working fine but when i am trying to create the connection

  • Projector Recommendations for Keynote

    I would like to get some recommendations from those of you who frequently use Keynote with a projector. I would like to get some help with what projector to purchase. I conduct small group presentations (fewer than 50 people) in typically-sized hotel

  • How to change the order of target message? kindly help

    Hi Experts,           I have a source message with fields EmpNo, EmpName, Dept and joining date. The target message has the same structure but fields are in different order. That is, EmpName, Dept, EmpNo and joiningdate. How to achive the target mess

  • XML OPP manager Tunning

    Hi, 11.5.10.2 apps--->9.2.0.6 db--->5.6.3 xml publisher version Am new to this concept...a new client am working for... am assigned to check why sometimes reports are failing of XML publisher. and i am to dont know much abt XML publisher....and its p