Bind variable issue in Package Body

When I try to compile my package body, I get an error on the variables declared within the procedure. Bind variable not allowed. Any thoughts?

Apparently the error was related to something else, and the message was mis-leading. When I re-structured the code for other reasons, the 'error' was no longer showing up. Sorry for the confusion.

Similar Messages

  • Bind variable inside a package

    Can we declare a bind variable inside a package specification?
    CREATE OR REPLACE PACKAGE GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE);
    VARIABLE O VARCHAR2(20);
    END GET_EMPLOYEEDETAILS ;
    CREATE OR REPLACE PACKAGE BODY GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE)
    IS
    BEGIN
    SELECT FIRST_NAME INTO F_NAME FROM EMPLOYEES WHERE EMPLOYEE_ID = E_ID;
    DBMS_OUTPUT.PUT_LINE(F_NAME);
    END;
    END GET_EMPLOYEEDETAILS;
    Output:
    ERROR at line 4: PLS-00103: Encountered the symbol "VARCHAR2" when expecting one of the following:
      := . ( @ % ; not null range default character
    The symbol ":=" was substituted for "VARCHAR2" to continue.
    2. IS
    3. PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE);
    4. VARIABLE O VARCHAR2(20);
    5. END GET_EMPLOYEEDETAILS ;
    6. /
    or is there any alternative for bind variables inside an package
    Thanks in advance
    Message was edited by: 1009739

    The "VARIABLE O VARCHAR2(20);" syntax is the way SQLPlus declared bind variables - it is specific to the client. Because PL/SQL packages and procedures are server code that continue past sessions, its only access to the client environment is what the client gives it - it can't go and create a bind variable in the client.
    PL/SQL procedures, functions and packages run from lots of environments, so they cannot access bind variables inside their body - you have to pass any external variables as parameters.
    Anonymous PL/SQL blocks can access bind variables.
    You can declare package public global variables - just leave out that "VARIABLE". E.g.
    CREATE OR REPLACE PACKAGE GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMP.EMPNO%TYPE, F_NAME OUT EMP.ENAME%TYPE);
    O VARCHAR2(20);
    END GET_EMPLOYEEDETAILS ;
    For local variables in your procedure, just put them between the IS and BEGIN. Using them in SQL inside the PL/SQL automatically uses them as a bind variable.
    create or replace PROCEDURE GET_FIRSTNAME(E_ID IN EMP.EMPNO%TYPE, F_NAME OUT EMP.ENAME%TYPE)
    IS
      O VARCHAR2(20);
      O2 VARCHAR2(21);
    BEGIN
      O := 'FR%';
    SELECT ENAME INTO F_NAME FROM EMP WHERE EMPNO = E_ID and ENAME like O;
    O2 := F_NAME || '2';
    DBMS_OUTPUT.PUT_LINE(F_NAME);
    END;
    O is bound in the query.
    To access bind variables from anonymous PL/SQL, first declare them in the calling environment. In SQL Plus that's
    VARIABLE O VARCHAR2(20);
    In Pro*C it's
    EXEC SQL BEGIN DECLARE SECTION;
      char[21] O
    EXEC SQL END DECLARE SECTION;
    Then reference it in anonymous PL/SQL with a colon as prefix:
    BEGIN
    SELECT FIRST_NAME INTO :O FROM EMPLOYEES WHERE EMPLOYEE_ID = E_ID;
    END;
    This only works for anonymous blocks (starting with BEGIN or DECLARE). As I said, PL/SQL procedures, functions and packages cannot see bind variables from the calling environment

  • Parameter error - bad bind variable in a Package..!!

    Hello All
    i am tring to create a security package with in one procedure i am trying to handle the number of times the user enters the wrong user name or password:
    -i created a parameter on my login form and add it to my procedure and it works just fine,But when i tried to copy the same procedure the package inside my library can't recognize that Parameter.
    -It gives me error : bad bind variable.
    The code is as follows.
    PARAMETER.COUNT := :PARAMETER.COUNT + 1;
    IF :PARAMETER.COUNT > 3 THEN
    WRONG_ALERT('WRONG_PASS',' ur number of trials has expiered the form will be closed ');
    EXIT_FORM;
    END IF;
    Can anyboady help me pls.
    Regards,
    Abdetu.

    Super,It works Just fine.
    Thanks Gerd,
    That's make me decide that if i have the following statatment for example:
    IF :USER_CODE IS NULL THEN .........
    I have to change it to :
    IF copy (name_in ('USER_CODE' )) IS NULL THEN..........
    But,if i have the following select statment :
    ==============================
         SELECT USER_CODE , USER_PASS WORD
         INTO :GLOBAL.USER_CODE , :GLOBAL.USER_PASS WORD
         FROM APP_USERS
         WHERE USER_CODE = :USER_CODE
         AND USER_PASS WORD= :USER_PASS WORD;
    Should i transfer it to the following:
    =========================
    SELECT USER_CODE , USER_PASS WORD
    INTO     COPY(NAME_IN ('GLOBAL.usr_code'), COPY(NAME_IN ('GLOBAL.PASSWORD')
    FROM APP_USERS
         WHERE USER_CODE = COPY(NAME_IN ('USER_CODE' )
    AND USER_PASS WORD=COPY(NAME_IN ('USER_PASS WORD');
    Pls help me,it's my first time ...
    Thanks in advance.
    Regards,
    Abdetu.

  • SOLVED -Newbie with Bind Variable Issue in Data template

    My XML output looks the way I want it structure-wise, but the data is the same for each group. Obviously my bind variable never gets updated. How can this be achieved? Here are the dataquery and data structure parts of my template:
    <dataQuery>
              <sqlStatement name="Q1">
              SELECT DISTINCT trans_id FROM table1
    </sqlStatement>
              <sqlStatement name="Q2">
                   <![CDATA[SELECT * from table1 WHERE report_type = 'invoice' and record_type = 'HEADER' AND trans_id = :trans_id]]>
              </sqlStatement>
              <sqlStatement name="Q3">
                   <![CDATA[SELECT * from table1 where report_type = 'invoice' and record_type = 'LINE'  AND trans_id = :trans_id]]>
              </sqlStatement>
              <sqlStatement name="Q4">
                   <![CDATA[SELECT * from table1 where report_type = 'PSA_INV' and record_type = 'FOOTER'  AND trans_id = :trans_id]]>
              </sqlStatement>
         </dataQuery>
    <dataStructure>
    <group name="ONE" source="Q1" groupFilter="">
                   <element name="trans_id" value="trans_id" function=""/>
                   <group name="HEADER" source="Q2" groupFilter="">
                        <element name="Direct_Inquiries_To" value="ATT1" function=""/>
                        <element name="Tax_Id" value="ATT2" function=""/>
                        <element name="Bill_To_Address_Line1" value="ATT3" function=""/>
                        <element name="Bill_To_Address_Line2" value="ATT4" function=""/>
                        <element name="Bill_To_Address_Line3" value="ATT5" function=""/>
                        <element name="Bill_To_Address_Line4" value="ATT6" function=""/>
                        <element name="Bill_To_Address_Line5" value="ATT7" function=""/>
                   </group>
                   <group name="LINE" source="Q3" groupFilter="">
                        <element name="Line_No" value="ATT1" function=""/>
                        <element name="Desc_Line1" value="ATT2" function=""/>
                        <element name="Amount" value="ATT3" function=""/>
                        <element name="Desc_Line2" value="ATT4" function=""/>
                        <element name="Amount_Line2" value="ATT5" function=""/>
                                       </group>
                   <group name="FOOTER" source="Q4" groupFilter="">
                        <element name="Sub_Total" value="ATT1" function=""/>
                        <element name="Taxes" value="ATT2" function=""/>
                        <element name="Net_Amount" value="ATT3" function=""/>
              </group>
         </group>
    </dataStructure>
    I have 2 possible transids
    The transid gets updated in the 1st group , but the rest of the data is the same as the first trans_id.
    Message was edited by:
    user647407

    "What do you mean by 'Obviously my bind variable never gets updated' - are the sub queries not getting the trans_id from the first query ?"
    yes, that would appear to be the case. It only gets one value of the transid. To put it in a better perspective, I'll compare it to the Employee example in the user's guide. My Depts would all come out fine. But Dept 10, 20, etc would all show the employee data for dept 10 only.

  • View Link Bind variable issue

    All,
    I have a view link defined which and both the VO are part of my AM.
    At run time i am supposed to get the list of notes for a particular line. (the view link establishes this connection). However when i run my application i am not getting any records. Below SQL is getting fired for each request
    SELECT * FROM (SELECT note_type_meaning, note_status_meaning, creation_date, created_by_name,
           notes, row_id, jtf_note_id, notes_detail_size, entered_by,
           source_object_id, source_object_code, note_type, note_status, CONTEXT,
           attribute1, attribute2, attribute3, attribute4, attribute5, attribute6,
           attribute7, attribute8, attribute9, attribute10, attribute11,
           attribute12, attribute13, attribute14, attribute15, created_by,
           entered_date, last_updated_by, last_update_date, last_update_login
      FROM apps.ast_notes_details_vl
    WHERE source_object_id = :bLeadNumber) QRSLT  WHERE SOURCE_OBJECT_CODE = :Bind_LeadNumber
    <logQueryStatementAndBindParameters> BindVars:(bLeadNumber=null,Bind_LeadNumber=23040400)OK, the above sql is used to get the count but i am a bit lost as to why the bind variable is taking value at only one place.
    Please advise
    Jdev 11.1.1.5

    Sorry for this stupid post.

  • Bind Variable Not Being Reset

    I am using JDeveloper 11.1.1.2 and ADF with BC. I have the following situation:
    I have a view object whose where clause has multiple bind variables. On one of my pages, I dragged this view object as a form onto the page. I also dragged the ExecuteWithParams method for this view object onto my page as a command button. I dynamically set the bind variables for this action via EL-based NamedData elements. When I click the button, the query is run with the bind variables I specify. Everything looks great.
    On another page, I am programmatically setting one of the bind variables (let's call it bv1) for the same view object and then navigating to the page described above. The data displays fine. However, when I try to use the command button (ExecuteWithParams) with a different value for bv1, the query continues to use the value that I set programmatically.
    It seems like the bind variable value set programmatically (using vo.setNamedWhereClauseParam) always trumps the one that gets set using the NamedData element in ExecuteWithParams. Why doesn't this value get reset with the value from the NamedData element?
    Thanks,
    Brad

    hi Brad
    ... It seems as if once the bind variable gets set on the view object programatically, the corresponding parameter in ExecuteWithParams does not overwrite it. ...Looks similar to the behaviour I describe in forum thread forum thread "10g versus 11g : bind variable issue"
    at 10g versus 11g : bind variable issue
    regards
    Jan Vervecken

  • Variable scope in package

    I have some procedures in a package that need almost the same type of variables. Now, lets say I put them in the package spec in the private variable declaration part so that all the procedures use the same variables instead of declaring them inside all procedures. Now, if someone is executing those procs simultaneously will Oracle Oracle create a separate instance of those variables or use the same copy of the variables for all the simultaneously executing procedures?
    Also, is it a good practise to put these variables in the package body section so that they become public?

    another question!
    is it advisable to put some kind of driver proc in the package such that its job is just to invoke other procs of the package when called like:
    create or replace package body mypack is
    procedure proc proc_main(params) is
    begin
    proc1(params); --invoke other procs
    proc2(params);
    procn(params);
    end ;--end of proc
    --package initialization section
    begin
    proc_main(params);
    end; --end of package                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Sdo_geometry bind variables in trace file

    If I run trace on oracle spatial queries, how can I get the detailed information of the sdo_geometry objects (the content of the sdo_geometry objects, e.g. coordinates... ) in the queries?
    Thanks!

    Hi Rob
    Haven't checked the bind variable issue specifically here, but just a by-pass-reflex-of-fixed-implementations, have you tried passing the geometry as WKT?
    Obviously, this can also have some constraints on the varchar2 length etc, but depending on the type of geometries (and consequent length of the WKT) it might help you working around it.
    Check this section for the appropriate sdo_geometry constructor based on a WKT input.
    http://docs.oracle.com/cd/B19306_01/appdev.102/b14255/sdo_objrelschema.htm#CBBFGHAE
    Just a thought
    Luc

  • How to declare bind variable in package

    hi,
    i have created one package with insert and returning the value in procedure using bind variable.
    -- spec part.
    SET SERVEROUTPUT ON
    VARIABLE id NUMBER
    CREATE OR REPLACE PACKAGE pack_sale AS
    PROCEDURE pro_insert_SOHeader (
    SO_HEADER_ID NUMBER,
    SO_NO VARCHAR2,
    SO_TYPE VARCHAR2,
    SO_APPROVED_FLAG VARCHAR2,
    SO_DATE DATE,
    CUST_HEADER_ID NUMBER);
    END pack_sale;
    -- body part
    CREATE OR REPLACE PACKAGE BODY pack_sale AS
    PROCEDURE pro_insert_SOHeader (
    SO_HEADER_ID NUMBER,
    SO_NO VARCHAR2,
    SO_TYPE VARCHAR2,
    SO_APPROVED_FLAG VARCHAR2,
    SO_DATE DATE,
    CUST_HEADER_ID NUMBER) IS
    BEGIN
    INSERT INTO SO_Header VALUES (SEQ_SOHEADER.NEXTVAL,SO_NO,SO_TYPE,SO_APPROVED_FLAG,SO_DATE,CUST_HEADER_ID)
    RETURNING SEQ_SOHEADER.CURRVAL INTO :id;
    COMMIT;
    END pro_insert_SOHeader;
    END pack_sale;
    I have run this package in sql*plus,it will return the warning message like
    PLS-00049: bad bind variable 'ID'.
    i do not know how to rectify this error
    and how to execute this procedure in sql*plus.
    please help me...

    hi,
    when i was running the body script the error is displayed in
    sql*plus like
    SQL> @"D:\Viji Share\ex_body"
    SP2-0042: unknown command "" - rest of line ignored.
    15 /
    Warning: Package Body created with compilation errors.
    SQL> show error
    Errors for PACKAGE BODY PACK_SALE:
    LINE/COL ERROR
    11/30 PLS-00049: bad bind variable 'ID'

  • Having issues with bind variable refcursor

    Hi,
    I have a procedure which returns just the list of employees from the emp table.
    while executing this package, it gives me an error
    Ex:
    sql> variable cur refcursor;
    sql> exec emp.getemplist(:cur);
    error:
    not all variables bound
    Please let me know what is wrong here.
    Thanks
    Manju

    manjukn wrote:
    package is a simple one..
    Exact Oracle version? Works fine on 10.2.0.4.0:
    SQL> create or replace package body emp_pkg is
      2  PROCEDURE getemplist (result_cursor OUT sys_refcursor)
      3  IS
      4  begin
      5  open result_cursor for select * from emp where deptno=10;
      6  end getemplist;
      7  end emp_pkg;
      8  /
    Package body created.
    SQL> variable cur refcursor;
    SQL> exec emp_pkg.getemplist(:cur);
    PL/SQL procedure successfully completed.
    SQL> print cur
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    SQL> SY.

  • Issue with viewing Package Body  in SQL Developer 2.1 RC1

    Were anybody able to see the package body of other user in 2.1 RC1.
    I had an issue since 2.1 EA 1 so... just curious.
    - Oracle 9i
    - Windows XP SP3
    Please do let me know if there is any hint or setting that can be change to view the package body.
    Thanks!

    Thanks for your msg.
    Below is the info:
    1.
    SQL: SELECT * FROM v$version;
    Result:
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
    PL/SQL Release 9.2.0.8.0 - Production
    "CORE     9.2.0.8.0     Production"
    TNS for Solaris: Version 9.2.0.8.0 - Production
    NLSRTL Version 9.2.0.8.0 - Production
    2.
    Result:
    The account has 'EXECUTE' privilege on the package.
    3.
    SQL: SELECT username "User"
    ,granted_role "Granted_Role"
    ,initcap(admin_option) "Admin_Option"
    ,initcap(default_role) "Default_Role"
    FROM user_role_privs
    ORDER BY username
    ,granted_role;
    Result:
    User``````````Granted_Role```````````Admin_Option``Default_Role
    ~~~~ ~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~
    USER_NAME```SELECT_CATALOG_ROLE``No````````````Yes
    4.
    SQL:
    SELECT privilege "Privilege"
    ,initcap(admin_option) "Admin_Option"
    FROM user_sys_privs
    ORDER BY privilege;
    Result:
    Privilege````````````Admin_Option
    ~~~~~~ ~~~~~~~~~
    ALTER SESSION`````No
    CREATE SESSION````No
    CREATE SYNONYM```No

  • && Substitution Variable in Package Body using SQL Developer

    Hi Folks,
    I've moved over to working to in SQL Developer (its a very early version - 1.0.0) from a combination of SQL*Plus command line and a text editor. I'm trying to get this upgrgraded, but I think the question will be the same with a newer version anyway.
    I am creating a package, and in the package body I have some &&my_var substitutions that I was previoulsy prompted for when calling the .sql from the command line SQL*Plus. I need this as the variable needs to be different for the development and live environment.
    When working in SQL Developer, I can load the package body from Connection->Packages->My Package->My Package Body, and click the edit button to edit the code, however, when I click the Compile button in the top of the window my code error's because of the substituion variablle. An example is:
    CREATE OR REPLACE
    PACKAGE BODY MY_PACKAGE AS
    PROCEDURE MY_PROCEDURE
    BEGIN
    my_variable := &&my_function_from_live_or_dev_database
    END MY_PROCEDURE
    Can anyone tell me if there is a way of defining a compiler variable within the IDE widow while editing a package body stored in the database, without manually copying the code into the Worksheet and running it as a script?
    Thanks,
    AM

    953104 wrote:
    Thanks for the reply, the code was just quickly typed to show the sort of thing I am doing, it wasn't actual code form my project.
    I've come from a C background so what I would have done would be create a #define and changed to when on live or development - or passed the variable to the build environment from the IDE or makefiles and the change would have reflected through my whole project.
    What I want to be able to do is alter a definition of some sort that will reflect throughout my whole project, so I can change it in one location to minimize code changes before going live. I don't really want to be prompted at all. On one system it needs to be DEV_10 and on the other it needs to be LIVE_10.Is there a possibility to elimiante this difference at all?
    For example if DEV_10 is the oracle schemauser on the development database and LIVE_10 would be the one on the production system. THen you could just remove all references to the schema from your code.
    IF you are already connected to this schema, then you don't need to specify the schema name anymore.
    example
    instead of
    create or replace package dev_10.myPackage
    ...you can simply use
    create or replace package myPackage
    ...If needed you can alter the cuurently connected user just before you run the script.
    alter session set current_schema = LIVE10;
    create or replace package myPackage
    ...This would be a different working window in the developer (script worksheet, instead of direct pl/sql editor).
    Substitution variables are allowed there.

  • ERROR: Package deleted because of bad bind-variable

    hello,
    i believe to have a serious problem here and i need help. portal deleted packages twice because of a "bad bind variable" so i had to start over again.
    i'm trying to write a simple blackboard-application. Users can post and read posts. No answers, no threads
    This is the structure:
    Tables: categories with cat_id,cat_name
    posts with post_id,cat_id, date,user_id,title,content
    Reports for list of categories and list of posts in a certain category
    Link from category-name to list of posts in category
    This link uses :cat_id as passed parameter from category-list to list of posts
    The list of posts has this select-statement:
    SELECT post_id,cat_id,date,user_id,title
    FROM schemaname.posts
    WHERE cat_id = :cat_id;
    So far everything works fine
    Now i want to customize the look of the report. On the "Report and Customization Form Text"-Tab I wrote some html-code into the header-field. Then i tried to include a select statement to print the category-name. But everything i wrote between the <oracle></oracle>-tags was displayed as code and not parsed. So i next tried to put a select-statement into the "after header displayed"-field on the "additional PL/SQL Code"-Tab.
    This is what i wrote:
    declare
    cat varchar2(20);
    begin
    SELECT cat_name into cat
    FROM schemaname.categories
    WHERE cat_id = :cat_id;
    end;
    When i now run the report i get a 4-page error-message saying package was deleted and that i used a bad bind-variable.
    Can somebody please help?
    we use portal 30982 on 9i database and windows 2000
    Thank you very much
    Ralf Schmitt

    Hi,
    You cannot use bind variable in the additional plsql section. If you want to access the value of :cat_id then you should
    pick it up from p_arg_names and p_arg_values.
    In the additional plsql code "after header displayed"-
    declare
    cat_nm varchar2(50);
    begin
    for i in 1..p_arg_names.count
    loop
    if p_arg_names(i) = 'cat_id' then
    SELECT cat_name into cat
    FROM schemaname.categories
    WHERE cat_id = p_arg_values(i);
    exit;
    end if;
    end loop;
    htp.p('Cateegory :' ||cat_nm);
    end;
    Thanks,
    Sharmila

  • Bind Variables with AND in String causing Issues in XML & Report Outputs

    Hi all,
    I'm creating a BI Publisher report (10.1.3.2) and am experiencing an issue with the interprutation of Bind Variables in the Data Template.
    Here is an example of some of the Data template
    <dataTemplate name="BudgetDataBU" description="BudgetDataBU" dataSourceRef="DLXN">
       <parameters> 
          <parameter name="p_Year" dataType="Integer" include_in_output="true"/>
          <parameter name="p_Measure" dataType="character" include_in_output="true"/>
          <parameter name="p_Currency" dataType="character" include_in_output="true"/>
          <parameter name="p_Version" dataType="character" include_in_output="true"/>
       </parameters>
       <dataQuery>
          <sqlStatement name="BusUnits">
               <![CDATA[SELECT DISTINCT CC.BUSINESS_UNIT as BUSINESS_UNIT
                        FROM   DLXN_FACT_DATA_DET FD,
                               DLXN.COST_CENTRE CC
                        WHERE FD.COST_CENTRE = CC.COST_CENTRE
                        AND FD.CAL_YEAR    = :p_Year
                        AND FD.Currency      = :p_Currency
                        AND FD.Measure      = :p_Measure
                        AND FD.Version        = :p_Version                                
                        AND CC.DLXN_VIEW = 'Delexian' ]]>
               </sqlStatement>
           <sqlStatement name="Details">
               <![CDATA[SELECT DLXN_FACT_DATA_DET.VERSION,
                               DLXN_FACT_DATA_DET.CURRENCY,
                               DLXN_FACT_DATA_DET.CAL_YEAR as CAL_YEAR,
                               SUM(nvl(DLXN_FACT_DATA_DET.JAN_AMT,0)) as JAN_AMT,
            </sqlStatement>
        </dataQuery>The problem is with the :p_Measure Bind Variable but it could just as easily be any of the other character parameters.
    The particular string value that is causing a problem is "Travel and Expenditure". I believe it is due to the "AND" in the string but this string value cannot be changed in the database to say "Travel & Expenditure".
    I have thought about using a REPLACE function in the SELECT statement but see this as an ugly solution.
    Any input greatly appreciated.
    Kind Regards,
    Gary.

    We remove this restriction ,fix included in BI Publisher July 2009 update for 10.1.3.4.x. The patch number is 8704846.

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

Maybe you are looking for