Setting ViewObject Stored Procedure Where Clause Param from Struts Action

I adapted/used Steve's example to get stored procedure to populate my ViewObject. However, I could not retrieve any rows after passing whereClause value from Struts action. The param in execureQueryForCollection returns null.
What could be wrong. Thanks.
Here's my code.
ViewObjectImpl:
package org.adb.sls.model;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import oracle.jbo.JboException;
import oracle.jbo.domain.Date;
import oracle.jbo.domain.Number;
import oracle.jbo.server.DBTransaction;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.server.ViewRowImpl;
import oracle.jbo.server.ViewRowSetImpl;
import oracle.jdbc.driver.OracleCallableStatement;
import oracle.jdbc.driver.OracleTypes;
// --- File generated by Oracle ADF Business Components Design Time.
// --- Custom code may be added to this class.
public class ViewApplicableLoanTypesImpl extends ViewObjectImpl
* PLSQL block that will execute the REF_CURSOR
private static final String SQL =
"begin ? := sls_loan_types_pkg.get_applcbl_staff_lns_fn(?); end;";
* PLSQL block that will count the REF_CURSOR returned rows
private static final String COUNTSQL =
"begin ? := sls_loan_types_pkg.get_count_applcbl_staff_lns_fn(?); end;";
* This is the default constructor (do not remove)
public ViewApplicableLoanTypesImpl()
* Overridden framework method.
* Wipe out all traces of a built-in query for this VO
protected void create() {
getViewDef().setQuery(null);
getViewDef().setSelectClause(null);
setQuery(null);
* Overidden framework method
protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams)
// input parameter is employee number
String employeeNumber = null;
if (params != null) {
employeeNumber = (String) params[0];
} else
System.out.println("param is null");
storeNewResultSet(qc,retrieveRefCursor(qc,employeeNumber));
super.executeQueryForCollection(qc, params, noUserParams);
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs)
* We ignore the JDBC ResultSet passed by the framework (null anyway) and
* use the resultset that we've stored in the query-collection-private
* user data storage
rs = getResultSet(qc);
* Create a new row to populate
ViewRowImpl r = createNewRowForCollection(qc);
try {
* Populate new row by attribute slot number for current row in Result Set
populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
populateAttributeForRow(r,1, nullOrNewNumber(rs.getBigDecimal(2)));
populateAttributeForRow(r,2, rs.getString(3));
populateAttributeForRow(r,3, nullOrNewNumber(rs.getBigDecimal(4)));
populateAttributeForRow(r,4, rs.getString(5));
catch (SQLException s) {
throw new JboException(s);
return r;
protected boolean hasNextForCollection(Object qc)
ResultSet rs = getResultSet(qc);
boolean nextOne = false;
try {
nextOne = rs.next();
* When were at the end of the result set, mark the query collection
* as "FetchComplete".
if (!nextOne) {
setFetchCompleteForCollection(qc, true);
* Close the result set, we're done with it
rs.close();
catch (SQLException s) {
throw new JboException(s);
return nextOne;
protected void releaseUserDataForCollection(Object qc, Object rs)
* Ignore the ResultSet passed in since we've created our own.
* Fetch the ResultSet from the User-Data context instead
ResultSet userDataRS = getResultSet(qc);
if (userDataRS != null) {
try {
userDataRS.close();
catch (SQLException s) {
/* Ignore */
super.releaseUserDataForCollection(qc, rs);
public long getQueryHitCount(ViewRowSetImpl viewRowSet)
Object[] params = viewRowSet.getParameters(true);
String id = (String)params[0];
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(COUNTSQL,DBTransaction.DEFAULT);
* Register the first bind parameter as our return value of type CURSOR
st.registerOutParameter(1,Types.NUMERIC);
* Set the value of the 2nd bind variable to pass id as argument
if (id == null) st.setNull(2,Types.VARCHAR);
else st.setString(2,id);
st.execute();
return st.getLong(1);
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Return a JDBC ResultSet representing the REF CURSOR return
* value from our stored package function.
private ResultSet retrieveRefCursor(Object qc,String id) {
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
* Register the first bind parameter as our return value of type CURSOR
st.registerOutParameter(1,OracleTypes.CURSOR);
* Set the value of the 2nd bind variable to pass id as argument
if (id == null) st.setNull(2,Types.VARCHAR);
else st.setString(2,id);
st.execute();
ResultSet rs = ((OracleCallableStatement)st).getCursor(1);
* Make this result set use the fetch size from our View Object settings
rs.setFetchSize(getFetchSize());
return rs ;
catch (SQLException s) {
s.printStackTrace();
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Store a new result set in the query-collection-private user-data context
private void storeNewResultSet(Object qc, ResultSet rs) {
ResultSet existingRs = getResultSet(qc);
// If this query collection is getting reused, close out any previous rowset
if (existingRs != null) {
try {existingRs.close();} catch (SQLException s) {}
setUserDataForCollection(qc,rs);
hasNextForCollection(qc); // Prime the pump with the first row.
* Retrieve the result set wrapper from the query-collection user-data
private ResultSet getResultSet(Object qc) {
return (ResultSet)getUserDataForCollection(qc);
* Return either null or a new oracle.jbo.domain.Date
private static Date nullOrNewDate(Timestamp t) {
return t != null ? new Date(t) : null;
* Return either null or a new oracle.jbo.domain.Number
private static Number nullOrNewNumber(BigDecimal b) {
try {
return b != null ? new Number(b) : null;
catch (SQLException s) { }
return null;
Struts Action
package org.adb.sls.view;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import oracle.jbo.ApplicationModule;
import oracle.jbo.ViewObject;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import oracle.adf.model.binding.DCDataControl;
import oracle.adf.model.bc4j.DCJboDataControl;
import oracle.jbo.html.BC4JContext;
public class IndexAction extends DefaultADFAction
protected ActionForward performActionLogic(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws Exception {
try {    
ApplicationModule am = getApplicationModule("SLSApplicableLoanTypesDataControl", request);
if (am == null)
System.out.println("am is null");
ViewObject vo = am.findViewObject("ViewApplicableLoanTypes");
vo.setWhereClauseParam(0,request.getSession().getAttribute("SSO_EMPLOYEE_NUMBER"));
vo.executeQuery();
} catch (Exception e)
e.printStackTrace();
return mapping.findForward("success");
Struts Config
<form-beans>
<form-bean name="DataForm" type="oracle.adf.controller.struts.forms.BindingContainerActionForm"/>
</form-beans>
<action-mappings>
<action path="/index" className="oracle.adf.controller.struts.actions.DataActionMapping" type="org.adb.sls.view.IndexAction" name="DataForm" unknown="false">
<set-property property="modelReference" value="indexUIModel"/>
<forward name="success" path="/home.do"/>
</action>
<action path="/home" className="oracle.adf.controller.struts.actions.DataActionMapping" type="oracle.adf.controller.struts.actions.DataForwardAction" name="DataForm" parameter="/index.uix" unknown="true">
<set-property property="modelReference" value="indexUIModel"/>
</action>
</action-mappings>

I just found the solution. I've overridden setWhereClause method.
public void setWhereClauseParams(Object[] values)
ViewObjectImpl vo = (ViewObjectImpl) super.getViewObject();
vo.setWhereClauseParam(0,values[0]);
}

Similar Messages

  • How to pass LOV Where clause params from Page CO

    Dear Members,
    I have an OAF Page for which I defined a CO.
    I also have an LOV for which I have two parameters in where clause.
    Now my requirement is to pass the two values to the where clause parameters of LOV from the CO of the respective page.
    Can any one please guide me in achieving this requirement.
    Best Regards,
    Arun Reddy

    Hi Arun
    as gyan, suggested try attching a new controller to lov , or extend its existing controller.
    In the page CO
    store the parameter that needs to be passed to lov in pageContext.putSessionValue(paramName,paramValue)
    In the CO of Lov page , in processrequest
    retrive the stored values using pageContext.getSessionValue(paramName)
    Regards
    Ravi

  • Calling Oracle stored procedure with out param of user define type from Entity Framework 5 with code first

    Guys i am using Entity Framework 5 code first (I am not using edmx) with Oracle and all works good, Now i am trying to get data from stored procedure which is under package but stored procedure have out param which is user define type, Now my question is
    how i will call stored procedure from entity framework
    Thanks in advance.

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • Can I create a Stored Procedure That access data from tables of another servers?

    I'm developing a procedure and within it I'm trying to access another server and make a select into a table that belongs to this another server. When I compile this procedure I have this error message: " PLS-00904: insufficient privilege to access object BC.CADPAP", where BC.CADPAP is the problematic table.
    How can I use more than one connection into an Oracle Stored Procedure?
    How I can access tables of a server from a Stored Procedure since the moment I'm already connected with another server?
    Can I create a Stored Procedure That access data from tables of another servers?

    You need to have a Database Link between two servers. Then you could do execute that statement without any problem. Try to create a database link with the help of
    CREATE DATABASE LINK command. Refer Document for further details

  • Calling a Stored Procedure with output parameters from Query Templates

    This is same problem which Shalaka Khandekar logged earlier. This new thread gives the complete description about our problem. Please go through this problem and suggest us a feasible solution.
    We encountered a problem while calling a stored procedure from MII Query Template as follows-
    1. Stored Procedure is defined in a package. Procedure takes the below inputs and outputs.
    a) Input1 - CLOB
    b) Input2 - CLOB
    c) Input3 - CLOB
    d) Output1 - CLOB
    e) Output2 - CLOB
    f) Output3 - Varchar2
    2. There are two ways to get the output back.
    a) Using a Stored Procedure by declaring necessary OUT parameters.
    b) Using a Function which returns a single value.
    3. Consider we are using method 2-a. To call a Stored Procedure with OUT parameters from the Query Template we need to declare variables of
    corresponding types and pass them to the Stored Procedure along with the necessary input parameters.
    4. This method is not a solution to get output because we cannot declare variables of some type(CLOB, Varchar2) in Query Template.
    5. Even though we are successful (step 4) in declaring the OUT variables in Query Template and passed it successfully to the procedure, but our procedure contains outputs which are of type CLOB. It means we are going to get data which is more than VARCHAR2 length which query template cannot return(Limit is 32767
    characters)
    6. So the method 2-a is ruled out.
    7. Now consider method 2-b. Function returns only one value, but we have 3 different OUT values. Assume that we have appended them using a separator. This value is going to be more than 32767 characters which is again a problem with the query template(refer to point 5). So option 2-b is also ruled out.
    Apart from above mentioned methods there is a work around. It is to create a temporary table in the database with above 3 OUT parameters along with a session specific column. We insert the output which we got from the procedure to the temporary table and use it further. As soon the usage of the data is completed we delete the current session specific data. So indirectly we call the table as a Session Table. This solution increases unnecessary load on the database.
    Thanks in Advance.
    Rajesh

    Rajesh,
    please check if this following proposal could serve you.
    Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
    Here is an example how this could be defined.
    Package:
    type return_cur IS ref CURSOR;
    Procedure:
    PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
    OPEN myReturnCur FOR SELECT val1, val2, val3  FROM dual;
    Query:
    DECLARE
      MYRETURNCUR myPackage.return_cur;
    BEGIN
      myPackage.myProc(
        MYRETURNCUR => ?
    END;
    Good luck.
    Michael

  • Dynamically set ViewObject where clause dynamically from Java bean

    I have a requirement to display all of the records from a table when the JSP is first brought up, so my View Object looks like this:
    "select emp_name from emp"
    Then the users wants to ability to pass paramters to that View Object to refine the list so from by Java class I tried to do this:
    ViewObject vo = cpd.findViewObject("EmpViewObject");
    vo.setWhereClause("empName = :1");
    vo.setWhereClauseParam(1,varEmpName);
    vo.executeQuery();
    But I am getting JBO errors and I'm not sure what I'm doing wrong. Can anyone offer a hint as to how I can do this?

    this is exactly how the code is done -
    1. emp_name in the View Object
    2. emp_name in the where clause
    The two are identical. I have tried many variations of this - any time I set the where clause from my bean I get an error.
    When I take the SQL stmnt and run it in TOAD it returns expected rows when I run it in the SQL worksheet in JDev it gives an invalid Identifier - but if I hard code the where clause in the View Object it returns the same results as TOAD.

  • Not able to set the where clause params

    Hi,
    My version of apps is 12.1.3.
    I created a page with a searchRN and resultRN (LinesVO). (Not a query/view link) . I am passing the id from header to the VO to restrict the linesVO
    The controller correctly passes the id from searchRN to AM, but in AM, the where clause is not set and I am not getting the desired result:
    My AM Code:
        public void InvokeGo(String Hdrval)
                    LineVOImpl LineVO1 = getLineVO1();
                    LineVO1.setWhereClauseParams(null); // Always reset
                     System.out.println("AMIMPL:Hdrval = "+ Hdrval);
                    <prints the header_Value which is passed from CO>
                       if (Hdrval           == null        
                                            System.out.println("Inside Null If");  
                                            String message = "Please provide atleast one input to any of these search field";
                                            throw new OAException(message, OAException.ERROR);
                                    else   
                                        System.out.println("Not All Parameters are Null.Building Where Clause");
                                         < prints the line above>
                                        LineVO1.setWhereClause
                                        ("Header_name = :1");
                        System.out.println("Paremeter Set are: Header_name:"+Hdrval);
                        <prints the above line like :   Paremeter Set are: Header_name:Hdr_Name_1
                        LineVO1.setWhereClauseParam(0,Hdrval);
                        System.out.println("Inside MainAM invokeGO Method:"+LineVO1.getQuery());
                        < prints:Inside MainAM invokeGO Method:SELECT * FROM (select LINE_ID,hdr.HEADER_ID,LINE_NUMBER,LINE_NAME,Attach,hdr.header_name from xxtr_hdr hdr, xxtr_line line
    where hdr.header_id=line.header_id) QRSLT  WHERE (Header_name = :1)>
                        LineVO1.executeQuery();
    The issue is in the SQL build. I guess after setting the where clause, it should appear like :
    QRSLT  WHERE (Header_name = "Hdr_Name_1"
    Thanks

    Hu Sumit,
    I am doing that:
    LineVO1.setWhereClauseParam(0,Hdrval);
    before executequery. I even hard coded
    LineVO1.setWhereClauseParam(0,"XXXX");
    but still it din't work. I guess I am missing something small. because I have done this thing a lot of times earlier and it had worked.

  • Programmatically setting UI Hints for runtime named where clause params

    Hi,
    At runtime, I've added some named where clause parameters to my view object instance, set the where clause and then executed the query. Then, when navigating to the target page, where a af:query panel is shown and a af:table shows the filtered results, I see the bind variables I've just created appearing in the search area as mandatory fields.
    My question is: how can I hide those runtime bind variables?
    Thanks
    JDeveloper 11.1.1.3.0

    I do want where clauses to be created at runtime instead of design time to improve DB performance
    whereClause += "AND DEPARTMENT_ID = " + departmentId;Marge -
    What you are doing is a recipe for POOR performance, not good performance. String concatenation in a where clause with no bind variables... ugh! Poor performance + poor security (you are now susceptible to SQL injection attacks).
    I suggest that you do this at design time (where possible) and have a read of the documentation about view criteria.
    And please, no matter what approach you use, PLEASE PLEASE PLEASE start using bind variables and not just jamming strings together to make your where clause, otherwise you are heading straight for disaster. I cannot stress this enough.
    John

  • Calling an Oracle stored procedure and retrieving result from OUT parameter

    Hello,
    I have a stored procedure that returns a string in an OUT parameter after receiving 6 IN parameters. I have tested the procedure in PL/SQL and it's producing the right output there. The problem is when I call the stored procedure from my Java method. I then get an error message telling me that I have the wrong number or types of arguments in my procedure call. I have checked that the method receives and sends the correct data in the correct order and I'm not sure what else the error message can relate to...?
    The exception is called on my second try statement but I haven't been able to find out what I have done wrong there. Does anyone have any suggestions? Thanks.
    the error message
    java.sql.SQLException: ORA-06550: line 1, column 13: PLS-00306: wrong number or types of arguments in call to 'P_SET_GIVEN_ANSWER' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
    the procedure
    CREATE OR REPLACE PROCEDURE p_set_given_answer(
    strfeedback OUT VARCHAR2,
    intpi_id IN INTEGER,
    intquestion_id IN INTEGER,
    intgivenanswer IN INTEGER,
    strgivenprefix IN VARCHAR2,
    strgivenunit IN VARCHAR2,
    strgu_id IN VARCHAR2) AS
    -- some declarations
    BEGIN
    -- some processing and then returns the string below indicating the outcome
    strfeedback = 'result';
    END
    the java method (the class is called dbUtil and the database connection is created in the method called getDbConnection() )
    public void setGivenAnswer(int intPi_id, int intQuestion_id, int intGivenAnswer, String strGu_id, String strGivenPrefix, String strGivenUnit) {
    java.sql.Connection con = null;
    String query = "{call ? := p_set_given_answer(?,?,?,?,?,?)}";
    try {
    con = dbUtil.getDbConnection();
    } catch(Exception e) {
    dbConnectionExceptionMessage = "error 1:"+e.toString();
    try{
    CallableStatement stmt = con.prepareCall(query);
    // register the type of the out param - an Oracle specific type
    stmt.registerOutParameter(1, OracleTypes.VARCHAR);
    // set the in params
    stmt.setInt(2, intPi_id);
    stmt.setInt(3, intQuestion_id);
    stmt.setInt(4, intGivenAnswer);
    stmt.setString(5, strGivenPrefix);
    stmt.setString(6, strGivenUnit);
    stmt.setString(7, strGu_id);
    // execute the stored procedure
    stmt.execute();
    // retrieve the results
    strFeedback = stmt.getString(1);
    } catch (java.sql.SQLException e) {
    dbConnectionExceptionMessage = "error 2:"+e.toString();
    try {
    con.close();
    } catch (java.sql.SQLException e) {
    dbConnectionExceptionMessage = "error 3:"+e.toString();
    ----------------------------------------

    Looks like you are declaring a procedure, but you are calling it like a function. A procedure has no return value, it has only parameters: "{call p_set_given_answer(?,?,?,?,?,?,?)}"

  • Stored Procedure with in param not working

    I have  a stored procedure that works  now I need to use an in Parameter . when I made modification now the stored proc says  "Source does not have a runnable target." I can't seem to figure out what is wrong wit it.
    using SQL developer  version 1.5.5
    here is the  stored proc
    CREATE OR REPLACE
    PROCEDURE STATEMENT_DOMESTIC_TEST
    ( s_date IN statement.statementdate%Type
    ) AS
    BEGIN
    INSERT INTO STATEMENT_DATA
                      (   STATEMENTNUMBER,
                          STATEMENTTOTAL,
                          STATEMENTDATE,
                          BALANCE_FORWARD,
                          CUSTID,
                          CUSTNAME,
                          STATEMENTPURCHASES,
                          STATEMENTPAYMENTS,
                          NOMAILNOPRINT,
                          SOLDTOCOUNTRYNAME,
                          CREDITZEROFLAG,
                          SOLDTOCOUNTRYCODE)
                SELECT  STATEMENTNUMBER,
                        STATEMENTTOTAL,
                        STATEMENTDATE,
                        BALANCE_FORWARD,
                        CUSTID,
                        CUSTNAME,
                        STATEMENTPURCHASES,
                        STATEMENTPAYMENTS,
                        NOMAILNOPRINT,
                        SOLDTOCOUNTRYNAME,
                        CREDITZEROFLAG,
                        SOLDTOCOUNTRYCODE
                            FROM  EROCKS.PS_JWF_STATEMENT
                                  WHERE (statementdate = s_date)and (STATEMENTTOTAL >0)
                                        and (SOLDTOCOUNTRYNAME is null or SOLDTOCOUNTRYNAME='US')
                                        and (TRIM(NOMAILNOPRINT) is null and NOMAILNOPRINT!='99');
    update STATEMENT_DATA H
                        set
                          ( H.REMTO_ZIP,
                            H.REMTO_CITY,
                            H.REMTO_STATE,
                            H.REMTO_MAILNAME,
                            H.REMTO_ADDR1,
                            H.REMTO_ADDR2,
                            H.REMTO_ADDR3,
                            H.SOLDTO_CITY,
                            H.SOLDTO_STATE,
                            H.SOLDTO_ZIP,
                            H.SOLDTO_ADDR1,
                            H.SOLDTO_ADDR2,
                            H.SOLDTO_ADDR3,
                            H.PHONE_PREFIX,
                            H.PHONE_NUMBER,
                            H.COMPANY_NUMBER,
                            H.STATEMENTMISC_CREDIT1,
                            H.STATEMENTMISC_CREDIT2)=
                      (SELECT J.REMTO_ZIP,
                              J.REMTO_CITY,
                              J.REMTO_STATE,
                              J.REMTO_MAILNAME,
                              J.REMTO_ADDR1,
                              J.REMTO__ADDR2,
                              J.REMTO_ADDR3,
                              J.SOLDTO_CITY,
                              J.SOLDTO_STATE,
                              J.SOLDTO_ZIP,
                              J.SOLDTO_ADDR1,
                              J.SOLDTO_ADDR2,
                              J.SOLDTO_ADDR3,
                              J.PHONE_PREFIX,
                              J.PHONE_NUMBER,
                              J.COMPANY_NUMBER,
                              J.STATEMENTMISC_CREDIT1,
                              J.STATEMENTMISC_CREDIT2
                              FROM STATEMENT_HEADER J
                                  WHERE  H.STATEMENTNUMBER= J.STATEMENTNUMBER);
    INSERT INTO EROCKS.STATEMENT_DATA_DETAILS
                      ( INVOICENUMBER,
                      STATEMENTNUMBER,
                      INVOICEDATE,
                      DOC_TYPE,
                      INVOICETOTAL,
                      PURCHASES,
                      PAYMENTS,
                      MISC_CREDIT1,
                      MISC_CREDIT2,
                      BUNUMBER,
                      BUNUMBER_RU,
                      REFERENCE_NUMBER,
                      DESCRIPTION, seq_number)
                        SELECT  H.INVOICENUMBER,
                                H.STATEMENTNUMBER,
                                H.INVOICEDATE,
                                H.DOC_TYPE,
                                H.INVOICETOTAL,
                                H.PURCHASES,
                                H.PAYMENTS,
                                H.MISC_CREDIT1,
                                H.MISC_CREDIT2,
                                H.BUNUMBER,
                                H.BUNUMBER_RU,
                                H.REFERENCE_NUMBER,
                                H.DESCRIPTION,
                                EROCKS.SEQ_STATEMENT.NEXTVAL
                        FROM STATEMENT  H
                            WHERE H.STATEMENTNUMBER IN
                                (SELECT STATEMENTNUMBER
                                    FROM STATEMENT_DOMESTIC);
    END STATEMENT_DOMESTIC_TEST;

    Hello,
    could it be, that you are not connected to a database? This is what the error message suggests.
    You cannot compile or execute a stored procedure without a database connection.
    Regards
    Marcus
    BTW: you should also consider to install a newer version of SQL Developer. The current version is 3.2.2

  • Stored procedure scope: using sp from another database

    Good day,
    I hava a stored procedure named sp_emps (simple select from an employees table) in a database named Employees.
    I would like use this procedure in a another database named New_Employees.
    Is this possible, without creating / copying the sp to the other database ?
    Also I did not want to make the sp a system object
    Please assist

    Hi Zimiso,
    The problem here is that no matter from where you execute your procedure, its context will always be the "Employees" database.
    What you ask for is possible, but only by using Dynamic SQL.
    You can have a @Database parameter on your procedure, and then concatenate the value in this parameter to wherever needed in your dynamic queries.
    For example:
    CREATE PROCEDURE sp_emps
    @Database NVARCHAR(200)
    AS
    DECLARE @Command NVARCHAR(MAX);
    SET @Command = 'SELECT * FROM ' + QUOTENAME(@Database) + '.dbo.MyEmployees'EXECUTE(@Command)
    More information about dynamic SQL:
    http://www.mssqltips.com/sqlservertip/1160/execute-dynamic-sql-commands-in-sql-server/
    This isn't an ideal solution because there are lots of possible risks and problems that come along with dynamic SQL (for example, SQL Injection).
    The better solution, in my opinion, would be to create the stored procedure as a system object (create it in the "master" database). This will make its context change based on the database from whence it was executed.
    Eitan Blumin; SQL Server Consultant - Madeira Data Solutions;

  • Viewobject - Stored Procedure with sys_refcursor out

    Hi,
    I have been trying to call an Oracle stored procedure which returns sys_refcursor as an out parameter.
    Even though I register out parameter in callStoreFunction method, I am getting "PLS-00306: wrong number or types of arguments in call".
    You can find piece of codes below.
    Could you please help?
    Thanks in advance.
    Stored Procedure;*
    CREATE OR REPLACE PROCEDURE SP_GET_PRODUCT_DETAIL_BY_ID(
    ID_in IN NUMBER,
    p_product_refcur OUT SYS_REFCURSOR
    IS
    BEGIN
    OPEN p_product_refcur FOR SELECT * FROM PRODUCT_DETAIL WHERE ID = ID_in;
    END SP_GET_PRODUCT_DETAIL_BY_ID;
    Java Code*
    The code that calls function method;
    ResultSet rs = (ResultSet)callStoredFunction(OracleTypes.CURSOR,"SP_GET_PRODUCT_DETAIL_BY_ID(?)",new Object[]{new Number(3)});
    Call function method;
    protected Object callStoredFunction(int sqlReturnType, String stmt, Object[] bindVars) {
    CallableStatement st = null;
    try {
    System.out.println("222222");
    // 1. Create a JDBC CallabledStatement
    st = getDBTransaction().createCallableStatement("begin ? := " + stmt + ";end;", 0);
    // 2. Register the first bind variable for the return value
    st.registerOutParameter(1, sqlReturnType);
    if (bindVars != null) {
    // 3. Loop over values for the bind variables passed in, if any
    for (int z = 0; z < bindVars.length; z++) {
    // 4. Set the value of user-supplied bind vars in the stmt
    st.setObject(z+2, bindVars[z]);
    // 5. Set the value of user-supplied bind vars in the stmt
    st.executeUpdate();
    // 6. Return the value of the first bind variable
    return st.getObject(1);
    } catch (SQLException e) {
    e.printStackTrace();
    throw new JboException(e);
    } finally {
    if (st != null) {
    try {
    // 7. Close the statement
    st.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }

    Hi mate,
    Sorry about that. My Jdev version is 11.1.2.3.0.
    The use case is that I am trying to call a SP from a VO which is triggered from App Module. I have a bind parameter in App Module for SP input, but at the moment I am using a static value for test purpose.
    I am able to make a call from App Module to SP via VO but got an error as I am calling with wrong parameters.
    Stored Procedure;_
    CREATE OR REPLACE PROCEDURE SP_GET_PRODUCT_DETAIL_BY_ID(
       ID_in IN NUMBER,
       p_product_refcur OUT SYS_REFCURSOR
    IS
    BEGIN
       OPEN p_product_refcur FOR SELECT * FROM PRODUCT_DETAIL WHERE ID = ID_in;
    END SP_GET_PRODUCT_DETAIL_BY_ID;
    Java Code_
    The code that calls function method;
    ResultSet rs = (ResultSet)callStoredFunction(OracleTypes.CURSOR,"SP_GET_PRODUCT_DETAIL_BY_ID(?)",new Object[]{new Number(3)});
    Call function method;
    protected Object callStoredFunction(int sqlReturnType, String stmt, Object[] bindVars) {
       CallableStatement st = null;
       try {
          // 1. Create a JDBC CallabledStatement
          st = getDBTransaction().createCallableStatement("begin ? := " + stmt + ";end;", 0);
          // 2. Register the first bind variable for the return value
          st.registerOutParameter(1, sqlReturnType);
          if (bindVars != null) {
             // 3. Loop over values for the bind variables passed in, if any
             for (int z = 0; z < bindVars.length; z++) {
                // 4. Set the value of user-supplied bind vars in the stmt
                st.setObject(z+2, bindVars[z]);
          // 5. Set the value of user-supplied bind vars in the stmt
          st.executeUpdate();
          // 6. Return the value of the first bind variable
          return st.getObject(1);
          } catch (SQLException e) {
             e.printStackTrace();
             throw new JboException(e);
          } finally {
             if (st != null) {
                try {
                   // 7. Close the statement
                   st.close();
                } catch (SQLException e) {
                   e.printStackTrace();
    The exact error;
    java.sql.SQLException: ORA-06550: line 1, column 14:
    PLS-00306: wrong number or types of arguments in call to 'SP_GET_PRODUCT_DETAIL_BY_ID'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignoredThanks alot.

  • Trouble with calling a stored procedure with VARCHAR parameter from trigger

    Hi everybody,
    today I ran across a problem with stored procedures and triggers that try to call them. Background info: I want to log changes in certain tables to another table in a trigger, so I can replicate the changes to another (non-Oracle) database in an asynchronous way. As an example I have the first data table "bak_s3_berufliste" and the table to store the changes in is "bak_s3_change_request".
    DROP TABLE BAK_S3_BERUFLISTE;
    CREATE TABLE bak_s3_berufliste (
    id_bl NUMBER(27,0) NOT NULL,
    berufsbez VARCHAR2(255),
    CONSTRAINT PK_BAK_S3_BERUFLISTE PRIMARY KEY (id_bl) ENABLE);
    DROP TABLE bak_s3_change_request;
    CREATE TABLE bak_s3_change_request (
    ID_CR NUMBER(27,0) NOT NULL,
    TABELLE_NAME VARCHAR2(50) NOT NULL,
    TABELLE_ID_ALT NUMBER(27,0),
    TABELLE_ID_NEU NUMBER(27,0),
    CONSTRAINT PK_BAK_S3_CHANGE_REQUEST PRIMARY KEY (ID_CR) ENABLE);
    DROP SEQUENCE seq_bak_s3_change_request;
    CREATE SEQUENCE seq_bak_s3_change_request;
    For testing purposes I created the following stored procedure and trigger:
    CREATE OR REPLACE PROCEDURE schreibe_cr (t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
    BEGIN
    INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
    VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
    END;
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr(:old.id_bl,:new.id_bl)
    *... and everything worked perfectly - except from the fact that I need to know which table had changed of course. So I added another parameter to the stored procedure:*
    CREATE OR REPLACE PROCEDURE schreibe_cr (t_name IN VARCHAR2, t_id_alt IN NUMBER, t_id_neu IN NUMBER) IS
    BEGIN
    INSERT INTO bak_s3_change_request(ID_CR, TABELLE_NAME, TABELLE_ID_ALT, TABELLE_ID_NEU)
    VALUES (seq_bak_s3_change_request.NEXTVAL, t_name, t_id_alt, t_id_neu);
    END;
    and tested it:
    CALL schreibe_cr('Test',1,2);
    *... successfully. So I also added the parameter to the trigger:*
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr('Tabellenname',1,2)
    and what i get is:
    Error starting at line 31 in command:
    CREATE OR REPLACE TRIGGER trg_bak_s3_berufliste
    BEFORE INSERT OR UPDATE OR DELETE ON bak_s3_berufliste
    FOR EACH ROW
    call schreibe_cr('Tabellenname',1,2)
    When I try to insert something into that table I get the following error:
    insert into bak_s3_berufliste (id_bl, berufsbez) values (seq_bak_s3_change_request.NEXTVAL, 'tueduelue');
    Error report:
    ORA-00911: Ungültiges Zeichen
    00911. 00000 - "invalid character"
    Cause: identifiers may not start with any ASCII character other than
    letters and numbers. $#_ are also allowed after the first
    character. Identifiers enclosed by doublequotes may contain
    any character other than a doublequote. Alternative quotes
    (q'#...#') cannot use spaces, tabs, or carriage returns as
    delimiters. For all other contexts, consult the SQL Language
    Reference Manual.
    Action:
    I tried everything that came to my mind, like using double-quotes (") instead of quotes (') in the trigger code or escaping the quotes (\'), but nothing worked. Can anybody help my and tell me what's wrong? After googling for hours I'm outta ideas :-(
    Any ideas appreciated!
    Thanks in advance,
    Jens

    Why?
    Are you looking for this?
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:01.61
    satyaki>
    satyaki>
    satyaki>create table aud_dup_emp
      2     as
      3       select empno, ename
      4       from dup_emp
      5       where 1=2;
    Table created.
    Elapsed: 00:00:01.86
    satyaki>
    satyaki>select * from dup_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
    18 rows selected.
    Elapsed: 00:00:00.10
    satyaki>
    satyaki>
    satyaki>create or replace procedure ins_aud_dup(eno in number, enm in varchar2)
      2     is
      3     begin
      4       insert into aud_dup_emp(empno,ename) values(eno,enm);
      5     end;
      6  /
    Procedure created.
    Elapsed: 00:00:03.36
    satyaki>
    satyaki>
    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
      1  create or replace trigger trg_aud_dup
      2  before insert on dup_emp
      3     for each row
      4     begin
      5       ins_aud_dup(:old.empno,:new.ename);
      6*    end;
    satyaki>/
    Trigger created.
    Elapsed: 00:00:01.47
    satyaki>
    satyaki>
    satyaki>select * from aud_dup_emp;
    no rows selected
    Elapsed: 00:00:00.10
    satyaki>
    satyaki>
    satyaki>insert into dup_emp(empno,ename,deptno) values(8855,'BILLY',40);
    1 row created.
    Elapsed: 00:00:00.19
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>
    satyaki>select * from dup_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          8855 BILLY                                                                   40
    19 rows selected.
    Elapsed: 00:00:00.20
    satyaki>
    satyaki>select * from aud_dup_emp;
         EMPNO ENAME
               BILLY
    Elapsed: 00:00:00.09
    satyaki>Regards.
    Satyaki De.

  • Calling Oracle Stored procedure with OUT parameter from ODI

    Hi,
    I called an oracle stored procedure with following anonymous block in the ODI procedure.
    Declare
    Status varchar2(10);
    Begin
    OTM.DeleteTarget('E_KPI_TARGET_VALUE', Status);
    End;
    I want to capture the OUT parameter STATUS value in a project level variable.
    And based on its va;lue I would like to choose between 2 interfaces in my package.
    Please help me in doing this.

    Hi,
    For that kind of situation I commoly use:
    1) one step with:
    create or replace package <%=odiRef.getSchemaName("W")%>.pck_var
    Status varchar2(10);
    end;
    * transaction 9, for instance
    2) step
    Begin
    OTM.DeleteTarget('E_KPI_TARGET_VALUE', <%=odiRef.getSchemaName("W")%>.pck_var.Status);
    End;
    * transaction 9
    3) then, at an ODI variable, use a refresh like:
    select <%=odiRef.getSchemaName("W")%>.pck_var.Status from dual
    at same logical shema where the package was created.
    Does it make sense to you?

  • Readonly table with where clause value from previous page

    Hi
    I am using jdeveloper 10.1.3.
    I have a globalhome page where the user enteres a reference number. i have a backing bean for the globalhome page that runs a method to run an sql that seraches for this reference number, if the reference number exsits the user is directed to a detail page.
    this detail page should display details of this reference number.
    i have set up a read only table to display this data based on a view object with a bind varaible in the where clause.
    however i am unsure how to set this bind varaible value to the reference entered in the first globalhome page.
    please can anyone advise how to do this.
    regards

    Hi,
    You can follow following steps to achieve this
    1) Write a custom method in your Application module like
    public void executeMyVO(String bindVarValue)
    MyVOImpl vo= getMyVo();
    vo.setNamedWhereClauseParam(<bind variable name decalred in VO>,bindVarValue);
    vo.execute();
    2) Expose the above method to client. (Right click AM-->Client-->Shift method from left to right)
    3) In the pagedef of globalhome page, create a method action for the aboce created custom method
    4) execute the method action from your backing bean after you run an sql that seraches for this reference number.
    Hope this help.
    Vikram

Maybe you are looking for

  • Mapping with attachments, DataType creation

    Hi all, Have to solve two problems: 1. How to map attachment? - I'm getting message with an attachment on XI, then I need to extract it and convert to base64 string(guess it will be done with java mapping, but I don't know how at all). 2. I'm trying

  • Runtime Errors DBIF_RSQL_TABLE_UNKNOWN in BW system

    Hi Guys, We refreshed BW system from production to sandbox. SGEN finished successfully. Now I am strucked at bdls. when i ran bdls i am getting below dump pls help me to resolve this. Runtime Errors         DBIF_RSQL_TABLE_UNKNOWN Date and Time      

  • Can a slideshow exported to a DVD be shown on a PC computer?

    I created a slideshow in iPhoto and exported it to a DVD which plays fine on my Mac, but I was told it won't play on a Windows PC.  Is that true?

  • My Exporting Files Solution

    Just wanted to offer this info in hopes that it helps someone with an export problem. After rolling along in LR with several exports, I suddenly couldn't export to my C drive or to my external HD, both of which had plenty of memory. I did a search he

  • Camera Raw Filter glitch

    Hi, running PS CC 2014 on Mac with Yosemite and am getting an annoying glitch when I access Filter >  Camera Raw Filter The only way to show all items in the filter is to roll over it with the cursor. This doesn't happen all the time, just enough to