EO and VO where clauses

I am working on some customizations for a client. I'm trying to query PoReqDistribuitionsVO for a particluar Requisition Line id and it is not working. I've looked at the queries both in the VO definition and using the VO getquery method and I noticed that the .getquery() method returns the query with where clause appeneded even if I execute .setWhereClause(null) just prior to it.
The where clause is filtering where the requistion_line_id = :1
I have two questions.
1) where is this where clausing coming from since it is not part of the VO definition
2) How can I set the bind parameter on this mystery where clause?
If I use the VO.setWhereClauseParams() method, I get a sql error of no such bind variable exists.
Thanks in advance for any help.

1) You can dynamically set the where clase from the AM or one of the method initQuery() inside the VOimpl.java.
This is a simple step to set where clasue dynamically.
public void initQuery(String yourid )
setWhereClauseParams(null); // Always reset
setWhereClause("Pid = :1");
setWhereClauseParam(0, "123");
executeQuery();
This initQuery is called from your Am method, for example vo.initQuery() instead of executing vo.executeQuery().
2) The reson you are getting error becuase , becuase you may have not set where clause before setWhereClauseParam. See example above.
One more thing to be careful is the indexing of the bind parameter, in case of setWhereClause() , the index start with 1 and in cae of setWhereClauseParam() , index start with 0.
hope this help.

Similar Messages

  • Group by with and without where clause

    Do I need to use these two inner views to show results by group by as one line? Can I achieve the same result without typing the same select statement two times since these two SELECT statements differ only in where clause. This query is a simulation. My actual query is longer. My expectation is to make this query shorter (without inner views).
    with tmp as (
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 1 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual)
    select v1.status, v1.country, v1.cnt01, v2.cntIncluding0 from
    (select status, country, count(*) cnt01 from tmp tmp1 group by status, country) v1
    JOIN
    (select status, country, count(*) cntIncluding0 from tmp tmp2 where substatus=0 group by status, country) v2
    on v1.status=v2.status and v1.country=v2.country;

    totalnewby wrote:
    Do I need to use these two inner views to show results by group by as one line? Can I achieve the same result without typing the same select statement two times since these two SELECT statements differ only in where clause. This query is a simulation. My actual query is longer. My expectation is to make this query shorter (without inner views).
    with tmp as (
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 1 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual)
    select v1.status, v1.country, v1.cnt01, v2.cntIncluding0 from
    (select status, country, count(*) cnt01 from tmp tmp1 group by status, country) v1
    JOIN
    (select status, country, count(*) cntIncluding0 from tmp tmp2 where substatus=0 group by status, country) v2
    on v1.status=v2.status and v1.country=v2.country;
    SQL> with tmp as
      2  (
      3  select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual UNION ALL
      4  select 'COMPLETE' status, 'GERMANY' country, 1 substatus FROM dual UNION ALL
      5  select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual
      6  )
      7  select status,
      8         country,
      9         count(substatus) cnt01,
    10         sum(decode(substatus, 0, 1, 0)) cntincluding0
    11    from tmp
    12   group by status, country
    13  ;
    STATUS   COUNTRY      CNT01 CNTINCLUDING0
    COMPLETE GERMANY          3             2

  • Tree Layout  and a Where Clause

    I have built a uix application using Jdev (10.1.2) + Jheadstart (10.1.2). I followed Jheadstart for ADF developer’s guide (10.1.2) for creating a page with a recursive tree, tree layout style and it works well. Now I need to apply a where clause, programmatically, on the view I am using for generating the tree and the problem is that the where clause 'gets lost' on the child view before the page is displayed. How do I fix this?

    rbackmann wrote:
    And the page_id_1 is a field in the table (SORRY EXAMPLE BAD NAMING CONVENTIONS) that IS VARCHAR
    and houses a comma seperated list of page numbers ie 28,29, 30Okay, I was wrong about the field name :(
    Carefully examine the query, expecially the INSTR line. Get the values in both the column and the bind variable and make sure they are what you think they are.
    The example on the other post might have failed because you were equality comparing the column value to '28' when it might have been a csv with commas unless you changed it (something worth trying).
    On 4th look I may (or may not) have something. PAGE_ID_1 is a VARCHAR2, while the 28 you compared it to was a number. Its a long shot, but maybe SQL is trying to convert the csv field to a number, failing to raise an error message where you can find it, and failing for that reason. Try using '28' on the equality test.
    Edited by: riedelme on May 8, 2009 6:03 AM

  • Mm.mysql JDBC Driver and the WHERE clause

    Anybody has succesfully performed a MySQL/JDBC query in a JSP application using more than one variable in the WHERE clause?
    It works fine when I run queries with one fixed value assigned to a column and one variable assigned to the other column in the WHERE clause; but when I do it with more than one variable in the WHERE clause, it screws up throwing an error.
    I wonder if it is a code error, a syntax error or if it is something tricky about the mm.mysql JDBC Driver. Following is a section of the code and the error. The variables are s_description and s_status. I read some examples in a book but they use SQL Server. Thank you in advance for any information.
    CODE:
    <% String sqlStatement = "" ; %>
    <% String s_description = "Mexican Style Rice" ; %>
    <% String s_status = "available" ; %>
    <% java.sql.Statement stmt = con.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_UPDATABLE); %>
    <% java.sql.ResultSet rs ; %>
    <% sqlStatement = "SELECT code, description, status FROM products WHERE products.description =" + s_description + " AND products.status =" + s_status + ";" ;%>
    <% rs = stmt.executeQuery(sqlStatement); %>
    <% rs.beforeFirst(); %>
    <% while (rs.next()) { %>
    <% rs.updateString(3, "sold"); %>
    <% rs.updateRow(); %>
    <% }%>
    <% rs.close(); %>
    This is the ERROR it throws
    java.sql.SQLException: Column not found: Unknown column 'available' in 'where clause'
         at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java:497)
         at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(MysqlIO.java:550)
         at org.gjt.mm.mysql.MysqlIO.sqlQuery(MysqlIO.java:635)
         at org.gjt.mm.mysql.Connection.execSQL(Connection.java:882)
         at org.gjt.mm.mysql.Connection.execSQL(Connection.java:815)
         at org.gjt.mm.mysql.Statement.executeQuery(Statement.java:169)
         at org.gjt.mm.mysql.jdbc2.Statement.executeQuery(Statement.java:78)
         at pagecompile._GetFood_xjsp._jspService(_GetFood_xjsp.java:45)
         at com.newatlanta.servletexec.JSP10HttpJspPage.service(JSP10HttpJspPage.java:41)
         at com.newatlanta.servletexec.JSP10Servlet.service(JSP10Servlet.java:779)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.newatlanta.servletexec.ServletExec.CallServletService(ServletExec.java:1679)
         at com.newatlanta.servletexec.ServletExec.processServletRequest(ServletExec.java:1654)
         at com.newatlanta.servletexec.ServletExec.processServletAlias(ServletExec.java:1602)
         at com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1343)
         at com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1113)

    I think perhaps this sentence has problems:
    <% sqlStatement = "SELECT code, description, status FROM products WHERE products.description =" + s_description + " AND products.status =" + s_status + ";" ;%>
    You can
    <% sqlStatement = "SELECT code, description, status FROM products WHERE products.description ='" + s_description + "' AND products.status = '" + s_status + "'" ;%>
    You perhaps ignore the ���� when using String variable s_description and s_status.
    Hope this will help you. Good lucky!

  • OraclePreparedStatement and dynamic where clause

    I am trying to figure out a better and more efficient way to construct a dynamic sql statement where the one or more parameters can be passed which would be included in the where clause. I know I can simply use a case or if statement to build the where clause but I cant believe this is the only/best way to do it.
    I was playing with OraclePreparedStatement but it only seems to work when the where columns are known. I need something like:
    select something from somewhere
    where ? = ?
    And I can simply set 1 to be a column and 2 to be a value. I suppose I could sublcass or create my own class that does this.
    Any help would be appreciated.
    Ryan

    >>>However, the problem is that my current structure doesn't all me to write any SQL to be written
    on DAL
    You cannot use dynamic sql in DAL? Have a stored procedure where you build dynamic sql and call it from
    within DAL.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Row Level Security using BO SDK - Dynamic Group and Criteria (where clauses)

    To the Universe Gurus out there:
    I have a rather daunting task of implementing a Row Level Security on a number of tables within our project using BO XI R2 SP2 with SQLServer 2005. Given the nature of the requirements around this (listed below), I am going to go with BO SDK to accomplish the creation of Restrictions. That said, I need some insight into some of the problem areas I have listed below. Any help is much appreciated.
    Background:
    We have 11 tables that are to be restricted.
    Each table is accessible to potentially 1..* group of users only.
    For eg SALES is accessible to ALL_SALES members only.
    Each row within each table is accessible to 1..* groups of users only. The restriction will occur on 2 columns Jurisdiction and LineID on SALES table.
    For eg
    1)Rows with NY Jurisdiction and LineID=123 are accessible to NY_SALES_ADMIN group only initially.
    2)NY_ADMIN will then approve that the above rows be open to NY_SALES_INTERNAL group only. This approval in turn will call upon the BO SDK to add a new restriction for the group with appropriate where clause.
    3)At a later point, the above rows will be opened to NY_SALES_EXTERNAL group also.
    This same concept holds good a number of jurisdiction (more or less static) and a dynamic number of LineIDs. So, if 10000 rows of data corresponding to new LineID 999 and Jurisdiction AK are in the table now, they are initially accessible only to AK_SALES_ADMIN group only. No one else should be able to access it.
    Results:
    1) With the way I laid out the business rules above, I am ending up with 528 groups.
    2) There is a restriction created for a unique combination of Jurisdiction and LineID for each table.
    Problems/Questions:
    How can I restrict access to the new rows to one group only. I know that I can let a certain group only look at certain data but how can I restrict that all others cannot look at the same.
    AK_SALES_ADMIN can look at LineID=999 and Jurisdiction='AK'.
    Do I use an Everyone group based restriction? If so, my Everyone group will end up with tons of restrictions. How will they be resolved in terms of priority.
    Am I even thinking of this the right way or is there a more noble way to do this?
    Regards

    the connectinit setting should look something like this:
    declare a date; begin vpd_setup('@VARIABLE('BOUSER')'); Commit; end;
    The vpd_setup procedure (in Oracle) should look like this:
    CREATE OR REPLACE procedure vpd_setup (p_user varchar)IS
    BEGIN
      DBMS_SESSION.set_vpd( 'SESSION_VALUES', 'USERID', p_user );
    END vpd_setup;
    Then you can retrieve the value of the context variable in your vpd functions
    and set the vpd.

  • Expert mode query in View objects and appended where clause

    My company is Oracle Member Partner and we are developing enterprise web applications using Oracle database and BC4J.
    I have the following problem...
    When I enable EXPERT MODE option in View Object I have trouble appending to query statement in my client code.
    I need expert mode because I must use "SELECT DISTINCT" insted of "SELECT" in my query.
    It looks something like this:
    viewObject.setWhereClause("CLA_ID = " + claId);
    viewObject.executeQuery();
    SQL query from View Object becomes sub-query and fails to execute:
    select * from (original view object query) where (... appended where clause)
    Order by part of the query causes sql errors because original query is now sub-query.
    Is there any way around this?

    I tried creating an expert mode SQL query:
    SELECT DISTINCT EMPNO, ENAME FROM EMP.
    Then at runtime I do:
    vo.setWhereClause("ENAME LIKE '%'||?||'%');
    vo.setWhereClauseParam(0,'A');.
    and this works fine. The trick is that since expert-mode view objects get wrapped as inline views (to allow runtime appending of WHERE clause, actually), you need to select any column in the select statement to which you want to later refer in a dynamically-appended where clause.
    If you want to prevent the inline-view wrapping, you can write the following code in your view object's ViewObjectImpl subclass to force the VO to NOT be treated as an expert-mode SQL VO.
      // Goes in your view object impl subclass
      public void create() {
         // Force this VO to NOT be treated as an expert-mode SQL, so that
         // its query does not get wrapped as an inline view.
         getViewDef().setFullSql(false);
      }I used this trick above to create an expert mode query like:
    SELECT DISTINCT deptno FROM empand then at runtime I add a dynamic where clause that refers to a column
    in EMP that is not in the select list like this:
        ViewObject vo = am.findViewObject("View1");
        vo.setWhereClause("ename like '%A%'");
        vo.executeQuery();
        System.out.println(vo.first().getAttribute(0));and this causes the query to come out as:
    SELECT DISTINCT deptno FROM emp WHERE ename like '%A%'.
    instead of:
    SELECT * FROM (SELECT DISTINCT deptno FROM emp) QRSLT WHERE ename like '%A%'which would cause an error due to the fact that ename is not in the select list of the original (wrapped, inline) query.

  • Join and Multiple where clauses: which is better??

    There was an argument between a colleague and I. He prefers building his views joining many tables with many where clause while I am cute with my join which is simpler and more understandable for me. So, it started an argument on which is a superior way of joining tables.
    I will actually like to know we is faster and better: using JOINs or using multiple where clauses to retrieve values from multiple tables.?

    Dave:
    "Are we talking about the difference between Oracle Joins and ANSI Joins?
    e.g.
    Select d.dept_name, e.emp_name
    from dept d, emp e
    where d.dept_id = e.dept_id"
    That is not really an "Oracle Join". That syntax works on just about every SQL database I have ever worked with. The (+) syntax for an outer join is Oracle specific, but some other databases use a similar style for outer joins (something like a.c += b.c or a.c *= b.c).
    OP:
    There are things you can do with the ANSI style syntax that either cannot be done, or cannot be done as easily, with Oracle's syntax. Most notably, outer joining one table to more than one other tables, and FULL OUTER joins.
    Having said that, in my experience, both are rather rare occurrences, so I tend to stick to doing the jopins in the WHERE clause because that is what I am used to.
    John

  • Where clause and joins

    HI all,
    If i Have a select statement that needs two different tables
    and a where clause with only 1 join and the rest of conditions dependent on only 1 table such as:
    select .... from table a, table b
    where a.col1 = b.col1
    and b.col2 some condition
    and b.col3 some condition;
    is it better/optima for performancel for me to have the join right at the beginning of the where clause or after table b has been filtered out such as:
    select ... from table a, table b
    where b.col2 some condition
    and b.col3 some condition
    and a.col1 = b.col1

    Hi,
    The order of conditions in a WHERE clause doesn't effect performance; the Cost-Based Optimizer will decide how to perform them.
    The order can make a difference on how easy it is to understand and maintain the code. I find ANSI join syntax far better for this:
    select      ...
    from      table      a
    join     table      b     on     a.col1     = b.col1
    where      b.col2  <some condition>
    and      b.col3  <some condition>
    ;

  • How to avoid repeat where clause in oracle sql

    Hi,
    Please find my query below, I need a help to avoid duplication of **where** clause in my query.
    In my below query, **JOIN** condition is same for both the queries and **WHERE** condition also same except this clause "and code.code_name="transaction_1"
    In **IF ** condition only credit and debit is swapped on both queries, due to this **Credit and Debit** and this where clause "and code.code_name="transaction_1" I am duplicating the query. Can you please give some solution to avoid this duplication. I am using oracle 11g
    select DAY as business_date,sum(amount) as AMOUNT, type_amnt as amount_type,test_code as code_seg
    from
    select table1_alias.date as DAY,code.code_numb as test_code,
    CASE
    WHEN qnty_item > 0 THEN 'credit'
    ELSE 'debit'
    END as type_amnt,
    "25.55" as amount
    from
    code_table code,
    table1 table1_alias
    join table2 table2_alias on table1_alias.id = table2_alias.id
    where
    table1_alias.state="OK"
    and table1_alias.type="R"
    and code.code_type="Movie"
    and code.code_name="transaction_1"
    UNION ALL
    select table1_alias.date as DAY,code.code_numb as test_code,
    CASE
    WHEN qnty_item > 0 THEN 'debit'
    ELSE 'credit'
    END as type_amnt,
    "25.55" as amount
    from
    code_table code,
    table1 table1_alias
    join table2 table2_alias on table1_alias.id = table2_alias.id
    where
    table1_alias.state="OK"
    and table1_alias.type="R"
    and code.code_type="Movie"
    and code.code_name="transaction_2"
    group by DAY, test_code,type_amnt
    Thanks

    user10624672 wrote:
    Hi,
    Please find my query below, I need a help to avoid duplication of **where** clause in my query.
    In my below query, **JOIN** condition is same for both the queries and **WHERE** condition also same except this clause "and code.code_name="transaction_1"
    In **IF ** condition only credit and debit is swapped on both queries, due to this **Credit and Debit** and this where clause "and code.code_name="transaction_1" I am duplicating the query. Can you please give some solution to avoid this duplication. I am using oracle 11g
    select DAY as business_date,sum(amount) as AMOUNT, type_amnt as amount_type,test_code as code_seg
    from
    select table1_alias.date as DAY,code.code_numb as test_code,
    CASE
    WHEN qnty_item > 0 THEN 'credit'
    ELSE 'debit'
    END as type_amnt,
    "25.55" as amount
    from
    code_table code,
    table1 table1_alias
    join table2 table2_alias on table1_alias.id = table2_alias.id
    where
    table1_alias.state="OK"
    and table1_alias.type="R"
    and code.code_type="Movie"
    and code.code_name="transaction_1"
    UNION ALL
    select table1_alias.date as DAY,code.code_numb as test_code,
    CASE
    WHEN qnty_item > 0 THEN 'debit'
    ELSE 'credit'
    END as type_amnt,
    "25.55" as amount
    from
    code_table code,
    table1 table1_alias
    join table2 table2_alias on table1_alias.id = table2_alias.id
    where
    table1_alias.state="OK"
    and table1_alias.type="R"
    and code.code_type="Movie"
    and code.code_name="transaction_2"
    group by DAY, test_code,type_amnt
    ThanksA very brief glance and it looks to me like the only difference between the 2 queries are
    and code.code_name="transaction_1"In the first portion and
    and code.code_name="transaction_2"So if that's all that is difference, you'd just want to use a single query (no union's) with
    and code.code_name in ('transaction_1', 'transaction_2')Cheers,

  • Handeling more than 1000 columns in where clause

    Hi,
    I am using oracle 9i. We are creating a select query and adding where clause at runtime.
    The no of clolumns in where clause depends on the results from another enterprise app. There may be any no of columns from 0-N. Till 1000 columns every thing works fine but when it goes beyond 1000 it gives the following error:
    ERROR:
    java.sql.SQLException: ORA-01795: maximum number of expressions in a list is 100
    0
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:2321)
    at oracle.jdbc.oci8.OCIDBAccess.parseExecuteDescribe(OCIDBAccess.java:12
    55)
    at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.jav
    a:2391)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
    nt.java:2672)
    at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:
    572)
    Please help.
    Thanks in advance.

    Thanks Archana,
    You are right.
    I think i have not framed my question right.
    Actually its problem with "IN", which i am using in where clause. It working properly till 1000 expressions like "select * from foo where fooid in (n0,n1,n2......,n1000)".
    But throwing exception once the count increases to 1000 like
    "select * from foo where fooid in (n0,n1,n2......,n1000,n1001,n1002)".
    Thanks,
    Mukesh

  • Bad performance when calling a function in where clause

    Hi All,
    I have a performance problem when executing a query that contains a function call in my where clause.
    I have a query with some joins and a where clause with some regular filters. But one of these filters is a function, and its input parameters are columns of the tables used in the query.
    When I run it with only a few rows in the tables, it goes ok. But as the number of rows grows, performance falls geometrically, even when my where clause filters the result to only a few rows.
    If I take the function call off of the where clause, then run the query and then call the function for each returned row, performance is ok. Even when the number of returned rows is big.
    But I need the function call to be in the where clause, because I can't build a procedure to execute it.
    Does anyone have any clue on how to improve performance?
    Thanks,
    Rafael

    You have given very little information...
    >
    If I take the function call off of the where clause, then run the query and then call the function for each returned row, performance is ok. Even when the number of returned rows is big. Can you describe how you measured the performance for a big result set without the function? For example lets say there had been 10.000 rows returned (which is not really big, but it is astarting point). Did you see all 10.000 rows? A typical mistake is to execute the query in some tool like Oracle SQL Developer or TOAD and measure how fast the first couple of rows are returned. Not the performance of the full select.
    As you can see from this little detail there are many questions that you need to address first before we can drill down to the root of your problem. Best way is to go through the thread that Centinul linked and provide all that information first. During the cause of that you might discover that you learn things on the way that help a lot for later tuning problems/approaches.
    Edited by: Sven W. on Aug 17, 2009 5:16 PM

  • Where clause with conditions

    Hi all,
    I have a report that is to be filtered based on user input into a text field and drop down list.
    The goal is to let the user enter either an exact value (based off auto-complete functionality), or use the wildcard character, %
    This is where the drop down comes in. If they select value1, the autocomplete, exact value is used and the where clause would look like something below,
    select col1, col2, col3
    from table
    where :P1_FILTER in (select distinct col2 from another_table)If they select value2, then the where should process using the like function and %s. Something like,
    select col1, col2, col3
    from table
    where :P1_FILTER like (select distinct col2 from another_table)How can I take care of this in 1 where clause? I'm sort of stuck trying to figure it out.
    Thank you for any help.
    -Chris

    I don't believe the way you have it coded is correct.. Can you move it over o SQL Developer of the SQL Commands page in APEX and trying running your query? If it doesn't work there then your SQL is coded wrong.
    Since you are trying to have One or The Other condition be used for your query, I would think the Function returning Sql Code would be the obvious selection, but I could be wrong here...
    Thank you,
    Tony Miller
    Webster, TX
    A lady came up to me on the street, pointed at my suede jacket and said "Do you know a cow was murdered to make that jacket?"
    "I didn't know there were any witnesses", I replied " Now I'll have to kill you too"

  • The to_date() error in where clause of proc code

    In a proc code, firstly I use "SELECT to_char(f_date_1, 'DDMONYY') into :char_date FROM TBL_1;" to get the value of f_date_1.
    Then I use "SELECT ID FROM TBL_2 WHERE f_date_2 = :char_date;" to get the value of ID according char_date.
    In table, the type of f_date_1 and f_date_2 is DATE.
    char_date is "char char_date[10]".
    My question is:
    1. If I use WHERE f_date_2 = to_date(:char_date, 'DDMONYY'), it will prompt: "-1861, ORA-01861: literal does not match format string".
    2. If I use WHERE f_date_2 = :char_date, it will work well.
    Since the type of f_date_2 is DATE and the type of char_date is CHAR, why does to_date(:char_date, 'DDMONYY') have problems?
    Thanks.

    I was not able to duplicate the error you got, but I did spot something that may be affecting your results:
    *Set up test table using HR.EMPLOYEES*
    create table TEST_DATE as
    select employee_id, last_name, hire_date
    from employees
    var char_date char(10)
    begin
    select to_char(hire_date,'DDMONYY') into :char_date
    from test_date
    where rownum = 1;
    end;
    *case 1*
    select *
    from test_date
    where hire_date = to_date(:char_date,'DDMONYY')
    *case 2*
    select *
    from test_date
    where hire_date = :char_date --> this assumes a implicit char to date conversionWhile I got case 2 to work, it assumes that the database is configured to recognize the character mask as a valid string format. If you tried running that query on a different database, this query may fail as well.
    To verify why case 1 may not have worked, do a quick check:
    select :char_date from dualIt is possible that you may have applied a different character mask between your first query:
    >
    SELECT to_char(f_date_1, 'DDMONYY') into :char_date FROM TBL_1;
    >
    and the WHERE clause of your second query:
    >
    WHERE f_date_2 = to_date(:char_date, 'DDMONYY')
    >
    RP

  • Regarding WHERE clause

    Hello,
    I have a stupid question...
    Let's suppose I have a query like this one:
    SELECT *
       FROM table_t
    WHERE ...
       AND TRUNC(SYSDATE) BETWEEN TO_DATE('01/01/2011', 'DD/MM/YYYY') and TO_DATE('02/01/2011', 'DD/MM/YYYY')And let's suppose this query takes a long time to execute because I'm having million records in the table. If I launch this query at 23:59 the 01/01/2011 and it takes more than one minutes to execute, I guess the first minute TRUNC(SYSDATE) will return 01/01/2011 and after midnight the TRUNC(SYSDATE) will return 02/01/2011 and the where clause is no more verified?
    Is this how Oracle works or TRUNC(SYSDATE) is computed only once before running the WHERE clause?
    Thanks for your help,

    The SYSDATE is evaluated at the beginning of the statement. So, even if the system clock changes while the statement is running, it holds a "constant" (actually "consistent") value for TRUNC(SYSDATE).
    Hemant K Chitale

Maybe you are looking for

  • 0EC_PCA_1 Accumulated Balance field issue

    Hi Gurus/Experts, We have a standard extractor in ECC side: 0EC_PCA_1 wherein USD currency (CURRTYPE/Currecny type = 30) is giving out a sum value for Accumulated Balance field of -300,962.66 for Plant A. I checked on its corresponding EUR value (CUR

  • How can I back up Contacts synced from an Exchange server into iCloud?

    Hi everybody. I would like to back up into iCloud my Contact (and Calendars too) which I have  previously synced to the device ( that is an iPad air running iOS 8.2.1) from an Exchange server. The green flags in Settings / ICloud are duly switched on

  • Apps on iPad Air won't update - just open

    When I select UPDATE for an app in the App Store, the App opens instead of updating.   When I return to the App Store, the update remains. This started after updating to iOS 8. Does anyone have any suggestions on how to fix?

  • How do I play videos with premier elements 10

    I have just uploaded some mixed photos and videos to my computer using adobe premier elements 10 but I cant play the videos. A box appears saying i need the compression de compression codex. Where do Iget these?

  • Problem with Macbook Pro 15 (Late 2007)

    What I did is that I tried to install a 500gb threw the macbook. Then suddently, the macbook pro did not wanted to reconize the gb that I put in. I tried all the shortcut keys and none of them work. It only stayed with a Apple Logo with the circle on