Null global variable in block's WHERE clause - no records?

I'm setting a :GLOBAL.emp_id in certain spots in my form. The EMPLOYEE block's WHERE clause says emp_id = :GLOBAL.emp_id. In the POST-QUERY, it sets that variable back to NULL so the next time they want to run a blind query, it will show all records.
Well when the :GLOBAL.emp_id is NULL, nothing comes up in a blind query. I even changed the WHERE clause to say emp_id = NVL(:GLOBAL.emp_id,'') but that didn't do anything either.
How can I get the WHERE clause to (basically) do nothing when that global variable is null? Or should I be messing with DEFAULT_WHERE instead of these global variables
I'm in 6i

I'm sorry - I stumbled on something soon after I posted and changed it to:
emp_id = NVL(:GLOBAL.emp_id,emp_id)
and it worked - duh

Similar Messages

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

  • How to populate bind variable in view objects where clause in ADF faces

    I've got a page with 2 input items.
    The user manually enters the first value.
    On the second input item I have created a LOV for the item which opens in a popup. How do I restrict the data returned in the LOV using the value entered in the first input item. I have created a bind variable and have included it in the where clause for the view object but how do I populated it.

    Here is an example:
    Using the HR schema with the EMPLOYEES and DEPARTMENTS tables.
    Example is using ADF BC and created an EMPLOYEES entity with an updateable view object for page,
    and created a DEPARTMENTS view as a lookup
    (SQL: select department_id, department_name from departments where department_name = :DeptName)
    1: add method to the backing bean to filter the LOV
    public void getTextValueToFilterLOV(ValueChangeEvent valueChangeEvent) {
    Object value_from_form = valueChangeEvent.getNewValue();
    FacesContext fctx = FacesContext.getCurrentInstance();
    Application fapp = fctx.getApplication();
    JUFormBinding formBinding = (JUFormBinding)fapp.createValueBinding("#{bindings}").getValue(fctx);
    DCIteratorBinding dcBinding = (DCIteratorBinding)formBinding.get("DeptLOVIterator");
    ViewObject vo = dcBinding.getViewObject();
    vo.setNamedWhereClauseParam("DeptName",value_from_form);
    vo.executeQuery();
    2. add valueChangeListener to the inputText on the page with an id and autoSubmit="true"
    <af:inputText value="#{bindings.LastName.inputValue}" label="#{bindings.LastName.label}" binding="#{backing_DeptForm.inputText3}"
    id="inputText3"
    autoSubmit="true"
    valueChangeListener="#{backing_DeptForm.getTextValueToFilterLOV}">
    </af:inputText>
    3. reference the LOV with the id name on the partialTriggers property
    <af:selectOneChoice value="#{bindings.EmployeesUpdView1DepartmentId.inputValue}"
    label="#{bindings.EmployeesUpdView1DepartmentId.label}" binding="#{backing_DeptForm.selectOneChoice1}"
    id="selectOneChoice1"
    partialTriggers="inputText3">
    <f:selectItems value="#{bindings.EmployeesUpdView1DepartmentId.items}"
    binding="#{backing_DeptForm.selectItems1}"
    id="selectItems1"/>
    </af:selectOneChoice>
    Summary:
    When you entered a text (LastName), that value is passed into the backing bean method.
    The Bean method code will find the LOV Iterator and put the value into the bind variable.
    Cheers,
    Jim

  • Problem with DECODE block in WHERE clause

    Hi,
    I'm facing problem with DECODE statement. I just simulated my problem in the simple way as follows. If I execute this following query, I should get "hello", but I'm not getting anything (ZERO rows returned).
    SELECT 'hello' FROM DUAL
    WHERE 'sample1' in (DECODE(1, 1, '''sample1'', ''sample2'', ''sample3''',
    2, '''sample4'', ''sample5'', ''sample6'''
    I think some problem is there in my WHERE clause.
    But When I'm exeucting the following query as a seperate query, then I'm getting the value of DECODE block properly, but didn;t understnad why its not returning the same way when I'm putting the same DECODE statement in WHERE clause.
    SELECT DECODE(1, 1, '''sample1'', ''sample2'', ''sample3''',
    2, '''sample4'', ''sample5'', ''sample6'''
    FROM DUAL;
    Please help me to get out of this problem. Thank you so much in advance.
    Thanks,
    Ramji.

    The value returned by SELECT DECODE(1, 1, '''sample1'', ''sample2'', ''sample3''',2, '''sample4'', ''sample5'', ''sample6''') FROM DUAL;
    'sample1', 'sample2', 'sample3' is a single string. Consider it x.
    SELECT 'hello' FROM DUAL WHERE 'sample1' in ( DECODE(1, 1, '''sample1'', ''sample2'', ''sample3''',2, '''sample4'', ''sample5'', ''sample6'''));
    is like SELECT 'hello' FROM DUAL WHERE 'sample1' in ('x');
    or
    SELECT 'hello' FROM DUAL WHERE 'sample1' in ('''sample1'', ''sample2'', ''sample3''') and not
    SELECT 'hello' FROM DUAL WHERE 'sample1' in ('sample1', 'sample2', 'sample3');
    For this same reason SELECT 'hello' FROM DUAL WHERE 'sample1' in (select '''sample1'', ''sample2'', ''sample3''' from dual);
    also does'nt work.
    Please use INSTR to find whether 'sample1' exists in the string 'sample1', 'sample2', 'sample3'.

  • Parsing an input parameter for the where clause or record select value

    In my limited CR experience, I've always used a command database connection so that I can write my own SQL.  However, now I have to parse a  pipe delimited parameter to get my value for the where clause, so I'm selecting several tables and joining them through the Database Expert Links tab.  All works fine, but after doing that and then parsing the parameter with the below formula in the Select Expert, I notice that there is no where clause in the SQL query, and although the report eventually displays the proper values, it runs through thousands of records first.  Here is my Select Expert - Record formula:
    StringVar array Parm1;
    Parm1 := Split({?DATA_AREA}, "|");
    {SO_ORDERS.CASE_ID} = Parm1[2]
    If I change "Parm1[2]" on the last line to a valid Case ID, then there is a where clause in the SQL and the report generates immediately. 
    It seems like the record select formula is applied AFTER all of the records (without a where clause) are searched when I use the parsed parameter value, but when I hard code a valid value, it places that into the where clause BEFORE the sql is executed.  Is there a way to get the parameter parsed first and then use that parsed value in the SQL where clause?
    Thanks.
    Bill

    Yes crystal will run the query first to get 100% data and then applies record selection condition. To increase the performance you need to pass the where condition at the command level instead of report level. So you need to create a report using add command like this
    select * from tablename where field={?Parameter}
    {?Parameter} is a command level parameter.
    Now insert this report as a subreport in another report which has no connection but has a parameter
    {?DATA_AREA} and create a formula like this in the main report
    Split({?DATA_AREA}, "|")[2]
    Now right click on the subreport and go to change subreport links and add this formula from main report and link this to sub report parameter {?Parameter} without linking any database field from the subreport.
    Now your subreport runs with the where clause to get the data.
    Regards,
    Raghavendra

  • Global variables to a Tile : where to declare in MAS ?

    Hello,
    While looking at the VBA-formatted code, in came upon some golbal variables to a Tile, and couldn't find where they are declared in MAS :
    (Tile : camcprodl2)
    'Modified by Vikram on 25 Mar 2003
    Private astrSelCat1Cat2GrpKey(2) As String
    'Added by Vikram on 19 Aug 2003 (Next 2 lines)
    'Purpose: Indicates if products are added by mass assignment(set to true) or otherwise (false)
    Private blnMassAssignment As Boolean
    Except writing this directly in the VBA editing window, I don't see where in MAS they are defined.
    The reason for this is that I may have to move the Mass Assign button from the Campaign Products Tile to the Campaign Details Tile, and these 2 variables are used by the methods called.
    Thanks and Regards,
    François

    Ok, I found where it was hiding :
    In the MAS, select the Tile, then the "Free Script" Property : there you can define the tile global variables

  • Using a variable to vary the WHERE clause in a statement

    I have an int column that has values >= 0.
    Depending on a variable I want to select all the rows of the table or only the rows where the int column is 0.
    How do I do this?
    Your help would be much appreciated.
    Thanking you in anticipation.
    Roger
    rogerwithnell

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. Why do you think "a variable" and "the integer column" are precise clear specs? I hate to tell you but zero is a integer. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • 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 bind a VO :variable in a WHERE clause to a page parameter

    Hello,
    I have a VO. This VO has a variable :v in the WHERE clause of the query.
    This VO is used by different UI components in a page (a table, a tree). The page already has a parameter defined in his properties #{viewScope.myparam}
    What I want is to bind :v to the #{viewScope.myparam}, so that I can specify :v from a parameter in the URL, so that the table immeditaly shows the proper results.
    Is there a way to Bind :v to #{viewScope.myparam} directly in the VO definition in the model project? (It seems it is not possilble)
    The other alternative is to use ExecuteWithParams, but in this case I do not know how to perform the query without user actions in a trasparent way. I dont want to associate execute operations to UI components.
    thanks

    Hi,
    +Is there a way to Bind :v to #{viewScope.myparam} directly in the VO definition in the model project? (It seems it is not possilble)+
    No, this can't be done
    The other alternative is to use ExecuteWithParams, but in this case I do not know how to perform the query without user actions in a trasparent way. I dont want to associate execute operations to UI components.
    If you are within a bounded task flow or in an unbounded task flow that does not have this page as its first view (home page) then you can drag and drop executeWithParams as a method call activity. The attribute then should be saved in the pageFlowScope (not the viewScope).
    In addition I would use a ViewCriteria instead of "hard wiring" the bind variable to the VO definition. You can then - in the AM data model section - associate the View Criteria with the VO instance yo use in the UI
    Frank

  • How to use an UNIX shell variable in sql where clause

    Hi ,
    In my shell script first I get the Date and time from the system into the shell variable.At the end of the shell script I need to run a sql script in which I want to use the variable value in the where clause . Is there any way we can use a shell variable value in SQl script ?. Any help is greatly appriciated .
    Thanks in advance,
    Sampath

    Try the following
    In Unix
    SQLPLUS <username>/<password> @MyScript.sql <UNIX_Variable>
    In SQL*Plus
    Reference the variable as &1
    select *
    from MyTable
    where MyDate = to_date('&1','<date_format>');

  • Using where clause  with like

    Hi all,
    im trying to set a block default where clause in the pre-query trigger of my block "customer_settlement" , to query the records that exist in a customers table like this, where the customer_name is variable based on the value entered by the user in enter-query mode before hitting the F8 key , the statement is :
    set_block_property( 'customer_settlement' , default_where ,
    ' fk_cust_code in ( select customer_code from customers where customer_name like %' || :customer_settlement.customer_name ||'% )' );
    the query doesnt work and giving me an error " unable to perform query" , notice that :customer_settlement.customer_name is an item in the block , the user change it and would like to query upon it , and its not a base table item on customer_settlement block its on customers table only . I tried all combinations of '%' and || but it seems that oracle can't see the value In the customer_name field.
    any help is highly thanked.
    im using Oracle form 9.0.4 and Oracle 10g Db.
    Regards,
    IKQ

    Hi,
    does this work ?
    set_block_property( 'customer_settlement' , default_where ,
    ' fk_cust_code in ( select customer_code from customers where customer_name like '''%' || :customer_settlement.customer_name ||'%''' )' );
    Frank

  • WHERE clause sources

    Hi,
    it is said that there are four WHERE clause sources:
    1. WHERE clause block property (on datablock or programatically defined)
    2. ONETIME_WHERE clause block property (on datablock)
    3. Example Record
    4. Query/Where dialog box
    I dont have any idea where I can find/ where the process takes place for items 3&4? Please enlighten me. Thanks

    You can update some data, and you can see lots of data you shouldn't. Eg in a form based on emp and with a restriction in the block's where clause property, you can bring up the Query/Where window and type garbage. Then the "Help > Display Error" window shows something like this
    SELECT ROWID,EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
    FROM scott.emp WHERE deptno = user_dept_no() and (garbage!)The proper Where Clause will only let you see data from your own department, but if you put
    1=2) union select ROWID,EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
    FROM scott.emp WHERE (1=1in the Query/Where window, you can see and update the data from all departments.
    And if you try
    1=2) union select null, null, table_name, null,null, null,null, null,null
    from all_tables WHERE (1=1then you're on your way towards getting access to lots of data which you shouldn't. A form with a large text field would be better for this sort of hacking.
    Trying to update through a function gets this:
    ORA-14551: cannot perform a DML operation inside a queryWith well defined synonyms, privileges and FGAC/VPD it should be safe to keep this enabled. Putting something after the colons means you don't need to know the column names.
    It's handy functionality but I've never been keen on the user-unfriendliness of this window. I'd rather see a dialog showing all the Prompt names and next to each would be a list containing 'Between, <=, != etc', with a free text field after that (or a date picker for date fields, something else for checkboxes, multi-select lists for the list fields, etc). Another for the wish list!

  • MDX query - need to run different query (where clause) on mondays

    The below query works OK and uses the substitution variable CurrentWeek in the WHERE clause, but I have one shortcoming that I need your help for:
    The query works fine for all days but mondays. On Mondays I need the query to fetch numbers from last week (as opposed to current week) as the query returns null as the cubes have no data for current week on mondays. Hence I need to change the where clause to use substitution variable LastWeek, or in some other way run a different query on mondays. I have another substitution variable called WeekDay which I can use to test which day of the week it is, but I am not sure of the syntax I need to use to test for day of week and then have the query use different substitution variables as a result of this test.
    Please help.
    Henning Strand
    SELECT NON EMPTY {[Measures].[meas_sg]} ON COLUMNS,
    NON EMPTY {[Kunde],[Kunde].[KU01],[Kunde].[KU02],[Kunde].[KU03],[Kunde].[KU04]} ON ROWS
    FROM MIFS.MIFS
    WHERE ([Marked].[Dagligvare],[Tid].[&CurrentWeek])

    Or to go off of Sean's suggestion, programmatically change the value of the substitution variable, and leave the code alone.
    Other thoughts -- have a load process to a single cell (sorry, my BSO roots are showing, but the concept is the same, load a single number) and then do a boolean test off its value -- 0 = Monday, 1 = the rest of the week.
    Regards,
    Cameron Lackpour

  • Programmatically select global variable object

    Hello all.
    I have a rookie question that may have an easy answer (or perhaps you can direct me to a different method which is fine too).  I’m using a global variable in an instance where it’s controlled by a parent VI and read by multiple children VIs.  The global variable contains Boolean switches, each with a specific name.  
    If possible, I’d like to make the ‘child VI’ more generic and programmatically flexible so that I don’t have unique children.  That way, instead of four children, I just have one (makes debugging easier).  Here’s the crux of my question:  selecting which object is assigned to the global variable on the block diagram is done by clicking on it with the mouse – can I instead do that programmatically?
    More specifically, when using the global in children VIs (as instructed in the “Creating Global Variables” section of the help files), you can select the global vi and add it to your block diagram.  The next step is to select the front panel object to associate the placed variable with the proper data (you do this by mouse clicking the node you just created – see the attached image).  My question is, can I select the object associated with the placed node programmatically instead of needing to mouse click on it?
    Cheers!
    Attachments:
    ForumEX files.zip ‏31 KB

    Steve Chandler wrote:
    There is a better way of doing this as the others have already pointed out.
    Even Single Process Shared Variables with their API Interface would be better as Globals:
    Using this VI to read the variables gives you the ability to reference them with a string (Link to Variable). You may have to add an additional variable in future versions of your code, where you just need to add the new variable to the project and pass the string to the VI without changing the code. Single Process Shared Variables are based on Global Variables, which are usually just a bit faster. Single Process Variables can easily be converted to network variables.
    However, I agree with Damien that Data Value References would probably be the best sulution.
    Btw, there is a good KB talking about Globals: Are LabVIEW Global Variables good or bad, and when is it ok to use them?
    Christian

  • How to assign local variable to global variable dynamically in adobe livecycle designer 7.1

    Hi All,
    i want to assign my textfield value to global variable dynamically.so that where ever i want , i will access my global variable.so it is possible in adobe livecycle designer 7.1. kindly suggest me method.Thanks in advance.
    Thanks & Regards
    Ganesh

    Please remove all adobe livecycle designer versions from your local pc.
    restart your pc to be sure, that all temp data is deleted.
    download the newest ald version from service.sap.com and install it.
    have fun with developing adobe forms with sap transaction sfp.

Maybe you are looking for