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

Similar Messages

  • Difference between named where clause param and simple ui exposed bv

    Hi ppl,
    I just had a small question ,
    Assuming i have a view object with a named bind variable ( i give it at time of creation/definition itself ) ..
    In order to set this, for some simple usage such as a list table , i believe there are two ways:-
    1) in my managed bean , i could set the bind variable using the setNamedWhereClauseParameter
    OR
    2) i could expose the setter of my bind variable to the client interface and then set it manually
    following either of the above , i would do a vo.executeQuery() ....
    Are there any differences in the above approach ? which would be more appropriate ?
    K

    Hi,
    except for that using a client method is less code to write because you don't have to get a handle to the VO first, I don't see a difference.
    However, you can also create a binding in the pagedef fiel to the ExectuteWithParams operation on the ViewObject, in which case you could
    - get a handle to the ExecuteWithParams binding (e.g. named "myHandlerToExecute")
    - then do
    myHandlerToExecute.getParamMap().put("bindVar Name", value);
    myHandlerToExecute.execute();
    Might be the smarter way and probably best practices too (for more details see the developer guide)
    Frank

  • [Solved] Named Bind Variables at Runtime - SQL WHERE clause issue

    Hey 'all,
    I've been having this issue today with a Search page using Named Bind Variables at Runtime for the search parameters for the WHERE clause in the view objects SQL.
    I've got everything working except for a clearing method which I've created so that the user can clear the current WHERE clause from the SQL statment and set it as 1=2 (so that it doesn't do a blind query on load).
    The method can clear and set the WHERE clause to 1=2 only when there is already one there.
    Below are the methods: (located in my view object class)
    public void findInvoiceById(Number invoiceId){
        setWhereClause("invoice_id = :P_INVOICE_ID");
        defineNamedWhereClauseParam("P_INVOICE_ID",null,null);
        setNamedWhereClauseParam("P_INVOICE_ID",invoiceId);
        executeQuery();
    public void clearCriteria(){
        setWhereClause("1=2");
        removeNamedWhereClauseParam("P_INVOICE_ID");
        executeQuery();
    }The error which I get is the following - this happens when the button is pressed twice in a row, or when no query has been passed previously.
    1. JBO-29000: Unexpected exception caught: oracle.jbo.NoDefException, msg=JBO-25058: Definition P_INVOICE_ID of type Variable not found in SupplierInvoicesView1
    2. JBO-25058: Definition P_INVOICE_ID of type Variable not found in SupplierInvoicesView1
    Any help with this would be greatly appreciated!
    Cheers,

    Hi Bonnie,
    we have it working ok, but still feel that there is room for improvement in the design.
    For us the key factors are:
    Pages based on the same view object that can be queried multiple ways.
    We don't want to put design time bind variables in because it limits the use of the VO
    We don't wan't multiple VO's with different where clauses.
    The page is displaying the same table columns and fields, but the where clause must be dynamic.
    We only want to query on the search field entered (some of our tables are massive)
    TopLink named queries are really what we are after, but we don't want to forgo all the other ADF BC functionality. The only examples of ViewCriteria in the developer guide had literals in the where clause and no bind variables. The View Criteria may still be an option, but it appeared quite complex compaired to directly adding and removing bind variables at runtime.
    a couple of footnotes:
    the following methods are used to clear the runtime variables prior to reusing the VO (thanks to John Stegman for the pointer on the exception handler):
        public void clearBindVariable(String bindVariableName){
            try
                removeNamedWhereClauseParam(bindVariableName);
            catch (NoDefException e)
        public void clearBindVariables(){
            clearBindVariable("P_INVOICE_ID");
            clearBindVariable("P_INVOICE_NUM");
            clearBindVariable("P_SUPPLIER_NAME");
            clearBindVariable("P_INVOICE_DATE_FROM");
            clearBindVariable("P_INVOICE_DATE_TO");
            clearBindVariable("P_SUPPLIER_NUMBER");
        }We are using 1=1 and 1=2 in the where clause to supress blind querying. 1=2 is applied when ever we are not explicitely searching for something. We had a problem with using the refresh condition ${adfFacesContext.postback == true} which I posted about here:
    executeQuery called twice using ${adfFacesContext.postback == true}
    Would still gladly hear other ideas on a better reuse design.
    regards,
    Brenden

  • Programmatically setting torque Limits for a servo axis

    Hello,
    I would like to know if in order to programmatically limit torque for a servo axis to be between -7V and +7V (rather than the default +/- 10V) I would have to call the "Load Torque Limit.flx" vi before every single move. If that is the case, is there a way to set the torque for an entire program run-time (other than manually setting it in MAX before running the program)?
    Thanks
    Vlad

    Hi Vlad,
    I believe you will have to call the VI each time and the only place I am aware of changing the limits wound be in MAX under Axis #>Control Loop Setting> Torque Settings Tab.
    Limiting the DAC Output Voltage on a Servo Axis
    http://digital.ni.com/public.nsf/allkb/CE34F1F1BAE5456C8625720B0080AD34?OpenDocument
    Tim O
    Applications Engineer
    National Instruments

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

  • Next-Previous Do not work Properly for lengthly dynamic Where Clause

    I have created a View object using Expert Query mode
    with following Query:
    SELECT LIC_SYS_ID,
    LIC_NAME,
    TERRITORIES,
    LANGUAGES,
    MEDIA,
    SEGMENT_NAME,
    CHANNELS,
    ACTIVITY_CD,
    LS.LIC_SHORT_NAME,
    LS.LIC_AKA_NAME
    FROM V_LICENSEE_SEARCH LS
    ORDER BY LIC_NAME
    Then at run time the following Where Clause staments get added by in JSP based on the users criteria
    wClause = "(ACTIVITY_CD = '" + activityStatus + "')"
    + " AND " +
    "(LIC_NAME like '" + licenseeName + "%' OR " +
    " LIC_SHORT_NAME like '" + licenseeName + "%' OR " +
    " LIC_AKA_NAME like '" + licenseeName + "%' ) "
    In this case the DataScroller does not work properly It DataTable traves only one setp when I click the "Next" link, But if I use the Drop down list of the Scroller its works fine.
    Secondly the "Next" "Previous" links of the DataScroller work fine if I use only one stmt in the WhereClause ex: "ACTIVITY_CD LIKE 'A%'".
    Can anybody help me with this, Is this a limitation of DataScroller/DataTable/DataSource tags why does it not work??
    Please help me its urgent.
    Thanks a ton !!

    Thx for the reply, I did try your suggestion It did not throw any exception. Here is the log messages after enabling jbo Debug.
    [391] Reusing a cached session application module instance
    [392] Getting a connection for internal use...
    [393] Creating internal connection...
    [394] Oracle SQLBuilder: Registered driver: oracle.jdbc.driver.OracleDriver
    wClause : (ACTIVITY_CD = 'A') AND (LIC_NAME like 'A%' OR LIC_SHORT_NAME like 'A%' OR LIC_AKA_NAME like 'A%' )
    [395] Column count: 10
    [396] ViewObject : Reusing defined prepared Statement
    [397] $$added root$$ id=-2
    [398] Application Module failover is enabled
    [399] Getting a connection for internal use...
    [400] Creating internal connection...
    [401] Oracle SQLBuilder: Registered driver: oracle.jdbc.driver.OracleDriver
    [402] <AM MomVer="0">
    <cd/>
    <VO>
    <VO Sz="8" St="8" Def="com.sophoi.ipls.media.tv.businessentities.licensee.LicenseeView" Name="licenseeView">
    <Wh>
    <![CDATA[(ACTIVITY_CD = 'A') AND (LIC_NAME like 'A%' OR  LIC_SHORT_NAME like 'A%' OR  LIC_AKA_NAME  like 'A%' )]]>
    </Wh>
    <Or>
    <![CDATA[LIC_NAME ASC]]>
    </Or>
    </VO>
    </VO>
    </AM>Long postings are being truncated to ~1 kB at this time.

  • 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

  • Need Help Programmatically setting Page Size for printing to Adobe PDF

    We are upgrading from Adobe 5 to Adobe 9.  In Adobe 5, we set a few parameters in the __pdf.ini file to create a document with a specific Page Size.  For Example:
    [Acrobat PDFWriter]
    PDFFileName=
    bDocInfo=0
    Orient=1
    bExecViewer=0
    cpmarginwhole=18
    cpwidepart=0
    cpwidewhole=612
    cpheightpart=0
    cpheightwhole=792
    Paper=0
    Since upgrading to Adobe 9.2, this no longer appears to work.  I have also tried adding these values to the following Registry Locations with no luck:
    HKCU\Software\Adobe\Acrobat PDFWrite
    and
    HKCU\Software\Adobe\Acrobat Distiller\PrinterJobControl
    Is it still possible to create a custom page size using this method?  Or am I going to have to do that in a different way?

    Bill, thanks for the quick response.  However, we generate many forms on a daily basis with different page size requirements.  The way this was accomplished through Adobe PDFWriter was by setting the various parameters in the __pdf.ini file for the Document that we are generating.  I believe we have about 7 different page sizes that we generate.

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

  • Output varies for group by  & where Clause

    Below are the two statements which i am comapring .
    1) for this i get a output as it displays 0 because there are no rows matched to this criteria .
    select count(No) from T1 where No = 3"
    1
    0
    1 record(s) selected.
    2) Same way i am looking to get output for this statement .If value exists it gives the count if not it should return 0.
    select count(*) from T1 GROUP BY No HAVING No = 3"
    1
    0 record(s) selected.
    Can someone suggest this

    user587133 wrote:
    Below are the two statements which i am comapring .
    1) for this i get a output as it displays 0 because there are no rows matched to this criteria .
    select count(No) from T1 where No = 3"
    1
    0
    1 record(s) selected.
    2) Same way i am looking to get output for this statement .If value exists it gives the count if not it should return 0.
    select count(*) from T1 GROUP BY No HAVING No = 3"
    1
    0 record(s) selected.
    Can someone suggest thisIn the second query the having clause is applied after the count, so the count is being done and then any rows matching the having clause are returned. As there are no rows matching the having clause the result is that no rows are returned. The count is being done, but you are filtering out those rows from the result.

  • Using 'between' for literals inside 'where' clause

    Dear all,
    I run the following queries in 10.g XE HR sample schema:
    The first query is limited by characters between "I" and "S" where the second query is limited by words between "IT" and "Sales".
    My question is, how come the first query doesn't return "Sales" row as it does in the second one? I don't quite understand how does "between" works on string literals. Please help.
    Regards,
    Valerie
    SQL> select department_name from departments where department_name between 'I' a
    nd 'S' order by department_name;
    DEPARTMENT_NAME
    IT
    IT Helpdesk
    IT Support
    Manufacturing
    Marketing
    NOC
    Operations
    Payroll
    Public Relations
    Purchasing
    Recruiting
    DEPARTMENT_NAME
    Retail Sales
    12 rows selected.
    SQL> select department_name from departments where department_name between 'IT'
    and 'Sales' order by department_name;
    DEPARTMENT_NAME
    IT
    IT Helpdesk
    IT Support
    Manufacturing
    Marketing
    NOC
    Operations
    Payroll
    Public Relations
    Purchasing
    Recruiting
    DEPARTMENT_NAME
    Retail Sales
    Sales
    13 rows selected.

    Imagine how those words are ordered in an encycopedia or thesaurus.
    1. I
    2. IT
    3. IT Helpdesk
    4. IT Support
    5. Manufacturing
    6. Marketing
    7. NOC
    8. Operations
    9. Payroll
    10. Public Relations
    11. Purchasing
    12. Recruiting
    13. S
    14. Sales
    15. System Management
    "S" is ordered before "Sales". Between includes everything including the lower and the upper boundary (row 1-13). It does not include stuff that is ordered AFTER the upper boundary (Row 14++).
    So if you want to find everything the starts with "S" then you have several options.
    1) Show everything after including "I" but before "T" (T not including)
    select department_name
    from departments
    where department_name >=  'I'
    and department_name < 'T'
    order by department_name;or
    2) Show everything where the first letter is between "I" and "S"
    select department_name
    from departments
    where substr(department_name,1,1) between 'I' and 'S'
    order by department_name;I would almost always choose the first option. Usually it is faster because an index on the department name can be used if there is one.
    There is a third option. But this is kind of silly and incomplete. You could add the very last string that you can imagine as the upper boundary of the between function.
    select department_name
    from departments
    where department_name between 'I' and 'Szzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
    order by department_name;Edited by: Sven W. on Dec 14, 2010 12:54 PM - added third option

  • How to write a java function for use in where clause in SQL statement

    Hi,
    Does anyone know a good tutorial on how to write and include a Java class/function into Oracle.
    I'd like to write mathematical function to use in my queries, but the resources available in PL/SQL are very limited.
    Many thanx

    Pim,
    I see you got an answer in the PL/SQL forum.
    But in case you haven't seen it, perhaps this Web page will help:
    http://www.oracle.com/technology/tech/java/jsp/index.html
    Good Luck,
    Avi.

  • Dynamic where clause for generated reports (designer 6.0)

    Hi,
    I'd like to include dynamic where clause into my reports. It's easy with report builder by using bind parameter in a query where clause (&param where param is a parameter in which you fill a VARACHAR2 to complete default where clause).
    Problem with designer 6.0 report generator is that he failed while trying to parse the query statement he contructs if there is a bind parameter within.
    How can I manage this problem ?
    Thanks for answers
    Romain

    Hi Divya,
         SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,'paramform=no P_WHERE_CLAUSE= '||Where_Clause);Instead of using SET_REPORT_OBJECT_PROPERTY built in try using ADD_PARAMETER built in which
    adds parameters to a parameter list. Each parameter consists of a key, its type, and an associated value.
    v_rep := RUN_REPORT_OBJECT(repid); and instead of using RUN_REPORT_OBJECT try using RUN_PRODUCT.
    DECLARE
         repid REPORT_OBJECT;
         v_rep  VARCHAR2(100);
         Where_Clause Varchar2(4000) := null ;
            *Pl_Id        ParamList;*
            *Pl_Name      VARCHAR2(10) := 'param_list';*
    BEGIN
         Where_Clause := 'Where '||Create_Where_Clause();
         message(Where_Clause);
         message(' ');
            pl_id := Get_Parameter_List(pl_name);
            IF not Id_Null(pl_id) THEN
               Destroy_Parameter_List(pl_id);
            END IF;
            pl_id := Create_Parameter_List(pl_name);
            Add_Parameter(pl_id,'P_WHERE_CLAUSE', TEXT_PARAMETER, WHERE_CLAUSE);
            Add_Parameter(pl_id,'PARAMFORM',TEXT_PARAMETER,'NO');
    --      Add_Parameter(pl_id,'ANY_OTHER_PARAMETER', TEXT_PARAMETER, 'VALUE FOR OTHER PARAMETER');
            RUN_PRODUCT(REPORTS,'REPORT_NAME', ASYNCHRONOUS, RUNTIME, FILESYSTEM, pl_id, NULL);
    END;Also you can add as many User created or System parameters as you want using add_parameter. Updated the code to add PARAMFORM parameter.
    Best Regards
    Arif Khadas
    Edited by: Arif Khadas on Mar 15, 2011 9:31 AM

  • Variable for entire where clause

    Is it possible to use a variable for the entire where clause in a PL/SQL select statement?
    I have a where clause stored as a string in the database and I want to use that entire string as a variable, but my procedure will not compile because it is missing the relational operator.
    SELECT whereclause FROM clausetable WHERE clause = 'TEST'; will return this string: column1 = 'abc'
    Here's my procedure:
    create or replace
    PROCEDURE TESTWC
    (c_out OUT sys_refcursor )
    AS
    BEGIN
    DECLARE
    v_whereclause VARCHAR2(255);
    BEGIN
    SELECT whereclause
    INTO v_whereclause
    FROM clause_table
    WHERE clause = 'TEST';
    DBMS_OUTPUT.PUT_LINE(v_whereclause);
    OPEN c_test FOR SELECT * FROM dpacsoftware WHERE v_whereclause;
    NULL;
    END;
    END TESTWC;

    Is it possible to use a variable for the entire where clause in a PL/SQL select statement?Unfortunately yes.
    I have a where clause stored as a string in the databaseThis is a really bad idea, like storing the source for half your program in a text file with a bunch of Java or C or FORTRAN code and opening, reading, compiling and linking at run time.
    It is slow, slow, slow as you can expect, and dangerous and insecure, since someone could have put a format C: command in your source file, or something equivalently nasty to a database.

  • How to define SQL that contains "in" where clause in VO?

    I don't want to define "in" caluse in a programatical way in VO like below. I want to use a declariable way to define in clause using varaible bindings.
    Can it be implemented?
        private String getInClauseWithParamNames(List termCodes) {
               //logic to form the in clause with multiple bind variables
               StringBuffer inClause = new StringBuffer();
               if(termCodes !=null){
                   for (int i = 1; i < termCodes.size() + 1; i++) {
                       inClause.append(":termC" + (i));
                       if (i < termCodes.size()) {
                          inClause.append(",");
               return inClause.toString();
        public Row[] getYardFixedSlots(List termCodes) {
            if(termCodes != null && !termCodes.isEmpty()){
                String inClause = getInClauseWithParamNames(termCodes);
                //setting the where cluase to use the generated in clause
                this.setWhereClause("YardFixedSlot.TERMINAL_C in (" + inClause + ")");
                ////clearing all existing where clause params if any
                this.setWhereClauseParams(null);
                if(getVariableManager() !=null){
                   this.getVariableManager().clearVariables();
                //setting values for all bind variables one by one in the in clause
                for (int i = 0; i < termCodes.size(); i++) {
                    //defining the named bind variables programatically
                    this.defineNamedWhereClauseParam("termC" + (i + 1), null, null);
                    //setting the value for each named bind variable
                    this.setNamedWhereClauseParam("termC" + (i + 1), termCodes.get(i));
                this.setRangeSize(-1);
                //executing the query
                this.executeQuery();
            //returning the rows from query result
            return this.getAllRowsInRange();

    I test it using model tester.
    I try to write a test program to test it. when run it in jdeveoper, why it always run model tester instead of run my test program?
    package com.psa.citos.ypc.model.views.shift;
    import oracle.jbo.ApplicationModule;
    import oracle.jbo.Row;
    import oracle.jbo.RowSet;
    import oracle.jbo.ViewObject;
    import oracle.jbo.client.Configuration;
    public class TestClient {
        public static void main(String[] args) {
            TestClient testClient = new TestClient();
            String        amDef = "com.psa.citos.ypc.model.services.AppModule";
            String        config = "AppModuleLocal";
            ApplicationModule am = Configuration.createRootApplicationModule(amDef,config);
            // Work with your appmodule and view object here
            // 1. Find the vessel view object instance.
            FindVesselListByVVCodesImpl vesselList = (FindVesselListByVVCodesImpl)am.findViewObject("FindVesselListByVVCode1");
            vesselList.setvv_csv_list("23981,23818,23132");
            // 2. Execute the query
              vesselList.executeQuery();
              // 3. Iterate over the resulting rows
              while (vesselList.hasNext()) {
                  Row customer = vesselList.next();
                  // 4. Print the person's email
                  System.out.println("AbbrVesselM: " + customer.getAttribute("AbbrVesselM"));
            Configuration.releaseRootApplicationModule(am, true);

Maybe you are looking for