Bind Variables in VO Query

Hi,
I extended a CO and added extra conditions to the VO Query by setWhereClause. The original VO query had :1 and :2 bind parameters. The extra added conditions also uses those 2 variables and an extra parameter. When I run the program, I am getting the error as "java.sql.SQLException: ORA-01008: not all variables bound"
The original query is
select a, b
from table1
where x = :1 and y = :2
The extra added condition is
exists (select ......(select ..from table1 where x = :1 and y = :2)
where ..
and z = :3)
Now I am binding the parameter :3 with a value.
:1 and :2 will be binded in the original CO. Since these parameters were used twice, I am getting the above error.
How can I work around this issue.
Thanks,
HC

Original VO Query:
SELECT *
FROM (SELECT rt_category_id,
category_name,
TYPE
FROM icx_cat_categories_tl
WHERE rt_category_id IN (SELECT child_category_id
FROM icx_cat_browse_trees
WHERE parent_category_id = :1)
AND language = :2
AND TYPE IN (1, 2)) QRSLT
ORDER BY UPPER (category_name)
Code from CO:
int v_WhereClauseValue1;
OAApplicationModule oam = paramOAPageContext.getApplicationModule(paramOAWebBean);
OAViewObject v_childCategoriesVO = (OAViewObject)oam.findViewObject("ChildCategoriesVO");
v_WhereClauseValue1 = paramOAPageContext.getUserId();
Integer v_Int = new Integer(v_WhereClauseValue1);
v_childCategoriesVO.setWhereClause("QRSLT.rt_category_id in (select distinct cb.rt_category_id from (SELECT distinct icb.child_category_id, IQ.rt_category_id FROM icx_cat_browse_trees icb, (SELECT rt_category_id FROM icx_cat_categories_tl WHERE rt_category_id IN (SELECT child_category_id FROM icx_cat_browse_trees WHERE parent_category_id = :1) AND language = :2 AND TYPE IN (1, 2) ) IQ START WITH icb.parent_category_id = IQ.rt_category_id CONNECT BY PRIOR icb.CHILD_CATEGORY_ID = icb.PARENT_CATEGORY_ID) cb, CW_IPROC_CATALOG_USER ciu, icx_cat_categories_tl icc where cb.child_category_id = icc.rt_category_id and icc.category_name = ciu.iprocurement_category and ciu.requestor_user_id = :3)");
// v_childCategoriesVO.setWhereClauseParams(null);
v_childCategoriesVO.setWhereClauseParam(2, v_Int);

Similar Messages

  • Passing values in a vector list as bind variables in sql query.

    Hi,
    I have a vector list containing values 12,13,14.
    vector<string> v;
    v has values 12,13 and 14.
    Here the number of values in vector list are not fixed.
    I want to pass these values as bind variables to sql query.
    Can anyone suggest me how to do this.
    Thanks in advance!!

    Ah, the it's the classic 'Varying In-List' again
    See:
    The Tom Kyte Blog: Varying in lists...
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061 (started more than a decade ago, so scroll down for more recent examples)

  • Bind variables in SQL query of DBAdapter

    Hi,
    Can we add bind variables to SQL query when we define DB adapter...?

    No, not in the Wizard.
    I do not know if it is possible with the TopLink in combination with BPEL.
    But can you use a Pl/SQL procudere/package that performs the dynamic SQL?

  • How to use SYSDATE as a default value of a bind variable in a query report?

    Hi,
    I want to use SYSDATE as default value for a bind variable in Query based report.
    I don't see any way to do it, someone helps?
    Thanks a lot.
    Paulo.

    You can aslo use #sysdate directly.
    Hi,
    The way I'm doing in my report is, I have a database function (f_ret_sysdate) with the following code
    create function f_ret_sysdate return varchar2
    begin
    return to_char(sysdate,'mm/dd/yyyy');
    end;
    Now, in the 'Customization Form Display Options' section of the report I'm calling this function as #f_ret_sysdate in the default value field of corresponding bind variable to display SYSDATE with the format.
    Hope this helps!...
    -Krishnamurthy

  • How to pass a value to a bind variable in a query report in oracle apex

    Hi Guys,
    I have requirement to send weekly reports via email to some users. The users should receive their own records in the report. The user details is stored in a table. What I am planning to do is to create a report query in oracle apex to generate the report and then run a function/procedure via a scheduler to email the report to respective users. Now my query is ............. is it possible to pass a value (user name) to the report query to pull records of only that user? I know we can have bind variables in the report query but I have no idea how to pass a value for bind variables from a function/procedure.
    Can anyone help me on this issue or suggest a better approach?
    Thanks,
    San

    You need to use dynamic sql
    But please keep in mind that since you're using Oracle you may be better off posting this in some Oracle forums
    This forum is specifically for SQL Server
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to use bind variable in the query to avoid hard parsing

    Hi,
    I have a query which is using literals
    strquery:='SELECT SUMTOTAL FROM tab1 WHERE BATCHNO = '''
          || gBNo
          || ''' AND A_ID = '''
          || g_id
          || ''' AND L_ID = '''
          || g_LId
          || '''  AND S_Code = ''C_3'' ';
    execute immediate strquery;I have been asked to use a bind variable to avoid hard parsing.
    How do i do it?
    Edited by: user8731258 on Jul 27, 2012 5:07 AM
    Edited by: user8731258 on Jul 27, 2012 5:08 AM

    You dont need Dynamic SQL. Your Table and Column Name are static in that query. Just use Static SQL
    SELECT SUMTOTAL
      INTO lSumTotal
      FROM tab1
    WHERE BATCHNO = gBatchNo
       AND ATM_ID  = gAtm_id
       AND LOAD_ID = gLoadId
       AND STEP_CODE = 'C_3';

  • Need help in Bind variable in AF Query LOV

    Hi,
    i have one problem with bind variable, if i use bind variable in the LOV VO Query then my result is not coming, if there is not bind variable it's working fine and if i use the bind variable in the LOV search option then it's working fine but if i hide the bind variable and set the value in AM prepareSesstion method the LOV is not returning any value. I try to return the values also all values are also coming but those values are not setting to AF Query Attribute.
    Query is:
    select substr(d.description,0,40) description
    from cm_system_users a,
    cm_user_responsibilities b,
    cm_responsibility_processes c,
    cm_processes d
    where a.nt_login =:B_NT_LOGIN
    and a.user_id = b.user_id
    and trunc(sysdate) between b.eff_date and nvl(b.exp_date,sysdate + 1)
    and b.RESPONSIBILITY_ID = c.RESPONSIBILITY_ID
    and c.process_type = d.process_type
    and d.enabled_flag = 'Y' order by d.arguments_flag
    AM Method:
    CmProcessViewImpl vo = getCmProcessView();
    String nt_login = getUserPrincipalName();
    vo.setNamedWhereClauseParam("B_NT_LOGIN", nt_login.toUpperCase());
    vo.executeQuery();
    Can any one help me in this. it's urgent for me.

    This is a little underdescribed. IIUC, the view object in question is being used as a target for a view accessor, correct? (Otherwise you'll have to be more explicit about what you mean by "Query LOV".
    If I'm right, there are two possibilities:
    1) You are using a VO instance in a shared application module instance. If so, make sure your code is in the prepareSession() for that application module class if it's session dependent (as it seems to be below), you need to make sure the application module instance is shared at session scope.
    2) You've based the view accessor directly on the VO definition. This basically creates an anonymous VO instance; I don't think there's any way to use prepareSession() to set a bind variable on such an instance (which won't be created until the accessor is first used). You might be able to get by with putting similar code into the view object class' create() method, but I haven't tested this.
    If your code is in your primary application module class (as opposed to the class for a shared AM instance), the problem here is that getCmProcessView() returns the VO instance from that application module instance's design-time data model, which is never used by view accessors.
    By the way, why do you need to do this in prepareSession() instead of at the view accessor level? I believe you can get the logged in user name (for the view accessor) in with the groovy expression
    viewObject.DBTransaction.session.userPrincipalName
    or possibly just
    DBTransaction.session.userPrincipalName
    (despite this involving DBTransaction, it returns the web app user name, not the DB username).
    That's a 100% declarative solution, if you don't count the Groovy expression as non-declarative.
    If you're afraid of a user executing the LOV (somehow) before the bind variable value gets set, just ensure that the bind variable is marked "required".

  • Use of Bind Variable in the Query of view object giving null pointer excep

    I am using this code in the backing bean of my page to set the value of the bind variable 'cmdID' in the view object.
    String AM = "model.UnixCommandsAppMod";
    String CF = "UnixCommandsAppModLocal";
    ApplicationModule am = Configuration.createRootApplicationModule(AM, CF);
    ViewObject vo = am.findViewObject("Command_options_view");
    vo.setNamedWhereClauseParam("cmdID", 1);
    vo.executeQuery();
    On the fifth line it is giving NullPointer exception.
    I am not being able to figure out the reason.

    User,
    a). Don't keep posting new questions in the same thread. It really does decrease the usability of the forum. Now, if someone searches for "INFO: ADF Faces is running with time-stamp checking enabled," they will find a post about null pointer exception in a bind variable and think, "oh, that doesn't apply to me." If your question is answered, mark the answer as correct. New questions go into a new thread. Kind of funny that the thread I pointed you to with the answer to your question also has this same admonishment.. ;)
    b). I'll relent and answer your new question. Ignore that INFO message. It is not an error. It will ALWAYS ALWAYS appear when you run your application in the embedded OC4J with JDeveloper. Had you searched the forum for "INFO: ADF Faces is running with time-stamp checking enabled" you would find that the first hit (among some others) has this same answer
    John

  • Binding variable to inner query in a VO

    Hi All,
    I am using ADF 11g. How do I bind the variables for :1,:2,:3 in the Query below:
    select max(trim_qty),max(vhead_qty),max(cill_qty),max(coupler_qty),max(wboard_qty),max(baycill_qty),max(baypole_qty)
    from +(select pd.production_date as production_date ,pd.load_no as load_no,pdi.reference_id as reference_id,pdi.item_type,pdi.piece_qty,pd.dispatch_id,pdi.package_type,pdi.type_seq,+
    decode(pdi.type_seq,0,(DECODE(pdi.item_type, 'TRIM' , pdi.piece_qty, 0)),
    +(DECODE(pdi.package_type , 'TRIM',pdi.type_seq,0))) trim_qty,+
    decode(pdi.type_seq,0,(DECODE(pdi.item_type, 'VHEAD' , pdi.piece_qty, 0)),
    +(DECODE(pdi.package_type , 'VHEAD',pdi.type_seq,0))) vhead_qty,+
    decode(pdi.type_seq,0,(DECODE(pdi.item_type, 'CILL' , pdi.piece_qty, 0)),
    +(DECODE(pdi.package_type , 'CILL',pdi.type_seq,0))) cill_qty,+
    decode(pdi.type_seq,0,(DECODE(pdi.item_type, 'COUPLER' , pdi.piece_qty, 0)),
    +(DECODE(pdi.package_type , 'COUPLER',pdi.type_seq,0))) coupler_qty,+
    decode(pdi.type_seq,0,(DECODE(pdi.item_type, 'WBOARD' , pdi.piece_qty, 0)),
    +(DECODE(pdi.package_type , 'WBOARD',pdi.type_seq,0))) wboard_qty,+
    decode(pdi.type_seq,0,(DECODE(pdi.item_type, 'BAYCILL' , pdi.piece_qty, 0)),
    +(DECODE(pdi.package_type , 'BAYCILL',pdi.type_seq,0))) baycill_qty,+
    decode(pdi.type_seq,0,(DECODE(pdi.item_type, 'BAYPOLE' , pdi.piece_qty, 0)),
    +(DECODE(pdi.package_type , 'BAYPOLE',pdi.type_seq,0))) baypole_qty+
    from pt_dispatch pd, pt_dispatch_item pdi
    where pdi.dispatch_id = pd.dispatch_id
    and production_date = :1 and load_no = :2 and reference_id = :3+
    and ((pdi.item_type in ('TRIM','VHEAD','CILL','COUPLER','WBOARD','BAYCILL','BAYPOLE') and pdi.type_seq = 0)
    or (pdi.package_type  in ('TRIM','VHEAD','CILL','COUPLER','WBOARD','BAYCILL','BAYPOLE') and pdi.type_seq > 0)))
    Thanks and Regards,
    Senthil

    You can drag the executeWithParams over to a page to create parameter form and fill out the values.
    http://www.oracle.com/technology/products/jdev/tips/muench/screencasts/threesearchpages/threesearchforms_partthree.html?_template=/ocom/technology/content/print

  • Creating graphs with bind variables in series query

    I am creating a page with 2 regions for for getting date range and other for getting Graph drawn on the basis of dates. But when I am using dates values like some field>=:PX_DAT1 the series doesn't work and gives data not found error.
    Some guru please help.

    Gaurav Bhargava wrote:
    What I want is use dates in query to fetch data for graph. Please if you have a demo page where I can see settings and create such page.Sorry, I havent really done much with the graphs in Apex - so dont have a sample to try out, was just trying to think of ideas. Is it XML? Maybe try putting the parameter in the alternative syntax &ITEM_TIME. (with the period at the end.)

  • Query with bind variable, how can use it in managed bean ?

    Hi
    I create query with bind variable (BindControlTextValue), this query return description of value that i set in BindControlTextValue variable, how can i use this query in managed bean? I need to set this value in String parameter in managed bean.
    Thanks

    Put the query in a VO and execute it the usual way.
    If you need to, you can write a parameterized method in VOImpl that executes the VO query with the parameter and then call that method from the UI (as a methodAction binding) either through the managed bean or via a direct button click on the page.

  • How to use bind variables in "query result" "validation rule"

    I have created a validation rule on my entity object. rules=compareValidator attribute=InvoiceNumber operator=NotEquals queryResult=SELECT ...
    In this query, I would like to reference entity attributes from the current instance of the entity when the value fires, for example SELECT invoice_number where invoice_id != :invoiceId
    How can I reference a bind variable inside the query result compare validator validation rule?
    THanks,
    Jerry.

    bump

  • How to bind local variables in complex query in PL/SQL

    Hi
    I have long complex query with local varibales; when I run in Dynamic SQL I get an error. Not sure which is the easiest way to bind local variables.
    L_QUERY := q'[select m.segment1 col1,
          '1' col2,
          '13' col3,
          l.operand col4,
          0 col5,
           'Y' col8,
          'N' col9,
          'N' col10,
       decode(h.name,'09_UKOR_*','EOS Credit','10_UKOR_*','TopUp','11_UKOR_*','Main') col18
    from qp_list_headers_v h,
          qp_list_lines_v l,
          mtl_system_items m
    where h.name in ('09_UKOR_*','10_UKOR_*','11_UKOR_*')
    and h.list_header_id = l.list_header_id
    and m.inventory_item_id = l.product_attr_value
    and m.organization_id  = 84
    UNION all
    SELECT qs.PRODUCT_ATTR_VALUE col1,
           hca.account_number col2,
           decode (su.site_use_code,'BILL_TO','21','SHIP_TO','18') col3,
           0 col4,
           qs.operand col5,
           null col6,
           null col7,
           'N' col8,
           'Y' col9,
           'N' col10,     
    --Local variables
          (case when (trunc(nvl(qq.start_date_active,sysdate)) between l_cur_year_from  and l_cur_year_to) and  
                      ( trunc(nvl(qq.end_date_active,l_cur_year_to)) >= trunc(l_cur_year_to) )  then    'TopUp'
                when (trunc(qq.start_date_active) between l_next_year_from  and l_next_year_to) and  
                      ( trunc(nvl(qq.end_date_active,l_next_year_to)) >= l_next_year_to)  then   'Main'              
                when (trunc(qq.start_date_active) between l_last_year_from  and l_last_year_to) and  
                      ( trunc(nvl(qq.end_date_active,l_last_year_to)) >= l_last_year_to )  then  'EOS Return'
           end )col18,
    --Local variables
           (case   when (trunc(qq.start_date_active) between l_next_year_from  and l_next_year_to) and  
                      ( trunc(nvl(qq.end_date_active,l_next_year_to)) >= l_cur_year_to )  then   'N'
              else
                    'Y'  end ) col21
       FROM qp.qp_list_headers_b qlhb,
            qp.qp_list_headers_tl qlht,
            qp.qp_qualifiers qq,
            qp_modifier_summary_v qs,
            hz_cust_site_uses_all su,
            hz_cust_acct_sites_all  sa,
            hz_cust_accounts hca
    WHERE 1=1
          and qlhb.LIST_TYPE_CODE       = 'DLT'
          and nvl(qlhb.active_flag,'Y') = 'Y'
          and qlhb.list_header_id       = qlht.list_header_id
          AND qq.list_header_id         = qlhb.list_header_id
          and qq.list_type_code         = qlhb.LIST_TYPE_CODE
          and qq.QUALIFIER_CONTEXT      = 'CUSTOMER'
          and qs.list_header_id         = qlhb.list_header_id
          and qs.LIST_LINE_TYPE_CODE    = 'DIS'
          and su.site_use_id            = qq.qualifier_attr_value --1064
          AND  su.cust_acct_site_id     = sa.cust_acct_site_id
          AND  sa.cust_account_id       = hca.cust_account_id ]';
    --call Dynamic SQL function
    l_cursor := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(l_cursor, p_QUERY , DBMS_SQL.NATIVE);
    l_rows := DBMS_SQL.EXECUTE(l_cursor);
    Any help will be much appreciated.
    iI guess I should use DBMS_SQL.BIND_VARIABLE to bind all variables seperately so not to mess with query

    1) What is the error you get?
    2) If you use bind variables inside a query, you should prefix them with colons, so use :l_cur_year_from etc.
    3) Why are you using dbms_sql instead of native dynamic sql and/or ref-cursors?
    Toon

  • Using Bind Variables in Parameter Form's Query

    I want to use bind variables in the query of Parameter form. But
    it does not allows. What is the other way out. The structure of
    my Parameter form is as under:
    State:
    Customer:
    Now I want that I want to list only those customer in the
    Customer LOV which belongs to the selected state.
    Thanks.
    Muhammad Nadeem

    Can we just link to an oracle form using a url still as we can with reports? I've built a report that requires the user to select from a dynamic list as well, and I know how to do this through forms, but can I simply call the form from a webpage?

  • Collection with bind variable

    Hello all,
    this might be more of a pl sql question but I am trying to create a collection in apex where the query uses a bind variable. I cannot get this query to work.
    This works
    p_query => 'select je_batch_id from gl_je_batches where default_period_name = ''MAY-10''',
    but I cannot get it to work with a bind variable.
    p_query => 'select je_batch_id from gl_je_batches where default_period_name = :P14_EPSB_ARGYLL_PERIODS ||',
    any assistance would be greatly appreciated.
    Thanks

    For the record, the APEX_COLLECTION package in Application Express 4.0 now does support bind variables in the query.
    APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY_B and APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERYB2 support an input array of bind variable names and bind variable values. This should be faster than referencing an item value via the v() function. However, prior to APEX 4.0, this is the only recourse.
    Joel

Maybe you are looking for

  • Screen output without connection to user., error key: RFC_ERROR_SYSTEM_FAIL

    Good Afternoon, I have the following issue in the moment of update the data in the Employee Self-Service - >Personal Information----->Addresses, with a user at the moment of save the data the portal display the following message of dump A critical er

  • Report that gives me details using my Purchase Order number

    Dear Gurus, Could you please tell me is there any report,where if i give the P.O.number it should list all the related items to the P.O. Provided i give the p.o number as the reference in all the invoices. Thanks and Regards Balaji Dhanavel

  • TPVS Delivery problem

    Hi We have a problem in TPVS. Eventhough there is sufficient stock, delivery generations is not done, inspite giving message "delivery quantity is not fully available". Can any one help in this? Is this the problem with timing of the activities in R3

  • Is my ipad 2 locked after putting in a sim card

    Bought an ipad 2 from apple and last year put in a ee sim pay as you go. Now want to sell the ipad  will it be locked now

  • My Tamron 10-24 is listed as Unknown Lens

    Any way to fix this? Details are: Lightroom version: 5.3 [938183] Operating system: Windows 8 Business Edition Version: 6.2 [9200] Application architecture: x64 System architecture: x64 Camera Pentax K5 WIth latest Firmware 1.16 Shooting Format - DNG