AND and OR operations in WHERE clause

Hello, Dear Oracle professionals.
In WHERE clause when I use AND or OR operations, is there any way of working ORACLE server to select rows?
For example
WHERE con1 and con2 and con3 and con4 and con5OR
WHERE con1 or con2 or con3 or con4 or con5How oracle checks this conditions ? From the begining to the end ? in order ?
May be I should put some more probable TRUE condition to the end(or to the begin).
Whant to know how oracle thinks.
Thanks in advance.

Hi,
Khayyam wrote:
Hello, Dear Oracle professionals.
In WHERE clause when I use AND or OR operations, is there any way of working ORACLE server to select rows?
For example
WHERE con1 and con2 and con3 and con4 and con5OR
WHERE con1 or con2 or con3 or con4 or con5How oracle checks this conditions ? From the begining to the end ? in order ?It evalauates the one that is likely to make the most difference first. In the case of AND, that means the condition that is least likely to be true (as far as the optimizer can predict).
May be I should put some more probable TRUE condition to the end(or to the begin).It doesn't matter to the optimizer. Do whatever you find easier to read and debug.
In ancient times, using the rule-based optimizer, order did matter, but there's no reason to be using the rule-based optimizer now. Oracle 11 doesn't even have the option.
By the way, be careful not to mix AND and OR without parentheses. That is, never say:
WHERE  x AND y OR z    -- ***** No!  Wrong!  ******Instead say
WHERE  (x AND y) OR z   or
WHERE  x AND (y OR z)   depending on what you want. If you don't use partentheses, then there are rules about how the expresssion is evaluated, but it's a waste of your time to learn them.

Similar Messages

  • Difference between column_name is null and column_name (+) is null in where clause.

    Hi All,
    I found the below condition in one of the code of my project.
    Select *
    From table name
    Where column_name ( + )  is null .
    Could any one explain what does column_name ( + ) in where clause.
    Thanks in advance.
    Regards,
    Jagadeeah

    Hi,
    Jagadeesh R wrote:
    Hi All,
    I found the below condition in one of the code of my project.
    Select *
    From table name
    Where column_name ( + )  is null .
    Could any one explain what does column_name ( + ) in where clause.
    Thanks in advance.
    Regards,
    Jagadeeah
    The  ( + )  sign is an old way of doing outer joins.  In Oracle 8 and earlier, you couldn't say
    SELECT  *
    FROM             scott.dept  d
    LEFT OUTER JOIN  scott.emp   e   ON  e.deptno  = d.deptno
    Instead, you got those results by saying:
    SELECT  *
    FROM    scott.dept  d
    ,       scott.emp   e
    WHERE   e.deptno  ( + ) = d.deptno
    The 1 line you posted was probably part of a larger WHERE clause.  You'll have a better understanding of what that 1 line is doing if you look at it in context, considering all the join conditions between the tables involved.

  • Use of DECODE and NULL value in a WHERE clause

    hi all,
    I came into an issue trying to use the DECODE function in a simple where clause.
    this is my test case
    CREATE TABLE tab_test (lev NUMBER, code VARCHAR2(10), val VARCHAR2(10));
    INSERT INTO tab_test VALUES (1, NULL, 'val11');
    INSERT INTO tab_test VALUES (1, NULL, 'val12');
    INSERT INTO tab_test VALUES (1, '13', 'val13');
    INSERT INTO tab_test VALUES (2, '21', 'val21');
    INSERT INTO tab_test VALUES (1, '22', 'val22');
    INSERT INTO tab_test VALUES (1, '23', 'val23');
    and this is the query
    SELECT * FROM tab_test WHERE code = DECODE(:lev,1,NULL,:cod)
    as you can see running this query, setting :lev to 1 will return an empty record set, instead of the expected first two rows (as it will be, running "select * from tab_test where code is null").
    is there a way to overcome this issue? thanks for help

    hi Frank,
    I can confirm that the queries do work when run on TOAD, but do not when they are put in the WHERE clause of my data block. I guess the problem relies on some data block setting; I should investigate on Forms forum.
    Anyway, here is my test case, including data and some examples. You can realize that it works good
    CREATE TABLE TAB_TEST
    LEV NUMBER,
    CODE VARCHAR2(10 BYTE),
    VAL VARCHAR2(10 BYTE)
    Insert into tab_test
    (LEV, CODE, VAL)
    Values
    (3, 'val21', 'val3_211');
    Insert into tab_test
    (LEV, CODE, VAL)
    Values
    (2, 'val21', 'val3_212');
    Insert into tab_test
    (LEV, VAL)
    Values
    (1, 'val11');
    Insert into tab_test
    (LEV, VAL)
    Values
    (1, 'val12');
    Insert into tab_test
    (LEV, VAL)
    Values
    (1, 'val13');
    Insert into tab_test
    (LEV, CODE, VAL)
    Values
    (2, 'val11', 'val21');
    Insert into tab_test
    (LEV, CODE, VAL)
    Values
    (2, 'val12', 'val22');
    Insert into tab_test
    (LEV, CODE, VAL)
    Values
    (2, 'val13', 'val23');
    COMMIT;
    SELECT * FROM TAB_TEST
    CONNECT
    BY PRIOR val = code
    START WITH (CASE
    WHEN :LIV = 1 AND code IS NULL THEN 'OK'
    WHEN :LIV != 1 AND code = :COD THEN 'OK'
    END = 'OK')
                   AND VAL = :V
    :LIV = 1
    :COD = [any]
    :V = 'val11'
    LEV     CODE     VAL
    1          val11
    2     val11     val21
    3     val21     val3_211
    3     val21     val3_212
    :LIV = 1
    :COD = [any]
    :V = 'val12'
    LEV     CODE     VAL
    1          val12
    2     val12     val22
    :LIV = 2
    :COD = 'val11'
    :V = 'val21'
    LEV     CODE     VAL
    2     val11     val21
    3     val21     val3_211
    2     val21     val3_212

  • Invalid relational operator in where clause dynamic

    I have a procedure where I pass the WHERE CLAUSE as a parameter like this:
    PROCEDURE PRC_CONSULTAR_AFIL_PEND(PV_WHERE IN VARCHAR2,
    RESULTSETM IN OUT SYS_REFCURSOR)
    IS
    BEGIN
    OPEN RESULTSETM FOR
    'SELECT PAISAFIL,
    TIPDOCAFIL,
    NUMDOCAFIL,
    APPAFIL,
    APMAFIL,
    NOMAFIL,
    SEXAFIL,
    FECNACAFIL,
    CODPNA,
    ESTADO,
    FECHA,
    TO_DATE(FECGEN),
    NOMCOLUMN
    FROM SUNAFILERR
    WHERE ' || PV_WHERE;
    I am passing the where clause as: 'APPAFIL'||' '||'APMAFIL'||' '||'NOMAFIL LIKE UPPER(rojas%)'

    Miguel Angel wrote:
    I have a procedure where I pass the WHERE CLAUSE as a parameter like this:
    PROCEDURE PRC_CONSULTAR_AFIL_PEND(PV_WHERE IN VARCHAR2,
    RESULTSETM IN OUT SYS_REFCURSOR)
    IS
    BEGIN
    OPEN RESULTSETM FOR
    'SELECT PAISAFIL,
    TIPDOCAFIL,
    NUMDOCAFIL,
    APPAFIL,
    APMAFIL,
    NOMAFIL,
    SEXAFIL,
    FECNACAFIL,
    CODPNA,
    ESTADO,
    FECHA,
    TO_DATE(FECGEN),
    NOMCOLUMN
    FROM SUNAFILERR
    WHERE ' || PV_WHERE;
    I am passing the where clause as: 'APPAFIL'||' '||'APMAFIL'||' '||'NOMAFIL LIKE UPPER(rojas%)'So your where clause is
    WHERE APPAFIL APMAFIL NOMAFIL LIKE UPPER (rojas%)Can you see why that's an error? It would make more sense if there was an operator between APPAFIL and APMAFIL, but then there's obviously something missing between APMAFIL and NOMAFIL as well, and some quotes missing later on.
    The following is valid SQL code
    WHERE   APPAFIL  != APMAFIL
    AND     NOMAFIL  LIKE UPPER ('rojas%')Of course, I have no idea if that's what you want or not.
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements) for any tables used, and the results you want from that data.
    if the problem involves parameters (such as the pv_where), then post a couple of different parameters, and the results you want from the same sample data for each parameter.
    Explain how you get those results from that parameter and that data.
    Always say which version of Oracle you're using.

  • How to use string operation in where clause of select query

    Hello All,
    I just want to know how can i write a restriction in select query saying retrive data only begins with name "DE*".
    Explaination: If my table has records and names starts with character then i want to write a query to fetch all the records in which names starts with DE*.
    Thanks in advance for your quick reply...
    Dev.

    Hi
    In the where clause you need to write like
    WHERE NAME LIKE 'DE%'
    Regards
    Sudheer

  • IN operator in Where Clause

    Hi Experts,
    I have been facing a problem in passing multiple values to the where clause in select query. I have 15 values in which i need to check in where condition.
    Ex:  SELECT AMATNR ASPART
               INTO TABLE IT_DIVISION
               FROM MARA AS A
               INNER JOIN MARC AS B ON
               AMATNR = BMATNR
               FOR ALL ENTRIES IN IT_UPDATE
               WHERE A~MATNR EQ IT_UPDATE-MATNR
               AND A~MTART IN ('ZLHA', 'ZFER', 'ZHAL', 'ZNLA', 'ZOPS',
                               'ZPSE', 'ZROH', 'ZUNB', 'ZVER ', 'ZDIA').
    Now i need to include some more (5) values, but its showing some error.
    Please guide me in this.
    Thnx in Adv..Meher

    Hi,
    Make use of a range table.
    types : begin of T_range,
    sign type TVARV_SIGN,
    option type TVARV_OPTI,
    low type mtart,
    high type mtart,
    end of t_range.
    data: IT_RANGE type standard table of T_range.
    data : wa_range type T_RANGe.
    wa_range-sign = 'I'.
    wa_range-option = 'EQ'.
    wa_range-low = 'ZLHA'
    append wa_range to IT_RANGE.
    wa_range-sign = 'I'.
    wa_range-option = 'EQ'.
    wa_range-low = 'ZFER'
    append wa_range to IT_RANGE.
    wa_range-sign = 'I'.
    wa_range-option = 'EQ'.
    wa_range-low = 'ZHAL'
    append wa_range to IT_RANGE.
    and so on till all your values are filled in the table and then use this table in the IN clause.
    SELECT AMATNR ASPART
    INTO TABLE IT_DIVISION
    FROM MARA AS A
    INNER JOIN MARC AS B ON
    AMATNR = BMATNR
    FOR ALL ENTRIES IN IT_UPDATE
    WHERE A~MATNR EQ IT_UPDATE-MATNR
    AND A~MTART IN it_range.
    The error which you are getting is because of the spacing between the different MTART values which you have included in the bracket.
    After every comma there should be a space.
    But you should always use range for such requirements.
    regards,
    Ankur Parab
    Edited by: Ankur Parab on Jun 23, 2009 6:59 PM

  • Convert string to datetime and then use in a where clause

    I am trying to pull in warranty expiry dates that have been entered as strings and then perform a calculation as to which ones are expired, about to expire within
    90 days or will expire in more than 90 days. I have got the query to a point where I have converted it to a datetime field (though I'm sure I used the right value to just give me the date, its giving me date and time) and have it printing out the machine name
    and the warranty for that machine.
    SELECT
      machNameTab.machName
      ,convert(date,auditRsltManualFieldValues.fieldValue,103) AS warranty
    FROM
      machNameTab
      INNER JOIN auditRsltManualFieldValues
        ON machNameTab.agentGuid = auditRsltManualFieldValues.agentGuid
    WHERE
      machNameTab.groupName = N'root.company'
      AND auditRsltManualFieldValues.fieldNameFK = 958472722796011
    What I need to do next is change this so instead of just spitting out all the dates as 'Warranty', I want it to give me the fields 'Expired', 'Expiring' (expiry date is within 90 days of the current date) and 90Days (expiry date is over 90 days from the current
    date)

    SELECT
    machNameTab.machName
    ,convert(date,auditRsltManualFieldValues.fieldValue,103) AS warranty,
    select
    case
    when datediff(day,getdate(),convert(date,auditRsltManualFieldValues.fieldValue,103) )<90 then 'Expiring'
    when datediff(day,getdate(),convert(date,auditRsltManualFieldValues.fieldValue,103) )<0 then 'Expired'
    when datediff(day,getdate(),convert(date,auditRsltManualFieldValues.fieldValue,103) )>=90 then '90Days'
    end as status
    FROM
    machNameTab
    INNER JOIN auditRsltManualFieldValues
    ON machNameTab.agentGuid = auditRsltManualFieldValues.agentGuid
    WHERE
    machNameTab.groupName = N'root.company'
    AND auditRsltManualFieldValues.fieldNameFK = 958472722796011
    I added a case to your select. The case will output the strings you wanted based on the date.

  • Should I use And or OR in the Where Clause?

    2 Databases have been merged, and in the purge some data was omitted, so I am running clean-up.  Now I need a query to show me if item1 is null, then check olditem1 if both fields are null then ignore the record completely.  But If either field
    has a value I need it returned.  So 1st check item1 if that field is not null, then return the record, if item1 is null, check olditem1 if that field is not null then return the record.  If both fileds are null, ignore the record and let's check
    the next one.
    Sample Data;
    Select
    Test.StaffIDID,
    Test.purchasedfrom,
    Test.date,
    case when Test.item1 is null then Test.olditem1 else null end as [1st Item],
    case when Test.item2 is null then Test.olditem2 else null end as [2nd Item],
    From internetsales Test
    CREATE TABLE Test
    StaffID INT NOT NULL PRIMARY KEY,
    purchasedfrom NVARCHAR(30) NOT NULL,
    date DateTime NOT NULL,
    item1 NVARCHAR(50),
    item2 NVARCHAR(50),
    olditem1 NVARCHAR(50),
    olditem2 NVARCHAR(50)
    INSERT Test VALUES
    (2, 'web1', '2010-01-02', 'stereo', 'NULL', 'NULL', 'NULL'),
    (3, 'web3', '2011-02-15', 'NULL', 'microphone', 'NULL', 'NULL'),
    (4, 'web14', '2014-02-21', 'NULL', 'NULL', 'NULL', 'headset'),
    (5, 'web81', '2015-01-01', 'NULL', 'NULL', 'MP3 Player', 'NULL');
    (6, 'web18', '2011-01-01', 'Dryer', 'NULL', 'MP3 Player', 'NULL');
    (7, 'web8', '2009-01-01', 'NULL', 'NULL', 'Stove', ''NULL);
    (8, 'web828', '2002-01-01', 'NULL', 'NULL', 'NULL', 'USB HUB');
    (9, 'web88', '2007-01-01', 'Refrigerator', 'NULL', 'NULL', 'NULL');
    (10, 'web89', '2009-01-01', 'NULL', 'NULL', 'NULL', 'NULL');
    Desired returned result sets would be StaffIDs: 2,5,6,7,9 -- as they have a value for item1 or olditem1

    Looks like you totally ignored my answer :-(
    well... you have your reason probably...
    You do realize that I gave you the answer from the start?!?
    Hi,
    your sample data do not include any NULL value. Blank string is not NULL.
    Please clarify your question and give us the result that you want to get, according to your sample data.
    * if your data is NULL and not empty string that you can use COALESCE(item1, olditem1,'') in order to get the first value that is not NULL. if both
    NULL then it will return blank string as this is the first value that is not null
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]
    Using nested IIF can be done directly with the
    COALESCE function.
    The execution plan is the same, but the code is much cleaner and easier to write or read.
    There is a reason for this function.
    * In your current needs there are only 2 nested IIF, but you should know about COALESCE function! Once you get more complex situation you will be able to get a solution much faster and probably without any mistake on the first try.
    try to use 5 nested IIF... using COALESCE  this is simple as 2 or 10... all you need is to write all the values and the function will return the first that is not NULL
    Any way, I hope this is useful for people that will come to this thread in future :-)
    -- SOLUTION 1: using nested IIF
    SELECT StaffID, purchasedfrom, date,
    IIF(ITEM1 IS NOT NULL, ITEM1, IIF(OLDITEM1 IS NOT NULL, OLDITEM1,NULL)) AS [1ST ITEM],
    IIF(ITEM2 IS NOT NULL, ITEM2,IIF(OLDITEM2 IS NOT NULL, OLDITEM2,NULL)) AS [2ND ITEM]
    FROM Test
    -- solution 2: using COALESCE
    SELECT
    StaffID, purchasedfrom, date,
    COALESCE(ITEM1, OLDITEM1) AS [1ST ITEM],
    COALESCE(ITEM2, OLDITEM2) AS [2ND ITEM]
    FROM Test
    -- Whish solution look simpler to read, write or use?
    -- The execution plan is the same, but it is always good idea to make sure if you are not sure :-)
    I hope this is useful :-)
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Conditional operator in where clause?

    I have 4 assignable parameters for filtering records. If a parameter is not assigned the filter is ignored. This is working fine with the SQL-statement below except for one scenario: if none of the parameters are assigned I get no records at all but then I need all of the records.
    with t as
        select 1 as val, 'a' as var from dual union all
        select 2 as val, 'a' as var from dual union all
        select 3 as val, 'b' as var from dual union all
        select 4 as val, 'b' as var from dual union all
        select 5 as val, 'b' as var from dual union all
        select 6 as val, 'c' as var from dual union all
        select 7 as val, 'd' as var from dual union all
        select 8 as val, 'e' as var from dual union all
        select 9 as val, 'e' as var from dual union all
        select 0 as val, 'f' as var from dual
    select *
    from t
    where t.var = decode(:pvar1,'',null,:pvar1)
    or t.var = decode(:pvar2,'',null,:pvar2)
    or t.var = decode(:pvar3,'',null,:pvar3)
    or t.var = decode(:pvar4,'',null,:pvar4)

    You need no "OR"s
    <br>
    SQL> var pvar1 char
    SQL> var pvar2 char
    SQL> var pvar3 char
    SQL> var pvar4 char
    SQL> with t as(    select 1 as val, 'a' as var from dual union all
      2      select 2 as val, 'a' as var from dual union all
      3      select 3 as val, 'b' as var from dual union all
      4      select 4 as val, 'b' as var from dual union all
      5      select 5 as val, 'b' as var from dual union all
      6      select 6 as val, 'c' as var from dual union all
      7      select 7 as val, 'd' as var from dual union all
      8      select 8 as val, 'e' as var from dual union all
      9      select 9 as val, 'e' as var from dual union all
    10      select 0 as val, 'f' as var from dual)
    11  select *from t
    12  where t.var = coalesce(:pvar1,:pvar2,:pvar3,:pvar4,t.var);
           VAL V
             1 a
             2 a
             3 b
             4 b
             5 b
             6 c
             7 d
             8 e
             9 e
             0 f
    10 rows selected.
    SQL> exec :pvar4 := 'b';
    PL/SQL procedure successfully completed.
    SQL>  with t as(    select 1 as val, 'a' as var from dual union all
      2       select 2 as val, 'a' as var from dual union all
      3       select 3 as val, 'b' as var from dual union all
      4       select 4 as val, 'b' as var from dual union all
      5       select 5 as val, 'b' as var from dual union all
      6       select 6 as val, 'c' as var from dual union all
      7       select 7 as val, 'd' as var from dual union all
      8       select 8 as val, 'e' as var from dual union all
      9       select 9 as val, 'e' as var from dual union all
    10       select 0 as val, 'f' as var from dual)
    11   select *from t
    12   where t.var = coalesce(:pvar1,:pvar2,:pvar3,:pvar4,t.var);
           VAL V
             3 b
             4 b
             5 b
    Message was edited by:
            jeneesh
    I did mistake. Follow Dave's post                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • ANSI SQL Syntax - What belongs to join-clause and what to where-clause

    Hello,
    we currently have a discussion about the ANSI SQL Syntax where we do not agree what belongs to the join clause and what belongs to the where clause in an ANSI Sytnax SQL Query.
    Lets say there is a query like this:
    +SELECT *+
    FROM employees emp, departments dept
    WHERE emp.dept_country = dept.dept_country
    AND emp.dept_name = dept.dept_name
    AND dept.dept_type = 'HQ'
    AND emp.emp_lastname = 'Smith'
    Primary key of the departments table is on the columns dept_country, dept_name and dept_type. We have a Oracle database 10g.
    Now I have rewritten the query to Ansi Syntax:
    +SELECT *+
    FROM employees emp
    JOIN departments dept
    ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name
    WHERE dept.dept_type = 'HQ'
    AND emp.emp_lastname = 'Smith'
    Another developer says that this is not completely correct, every filter on a column that belongs to the primary-key of the joined table has to be in the join clause, like this:
    +SELECT *+
    FROM employees emp
    JOIN departments dept
    +ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name AND dept.dept_type = 'HQ'
    WHERE emp.emp_lastname = 'Smith'
    Can somebody tell me which on is correct?
    Is there any definition for that? I couldn't find it in the Oracle Database definition.
    I just found out the names of the ANSI documents here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_standard_sql001.htm#i11939
    I had a look at the ANSI webstore but there you have to buy the PDF files. In my case thats exaggerated because both of the Queries work and i am just interessted if there is one correct way.
    Thank you in advance
    Marco

    Hi,
    As i guideline i would say, answer the question: should the result of the join be filtered or should only filtered rows be joined from a particular table?
    This is helpful in the case of outer joins also, for inner joins it doesnt matters as said already be former posters, where there may be hughe semantical differences depending of where the predicates are placed.
    From performance view, if we talk about oracle, take a look a the execution plans. You will see that there is (probably) no difference in case of inner joins. Even in case of outer joins the optimizer pushes the predicate as a filter towards the table if it semantically possible.
    Regards

  • How do you use 3 Where Clauses in a query

    Hi, i am trying to figure out how to use 3 Where Clauses in a Query where 2 of the Where Clauses uses a Sub query.
    Display the OrderID of all orders that where placed after all orders placed by “Bottom-Dollar Markets”.
    Order the result by OrderID in ascending order.
    First WHERE clause checks for OrderDate and uses a sub query with ALL keyword.
    Second WHERE clause use equals and sub query.
    Third WHERE clause uses equal and company name.
    This is what i have so far but i am pretty confused on how to do this.
    My Code for NorthWind:
    Select OrderID
    From Orders o
    Where o.OrderID IN (Select OrderDate From Orders Where Orders.OrderID > ALL
    (Select CompanyName From Customers Where CompanyName = 'Bottom-Dollar Markets'));
    The book shows how to use the ALL Keyword but not in a Sub query with Multiple Where Clauses.
    Select VenderName, InvoiceNumber, InvoiceTotal
    FROM Invoices JOIN Vendors ON Invoices.VendorID = Vendors.VendorID
    WHERE InvoiceTotal > ALL (Select InvoiceTotal From Invoices Where VendorID = 34)
    ORDER BY VendorName;

    >Where Orders.OrderDate
    > ALL  (Select
    CompanyName
    The comparison operator (>) requires compatible data types.
    DATETIME is not compatible with VARCHAR string for comparison.
    Here is your homework:
    SELECT orderid
    FROM orders o
    WHERE o.orderdate > ALL (SELECT orderdate
    FROM orders
    WHERE shipvia = (SELECT Max(shipvia)
    FROM orders o
    INNER JOIN customers c
    ON c.customerid =
    o.customerid
    WHERE
    c.companyname = 'Bottom-Dollar Markets'));
    11064
    11065
    11066
    11067
    11068
    11069
    11070
    11071
    11072
    11073
    11074
    11075
    11076
    11077
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

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

  • To_number function doesn't work with apex_collections in where clause

    One of my applications I have been using apex_collections and to_number function
    in the where clause. Since we upgraded apex to version 3.0.1 , it gives the invalid number error.
    Is this a bug in the new Version.
    I had to re-write the logic to fix the application.

    Can you show us that code? An example on apex.oracle.com where we can see the error would be great.
    Scott
    P.S. Please tell us your first name and put it into your handle and/or profile to help us.

  • JSP, Data Web Bean, BC4J: Setting the where clause of a View Object at run time

    Hi,
    I am trying to develop a data web bean in which the where clause of a View Object will be set at run time and the results of the query then displayed.
    My BC4J components are located in one project while the coding for the data web bean is in another project. I used the following code bu t it does not work. Could you please let me know what I am doing wrong?
    public void populateOSTable(int P_EmpId)
    String m_whereString = "EmpView.EMP_ID = " + P_EmpId;
    String m_OrderBy = "EmpView.EMP_NAME";
    oracle.jbo.ApplicationModule appModule = null;
    ViewObject vo = appModule.findApplicationModule("EMPBC.EMPAppModule").findViewObject("EMPBC.EMPView");
    vo.setWhereClause(m_whereString);
    vo.setOrderByClause(m_OrderBy);
    vo.executeQuery();
    vo.next();
    String empName numAttrs = vo.getAttribute(EmpName);
    System.out.println(empName);
    Thanks.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JDev Team (Laura):
    Here is how I have usually done mine:
    1. In the JSP, use a RowsetNavigator bean to set the where clause and execute the query.
    2. Use a custom web bean to process the results of the query (print to HTML).
    for example:
    <jsp:useBean class="oracle.jbo.html.databeans.RowsetNavigator" id="rsn" scope="request" >
    <%
    // get the parameter from the find form
    String p = request.getParameter("p");
    String s = request.getParameter("s");
    // store the information for reference later
    session.putValue("p", p);
    session.putValue("s", s);
    // initialize the app module and view object
    rsn.initialize(application,session, request,response,out,"wt_bc_WT_bcModule.wtjoinView");
    // set the where clause string
    String theclause = "presname = '" + p + "' AND slideno=" + s;
    // set the where clause for the VO
    rsn.getRowSet().getViewObject().setWhereClause(theclause);
    rsn.getRowSet().getViewObject().executeQuery();
    rsn.getRowSet().first();
    %>
    </jsp:useBean>
    <jsp:useBean class="wt_bc.walkthruBean" id="wtb" scope="request" >
    <%
    // initialize the app module and VO
    wtb.initialize(application,session, request,response,out,"wt_bc_WT_bcModule.wtjoinView");
    wtb.render();
    %>
    In this case, the render method of my custom web bean mostly gets some session variables, and prints various content depending on the session variable values.
    Hope this helps.
    </jsp:useBean><HR></BLOCKQUOTE>
    Laura can you give the code of your walkthru bean? i wna't to initialize a viewobject, set the where clause and give that viewobject back to initialize my navigatorbar.
    Nathalie
    null

  • Problem in case of or condition in  where clause in case of leftouter joi.

    hi
    i am encountering a wierd problem.
    in a select query if i have a left outer join and a or condition in where clause the order of condition in or matters and if i use a to_char problem is solved.
    see query below
    select * from custsupp left outer join Salesperson s on custsupp.sales_rep = s.id ,state a where (CS_FLAG='C' or CS_flag ='B') and custsupp.state = a.id
    i have a single record in table custsupp with CS_FLAG ='B' the above does not return result. but if i move CS_FLAG='B' on left of or i.e
    select * from custsupp left outer join Salesperson s on custsupp.sales_rep = s.id ,state a where (CS_FLAG='B' or CS_flag ='C') and custsupp.state = a.id
    i get the rsult.
    also if i remove left outer join and keep order of condition as it is i get result i.e
    select * from custsupp ,state a where (CS_FLAG='C' or CS_flag ='B') and custsupp.state = a.id
    also if i add a to_char to co,umns CS_FLAG i get the result.
    select * from custsupp left outer join Salesperson s on custsupp.sales_rep = s.id ,state a where (to_char(CS_FLAG)='C' or to_char(CS_flag ='B')) and custsupp.state = a.id
    why it is so?
    CS_flag is of type nchar
    Shreyas
    Edited by: shreyasd on Jun 9, 2010 11:07 PM

    First if you don't want to take credit of the free sample then follow the below procedure:
    1. Do the GRN for all the three item and for the free item in the excise tab at the item level select the material as non cenvatable. Just remember to add base value of the item
    2.  If you want to capture the Part1 entry then just do the normal transaction and while posting the excise with J1IEX just remove the excise duties for the free item.
    3. For paying the vendor the excise amount, just do subsequent debit in the MIRO and in the details tab add in the unplanned delivery cost the amount that you want to pay for the excise duties
    Second case if you want to take credit of the duties:
    1. Do the Normal GRN process, add the base value and excise values for the free item.
    2. Post the Excise duites with J1iEX.
    3. The with the account entry you can settle the excise payment
    Hope this will help you
    Enjoyyyyyyyyyyy
    Akshit

Maybe you are looking for

  • How to fix Online help issue with F1

    Dear All, I think you already know this issue : when using a proxy, Online help is not working on Adobe Reader XI. message displayed : "Online Help content cannot be displayed. Verify you can launch your web browser and have access to the Internet."

  • Why do I have to logon each time when opening a office Document from a SharePoint 2010 Library

    Hello guys, I'm facing some design issue with sharepoint 2010 and Microsoft office, hope you can help me to fix this. Why do I have to logon each time when opening a office Document from a SharePoint Library when I'm already authenticated via the bro

  • How do I search all Contacts fields in the Q5 with OS10.2?

    Blackberry appear to be advancing backwards with their new Q5 and 10.2 operating system. I originally bought the Blackberry specifically for its ability to search into the notes field of email contacts, which no other phone could do at the time. When

  • Running two (or more) conky's

    Is there a way to get multiple conky's up on my desktop?  what I would like to accomplish is have my current conky (showing system resources and whatnot) in the upper right with the output of /var/messages/messages.log running in the upper left hand

  • Finder don´t open the window

    my finder in my dock, when i click on it don´t open the window. only if i press command+n or select a new window. i don´t now if i made a combination keys and i dont no how to revers it.