Best place in VOimpl java code to call a stored proc to populate results

Hello all,
Using JDev 11g, ADF BC and Trinidad.
I am building an application that is primarily used for searching large amounts of data. We already have stored procedures on the database that perform the searches and dump the results into a holding table (together with a "search id"). I have easilly built a prototype of this application: my view object is simply "select a, b, c from results where search_id = :bv" - I have a service method in the AM that runs the stored procedure, obtains the search ID, binds it to the :bv in the VO and executes the VO's query - it's all working really nicely. Range paging is effective, the VO itself performs well, and I am able to control how long the stored proc runs via setting a timeout value.
Now, I'd like to generalize this. My thinking is this:
1). I'll add a custom property to my VO that is the SQL statement needed to call the stored procedure.
2). I'll add some bind variables to the VO to represent all the query parameters that can be passed to the stored proc. I'll also use custom properties to indicate these are "fake" bvs, and not in the SQL query itself.
3). The VO's SQL will remain simply "select a, b, c from results where search_id = :bv"
4). I will (have already tested) override bindParametersForCollection so that the "fake" bind variables aren't bound into the SQL.
Now, the question: I want to override some method in the VO's java code to call the stored procedure. The stored proc needs to be called before the actual query for the VO is run, and also before the method getQueryHitCount is called (so that the count is correct). What is the method that would be the "best" place to do this? My current thinking is that I would put the call in an over-ridden executeQueryForCollection call. As far as my analysis has gone, it seems to be always called before getQueryHitCount, but I have no way of knowing if this is completely safe.
Any thoughts from the BC experts out there?
Best regards,
John

John,
from your description I understand that you essentially program the VO yourself. So I suggest that you read chapter 35.9 of the 'Fusion Developer’s Guide for Oracle Application Development Framework' (I guess you know where to find it). Since you still call the actual SQL not all of the chapter apply, but you get the idea how it works.
And yes you analyzed the behavior correct. executeQueryForCollection() is allways called bevore getQueryHitCount().
Timo

Similar Messages

  • S'one tell me how to call Oracle Stored Proc from Java

    Hi,
    I have a problem in calling the Stored proc using callable statement.It looks like we are doing the same thing or no..
    Pl..let me know if you can correct me..Am enclosing the stored proc and java Code...
    CREATE OR REPLACE PROCEDURE StoreFTPAddress (FTP in FTPTYPE) is
    BEGIN
    INSERT INTO DES.FTPSERVICE(
    FTPID,
    COMPANYID,
    SERVERNAME,
    DIRECTORY,
    USERNAME,
    PASSWORD,
    INSTRUCTIONS)
    VALUES( FTPID.NEXTVAL,
    FTP.COMPANYID,
    FTP.SERVERNAME,
    FTP.DIRECTORY,
    FTP.USERNAME,
    FTP.PASSWORD,
    FTP.INSTRUCTIONS);
    END;
    JAVA CODE :;
    public String retrieveFormatExtension(String formatName)
    OracleResultSet rs_form = null;
    try
    conn = ConnectionDataObjectImpl.getConnection();
    Statement stmt = conn.createStatement();
    String sql_retrieve = "{call retrieveFormatExtension} " ;
    CallableStatement cst = conn.prepareCall(
    "{call retrieveFormatExtension(?,?)}");
    cst.setString(1," FName ");
    cst.registerOutParameter(1, OracleTypes.VARCHAR); // OUT Parameter
    cst.executeQuery();
    rs_form = (OracleResultSet) cst.getObject(1);
    cst.close();
    catch (SQLException ex)
    System.out.println("SQLException : " + ex.getMessage());
    return null;
    Regards
    Deepauk
    [email protected]
    null

    Syntactically it looks fine. Only thing is u r calling the proc with wrong name. Your procedure takes only one parameter and i.e
    IN type. I think u need to correct ur preparecall statement.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Ayappa:
    Hi,
    I have a problem in calling the Stored proc using callable statement.It looks like we are doing the same thing or no..
    Pl..let me know if you can correct me..Am enclosing the stored proc and java Code...
    CREATE OR REPLACE PROCEDURE StoreFTPAddress (FTP in FTPTYPE) is
    BEGIN
    INSERT INTO DES.FTPSERVICE(
    FTPID,
    COMPANYID,
    SERVERNAME,
    DIRECTORY,
    USERNAME,
    PASSWORD,
    INSTRUCTIONS)
    VALUES( FTPID.NEXTVAL,
    FTP.COMPANYID,
    FTP.SERVERNAME,
    FTP.DIRECTORY,
    FTP.USERNAME,
    FTP.PASSWORD,
    FTP.INSTRUCTIONS);
    END;
    JAVA CODE :;
    public String retrieveFormatExtension(String formatName)
    OracleResultSet rs_form = null;
    try
    conn = ConnectionDataObjectImpl.getConnection();
    Statement stmt = conn.createStatement();
    String sql_retrieve = "{call retrieveFormatExtension} " ;
    CallableStatement cst = conn.prepareCall(
    "{call retrieveFormatExtension(?,?)}");
    cst.setString(1," FName ");
    cst.registerOutParameter(1, OracleTypes.VARCHAR); // OUT Parameter
    cst.executeQuery();
    rs_form = (OracleResultSet) cst.getObject(1);
    cst.close();
    catch (SQLException ex)
    System.out.println("SQLException : " + ex.getMessage());
    return null;
    Regards
    Deepauk
    [email protected]
    <HR></BLOCKQUOTE>
    null

  • Java code for calling xslt mapping in module?

    Hi,
    We have 2 mapping(xslt) in IR
    source->cannonical and cannonical->target
    we want to remove source->cannonical mapping and want to put that in MODULE of communication channel.
    My problem is how to call xslt mapping using java code and we done value mapping their. Did that vallumapping will work in module..
    waiting for responce..its an urgent task..
    thanq
    krishna

    You can use the MessageTransformBean to run the XSLT in the adapter framework:
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3823 [original link is broken] [original link is broken] [original link is broken]
    I do not know, if the value mapping works here. Maybe you just give a try.
    Regards
    Stefan

  • Using Java to call COBOL stored proc on DB2 database

    I would appreciate any information you would have on calling a COBOL stored procedure from a Java Servlet. The COBOL stored procedure resides on a DB2 database on our mainframe. I have never had to invoke a stored procedure in my code, especially COBOL, so I need all the help I can get. The servlet will call the stored procedure and then based on the stored procedure's return code I will either display a confirmation screen or an error screen. Please help!
    Thanks in advance.

    I'm trying to call a stored procedure on a DB2 database from a Java Servlet. This is my code:
    try{
    cstmt = con.prepareCall("{CALL MKTDS80A
    cstmt.setShort(1, shFiscalYr);
    cstmt.setInt(2, iInvoiceNbr);
    cstmt.setString(3, sInvoiceTypeCd);
    cstmt.setInt(4, iUserNbr);
    cstmt.setString(5, sFormId);
    cstmt.setString(6, sSubSysCd);
    cstmt.setShort(7, shModNbr);
    cstmt.registerOutParameter(8, Types.INTEGER);
    cstmt.registerOutParameter(9, Types.INTEGER);
    cstmt.registerOutParameter(10, Types.CHAR);
    cstmt.registerOutParameter(11, Types.INTEGER);
    cstmt.registerOutParameter(12, Types.CHAR);
    cstmt.execute();
    iParm1 = cstmt.getInt(8);
    iParm2 = cstmt.getInt(9);
    sParm3 = cstmt.getString(10);
    iParm4 = cstmt.getInt(11);
    sParm5 = cstmt.getString(12);
    if (iParm1 == 0){ bReturnZero = true;
    CloseSQLStatement(cstmt);
    catch (SQLException ex) {
    CloseSQLStatement(cstmt);
    bReturnZero = false;
    System.out.println("SQL exception occurred: "
    + ex.toString());
    return iParm1;
    It seems to fail on the execute and I get the following SQL Exception message:
    SQL exception occurred in callStoredProcedure method:
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0440N
    No function by the name "MKTDS22B" having compatible arguments was
    found in the function path. SQLSTATE=42884
    Can anyone tell me what the problem might be? I've checked the parameter datatypes and everything matches up. Does anyone have a clue?
    Thanks in advance!

  • Read item from Java class and call to stored function/procedure of database

    Hi,
    I am looking solution that I was trying to find becasue of I am not expert and novice of ADF so I am getting problem to do. I am trying migrating from oracle forms to JDeveloper[ADF].
    I want to call database stored function from JSF pages by java bean class of a button press event (manually created) and after button event I have called java class which I created manually. But I can not read that values what I given into jsp page.
    question1: How can I read jsp pages items value to java class ?
    question2: How can I call to database stored function/procedure with that parameter?
    question3: How can I use return value of that stored function/procedure ?
    Please reply me .
    Thanks,
    zakir
    ===
    Edited by: Zakir Hossain on Mar 29, 2009 10:22 AM

    ---

  • JCA DB Adaptor to call a Stored Proc that updates a table

    Dear guru,
    I've a created JCA Db adaptor that will be used by OSB 10.3.1 that ultimately will call a stored procedure to update a table. However, I encountered exception :
    ORA-02089 COMMIT is not allowed in a subordinate session
    CREATE or REPLACE PROCEDURE EXAMPLEA
    StringA IN VARCHAR2,
    AS
    BEGIN
    UPDATE TABLE_A
    SET COLUMN_1 = 'testing'
    WHERE STRINGA_COLUMN = StringA ;
    COMMIT;
    END;
    If I removed the commit above, then I got another error :-
    JCA-11811
    Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the EXAMPLE_A. Cause: java.sql.SQLException: Unexpected exception while enlisting XAConnection java.sql.SQLException: Transaction rolled back: Transaction timed out after 31 seconds
    Desperate help is needed. Thanks!

    The stored procedure adapter service will execute within a JTA transaction that will be committed so you must not explicitly execute a commit as part of your procedure code. When setting up a connection-instance in weblogic-ra.xml, you must provide one of either xADataSourceName or dataSourceName, but not both. If you use xADataSourceName then make sure that the JTA XA Connection check box is checked when you create your database connection and specify a JNDI name. Uncheck the box if you use dataSourceName.

  • Runtime exception java.lang.ClassNotFoundException on executing Stored Proc

    I am getting the below error when I try to execute a stored proc in Pointbase from weblogic.
    java.sql.SQLException: The external "DbLog::insLog" routine had the following runtime exception "java.lang.ClassNotFoundException: DbLog"
    import java.sql.*; import com.pointbase.jdbc.*; public class DbLog { static Connection conn = null; static Statement m_stmt; static Statement l_stmt; static CallableStatement m_callStmt = null; public boolean logPreAuth() { try { String I_URL = "jdbc:pointbase:server://localhost:9093/weblogic_eval"; conn = DriverManager.getConnection(I_URL, "PBSYSADMIN", "PBSYSADMIN"); /*String SQL_CREATE_PROC = "CREATE PROCEDURE insLog(IN P1 VARCHAR(30))" + " LANGUAGE JAVA" + " SPECIFIC insLog" + " DETERMINISTIC" + " NO SQL" + " EXTERNAL NAME \"DbLog::insLog\"" + " PARAMETER STYLE SQL"; m_stmt = conn.createStatement(); m_stmt.executeUpdate(SQL_CREATE_PROC); m_stmt.close(); */ Commented out because it throwed error saying, The routine "INSLOG" in schema "PBPUBLIC" already exists in system table SYSROUTINES. m_callStmt = conn.prepareCall("{ call insLog(?) }"); m_callStmt.setString(1, "Success!!"); m_callStmt.execute(); } catch (Exception e) { logger.error("Error in logPreAuth method" + e); } return true; } public static void insLog(String test) { try { l_stmt = conn.createStatement(); l_stmt.executeUpdate("Insert into logs values('" + test + "')"); l_stmt.close(); conn.close(); } catch (Exception e) { } }
    Please let me know how to solve this.

    I setted the classpath in commEnv.cmd as follows,
    set POINTBASE_HOME=%WL_HOME%\common\eval\pointbase
    set POINTBASE_CLIENT_CLASSPATH=%POINTBASE_HOME%\lib\pbclient57.jar
    set POINTBASE_CLASSPATH=%POINTBASE_HOME%\lib\pbembedded57.jar;%POINTBASE_CLIENT_CLASSPATH%;C:\bea\user_projects\workspaces\work1\utility\build\classes
    set POINTBASE_TOOLS=%POINTBASE_HOME%\lib\pbtools57.jar
    My DbLog class in the path, C:\bea\user_projects\workspaces\Work1\util\build\classes\net\local\util\common
    FYI, net\local\util\common is the package.
    But when I try to execute the page which calls RequestFilter.java, I am getting the following error,
    Error 500--Internal Server Error
    java.lang.NoClassDefFoundError: Could not initialize class net.local.util.common.DbLog
    Please find the code below,
    --RequestFilter.java
    import net.local.util.common.DbLog;  
    public final class RequestFilter {  
    public void log() {  
    DbLog dblog = new DbLog();  
    dblog.logPreAuth();  
    }  --DbLog.java
    package net.local.util.common;  
    import java.sql.*;  
    import org.apache.log4j.Logger;  
    import com.pointbase.jdbc.*;  
    public class DbLog {  
        private static final Logger logger = Logger.getLogger(DbLog.class);  
        private static boolean DEBUGGING = logger.isDebugEnabled();  
        private Connection conn = null;  
        private Statement m_stmt;  
        private Statement l_stmt;  
        private CallableStatement m_callStmt = null;  
        //static ResultSet l_rs = null;  
    public DbLog() {  
        logger.info("DbLog constructor called");  
        init();  
    public void init() {  
        logger.info("DbLog init called");  
    public void logPreAuth() {  
            try {  
                logger.info("Inside logPreAuth method");  
                String I_URL = "jdbc:pointbase:server://localhost:9093/weblogic_eval";  
                Class.forName("com.pointbase.jdbc.jdbcUniversalDriver").newInstance();  
                //Class.forName("com.pointbase.jdbc.jdbcDataSource");  
                conn = DriverManager.getConnection(I_URL, "PBPUBLIC", "PBPUBLIC");  
            String SQL_CREATE_PROC = "CREATE PROCEDURE insLog(IN P1 VARCHAR(30))" 
                    + " LANGUAGE JAVA" 
                    + " SPECIFIC insLog" 
                    + " DETERMINISTIC" 
                    + " NO SQL" 
                    + " EXTERNAL NAME \"DbLog::insLog\"" 
                    + " PARAMETER STYLE SQL";   
                m_stmt = conn.createStatement();  
                m_stmt.executeUpdate(SQL_CREATE_PROC);  
                m_stmt.close();    
                m_callStmt = conn.prepareCall("{ call PBPUBLIC.insLog(?) }");  
                m_callStmt.setString(1, "Success!!");  
                m_callStmt.execute();   
            catch (Exception e) {  
                logger.error("Error in logPreAuth method" + e);  
    public void insLog(String test)  
        try {  
            l_stmt = conn.createStatement();  
            l_stmt.execute("Insert into logs values('" + test + "')");  
            l_stmt.close();  
            conn.close();  
        catch (Exception e) {  

  • Calling a stored proc in a decode statement

    I am having a problem calling a store procedure in a SQL statement. I am using Oracle's thin driver.
    I have been able to do the following:
    select col1,
    col2,
    SOME_STORED_PROC(var1,var2,col3)
    from some_table
    where col3 = var3
    However, when I try to call a stored procedure with-in a decode statement, the call fails. I have tested the call from a sql prompt and it works fine but it does not work when I execute the query in my Java program.
    Here is an example of what I am trying to do:
    select col1,
    col2,
    decode((select col1
    from some_other_table
    where col2 = var1), 'X',
    SOME_STORED_PROC(var1,var2,col3),
    SOME_OTHER_STORED_PROC(var2,var4,col5))
    from some_table
    where col3 = var3
    Does anyone know if this type of call is not supported in Oracle's thin driver?
    Thanks,
    Cory
    null

    I played around with a [parallel PL/SQL launcher|http://www.williamrobertson.net/feed/2008/08/parallel-plsql-launcher-update.html] a while ago, but I wouldn't call it production-ready.
    You could also [submit procedure calls in background|http://www.williamrobertson.net/feed/2005/12/job-control-object.html] using DBMS_ALERT to track completion status.

  • How to call a stored proc

    Hi,
    I want to call a stored procedure which returns 4 VARCHAR as a output
    parameter, and use 2 VARCHAR as a input parameter. How can I do
    that ?
    the signature of the SP is like this
    dec(
    in_a IN VARCHAR2,
    in_b IN VARCHAR2,
    out_c OUT VARCHAR2,
    out_d OUT VARCHAR2,
    out_e OUT VARCHAR2,
    out_f OUT VARCHAR2,
    Thank You
    PS: sorry if there's a repost, my mail server seems to have some problems..

    CallableStatement cstmt = con.prepareCall( "{call storedProcName(?,
    cstmt.registerOutParameter(1, java.sql.Types.VARCHAR);
    cstmt.registerOutParameter(2, java.sql.Types.VARCHAR);
    cstmt.registerOutParameter(3, java.sql.Types.VARCHAR);
    cstmt.registerOutParameter(4, java.sql.Types.VARCHAR);
    cstmt.registerInParameter(5, java.sql.Types.VARCHAR);
    cstmt.registerInParameter(6, java.sql.Types.VARCHAR);
    cstmt.executeQuery();
    -Krishna
    "Fabien" <[email protected]> wrote in message
    news:[email protected]..
    Hi,
    I want to call a stored procedure which returns 4 VARCHAR as a output
    parameter, and use 2 VARCHAR as a input parameter. How can I do
    that ?
    the signature of the SP is like this
    dec(
    in_a IN VARCHAR2,
    in_b IN VARCHAR2,
    out_c OUT VARCHAR2,
    out_d OUT VARCHAR2,
    out_e OUT VARCHAR2,
    out_f OUT VARCHAR2,
    Thank You
    PS: sorry if there's a repost, my mail server seems to have someproblems..
    >
    >

  • Calling DB2 Stored Proc from Oracle DB

    Hi,
    I am having two different database running (One is oracle on solaris while the other one is db2 on os/390 mainframe) i want to pass the data realtime. Is there any way I can call a DB2 stored procedure from oracle directly. If anyboy can help in this will be really helpful.
    thanks,
    Kishor

    odi version we have is  ODI_11.1.1.6.0, it is not migrated and 'Always Execute' option is checked already.
    tried using variables in capital format but did not worked,
    begin
    schema_name.proc_name(#LV_TABLE_NAME,#LV_SCHEMA_NAME,#LV_START_DATE,#LV_END_DATE);
    end;
    odi is giving error if it finds any bug in stored proc but after fixing its completing successfully without errors in operator but i am not able to see the result.
    Please advise.

  • Calling a Stored Procedure with a result set and returned parms

    I am calling a stored procedure from a Brio report. The stored procedure returns a result set, but also passes back some parameters. I am getting a message that states that the DBMS cannot find the SP with the same footprint. Besides the result set, the SP returns 3 out parameters: (Integer, char(60), char(40)). Is there something special I need to do in Brio to format the out parameters to be passed back from the SP.
    Thanks,
    Roland

    Did you try just declaring the vars?
    untested
    declare
      myCur SYS_REFCURSOR;
      myRaw RAW(4);
      BEGIN
        test (0, 0, myRaw, sysdate, myCur);
      END;

  • Calling Oracle Stored proc with record type and table Type

    I have a oracle SP which takes record type and table Type which are used for order management.
    Is there anay way to populate parameters with these datatypes and call the stored procedure using ODP.NET?
    Please help.
    Thanks in advance

    Hi,
    ODP supports associative arrays and REF Cursors. There is no support for PLSQL table of records.
    Jenny

  • Trying to call a stored proc from a form ?

    Hi im trying to call a stored procedure that create a web page
    any where from within a form. (the SP It uses the htp package).
    It does not seem to work.
    lets say in the PL/SQL block before the footer i pu
    <schema>.my_procedure;
    i get a not decleared <schema>.my_procedure error.
    Could someone help !
    Also is there a way to call stored proc directly from the url
    I tried httP://hostname/pls/portal30/<schema>.my_procedure
    unsuccessful.
    thanks

    For it to work, you should grant EXECUTE on your Procedure to
    PUBLIC.
    Have you done that?
    If yes then there is a problem.

  • Calling a storeed proc from jap

    How do we call a stored procedure from a jsp?

    And to do the call (either from the JSP, which I also don't recommend, or from somewhere else) use CallableStatement. Read the API documentation for more information on how to use it.
    Alin.

  • Java code to call methods in .ocx file

    dear friends,
    i have an .ocx file with me which is used to communicate with a specific device.it is an already existing one. i wish to know whether i can call method sin that .ocx file using java .using vb6 we can do this.
    if it is possible with java i wish to know how i can do this.please consider this query and please send me your responses. i know that using jni we can communicate with .dll files.but i am not sure about .ocx file. please help me.
    thank you
    arun

    i wish to know whether i can call method sin that .ocx file using java
    Probably
    db

Maybe you are looking for

  • Macbook Pro Hard Drives Failing

    Hi all, I've been having massing problems with my Macbook Pro 15" 2.53 Ghz laptop. I got one brand new with apple care in December of 2008. The hard drive was the standard 320 Gb @ 5400 RPM. Within approximately two weeks of operation the computer fa

  • How to print PDF files directly from SAP?

    We have created output that is being saved in a PDF format. We can store it on any drive or send it through email. However, we would like to be able to print a PDF file directIy without any manual intervention. Now users still have to open the file a

  • Scroll bar and alternate row color in Trinidad table

    I am using Jdeveloper 11g I have two question on tinidad table see below sample code *1)How to set scroll bar on table* *2)how to set different colors for alternate rows* <tr:form> <tr:panelGroupLayout> <tr:panelFormLayout inlineStyle="width:965px; h

  • How to put checkbox into classical report header row?

    Hi, I have a classical report that has a check item as a first column. I would like to put a check box item into the header row too, When checked it is supposed to set the check box item in all report rows. Something like in APEX Shared components /

  • Problem with my USB drive

    My MacbookPro (mid 2010) is not recognising any USBs that I'm inserting into it. I'm not sure what/ how it happened, but is there some way I can restart my MBP to the previous session when there weren't any issues with it? If that isn't the way to do