Selecting date column from a table

hi
I have a problem that looks wierd for me.
I have a table called blog_post which has a date field called publish_date
I have done this first.
alter session set nls_date_format='dd/mm/yyyy';
then
SQL> select publish_date from blog_post;
PUBLISH_DA
09/07/2007
02/07/2007
02/07/2007
02/07/2007
09/07/2007
now the wierd thing is that when i am selectin the same date it is not returning anything
SQL> select publish_date from blog_post where publish_date='09/07/2007';
no rows selected
Thanks for any help.
Ganesh

I don't know anything about Hibernate, but the reason why you need to specify the trunc(publish_date) = to_date('09/07/2007','dd/mm/yyyy') is because of the way that Oracle stores date/time internally.
It's labelled as a date field, but the time is automatically stored as well. So, if you're just wanting to compare the date to another date, you need to ignore the time part of the column - the trunc function does this.
As for the "to_date(<date>, <date mask>)", well, you want to compare a date to a date, not a string. You could rely on the implicit conversion, governed by the nls settings, but I really, really, really wouldn't. In fact, I can't stress enough how much of a bad idea that would be! It's best to make things explicit.

Similar Messages

  • Select sql running very long when made to select many columns from a table

    Hi,
    I am using an Oracle DB 10g. I have a table with 250 columns and I need to select 200 columns out of them. The table holds around 0.1 million rows. But when I run the select sql it takes 15 mins to return .1 million rows. Where as if I select only 10 or 15 columns the sql runs in less than a minute returning same number of rows. My sql looks like below:
    select p.col1,p.col2,.......,p.col200
    from table Parent p;
    The table also has a Primary key Index but it does not seem to be using it even when I forced an Index hint. Could you pls help?

    961796 wrote:
    I am using an Oracle DB 10g. I have a table with 250 columns and I need to select 200 columns out of them. The table holds around 0.1 million rows. But when I run the select sql it takes 15 mins to return .1 million rows. Where as if I select only 10 or 15 columns the sql runs in less than a minute returning same number of rows. My sql looks like below:
    As Sven points out, it is likely that most of your time is network (and client) time. You are sending 20 times as much data (based on column counts, at any rate) across the network, and concerned that it's taking 15 times as long.
    If you're testing from SQL*Plus then setting the arraysize to a value larger than the default might help.
    If you have control over the SQL*Net settings then you may get some benefit by adjusting the SDU sizes at both ends of the link.
    If you have control over the tcp configuration (transmit and receive buffer sizes) then you may get some benefit by adjusting these.
    Simple test, by the way, if you're on SQL*Plus
    set autotrace traceonly statistics
    select ...This will dump your data in the bit bucket as it arrives giving you
    a) the database time plus network time
    b) some statistics including the volume of data down the network and the number of network round-trips that Oracle saw.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    Author: <b><em>Oracle Core</em></b>

  • Select LONG column from Remote table

    Hi to all.
    I have the following problem: I can't select a LONG column from remote database, when there are Join operation in the query. Example:
    SELECT long_column FROM remote_table@DB
    -> that's OK, but:
    SELECT long_column FROM remote_table@DB INNER JOIN remote_table2@DB ON ...
    -> returns: "ORA-00997: Illegal use of LONG datatype"
    I cannot even perform (because there a LONG column in the joined table):
    SELECT nonlong_column FROM remote_table@DB INNER JOIN remote_table2@DB ON ...
    That's very strange to me because:
    SELECT long_column FROM local_table INNER JOIN local_table2 ON ...
    -> is OK!
    Can someone help me to SELECT a long column from remote in SELECT query with JOIN clause!
    Thanks a lot!

    Hi
    "Distributed queries are currently subject to the restriction that all tables locked by a FOR UPDATE clause and all tables with LONG columns selected by the query must be located on the same database. " by otn docs.
    I have no idea.
    Ott Karesz
    http://www.trendo-kft.hu

  • Selecting only columns from a table

    Could someone help me with a SQL query to select all the columns in a table as an array?

    Hello
    if you are on 9i upward, you can define a pl/sql table of the rowtype and use bulk collect to populate that table, otherwise, you can create separate array types for each column:
    create table dt_test_tab (id number, col1 varchar2(10));
    insert into dt_test_tab values(1, 'X');
    insert into dt_test_tab values(2, 'X');
    insert into dt_test_tab values(3, 'X');
    insert into dt_test_tab values(4, 'X');
    insert into dt_test_tab values(5, 'X');
    commit;
    declare
        type tt_TestTab is table of dt_test_tab%rowtype index by binary_integer;
        type tt_TestTabid IS TABLE OF dt_test_tab.id%type index by binary_integer;
        type tt_TestTabcol1 IS TABLE OF dt_test_tab.col1%type index by binary_integer;
        lt_TestTab     tt_TestTab;
        lt_Id          tt_TestTabId;
        lt_col1        tt_TestTabcol1;
    begin
        --use the rowtype array
        select
             id,
             col1
        BULK COLLECT INTO
             lt_testtab
        FROM
            dt_test_tab;
       --use the individual column arrays
        select
             id,
             col1
        BULK COLLECT INTO
             lt_id,
             lt_col1
        FROM
            dt_test_tab;
        dbms_output.put_line('loop through the rowtype array');
        FOR x in lt_TestTab.FIRST..lt_TestTab.LAST LOOP
           dbms_output.put_line(to_char(lt_TestTab(x).id)||to_char(lt_TestTab(x).col1));
        end loop;
        dbms_output.put_line('loop through the two column arrays');
        FOR x in lt_Id.FIRST..lt_Id.LAST LOOP
           dbms_output.put_line(to_char(lt_Id(x))||to_char(lt_Col1(x)));
        end loop;
    END;

  • Selecting a column from a table conditionally

    I'm trying this select statement (example):
    select np.phone_number from name_phone np, reservation_general_view rgv
    where rgv.resort='HVILLA'
    In this table there is a column called "phone_type" and I only want my column to display values that are associated to the column when the "phone_type" = 'EMAIL'
    I tried this:
    select np.phone_number(select np.phone_number from name_phone np where np.phone_type='EMAIL')
    from name_phone np, reservation_general_view rgv
    where rgv.resort='HVILLA'
    This doesn't seem to work...can someone tell me how to do that?
    Message was edited by:
    JonnyOpera

    select phone_number from name_phone
    where resort='HVILLA'
    and phone_type='EMAIL'

  • Employee related data columns  from  hrms table

    i am new to HRMS tables.
    i have to create employee report temporary table, columns are given below.
    Gender code
    Gender Description
    Grade code
    Grade Description
    Country name
    Nationality
    from which tables i can find these columns.i need employee tables names where i can find these columns.

    hi,
    there is no table with name per_all_populate_f
    I guess you are referring to per_all_people_f
    for grades the table are per_valid_grades
    for positions hr_all_positions_f,per_position_definitions

  • Selecting columns from two table is slow but same

    I am selecting 27 columns from two tables
    which running for more than 30 minutes. but
    if I select count(*) with the same query
    except the columns it is coming in seconds.
    Where is the error?

    If you post
    1) The table definitions for the underlying tables
    2) The indexes that are on the tables
    3) The two SQL statements you're running
    4) The explain plan for both statements
    we can probably be of some assistance.
    My guess is that the count(*) is able to return much more quickly because the optimizer is able to use a significantly faster query plan that is based on an index which the longer-running query cannot utilize. Without the information I've requested, though, it's hard to do more than speculate.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to check  which column data differs from master table and archive table

    Hi All,
    i have two tables, table a (a1 number,a2 varchar2,a3 varchar2) and table b (b1 number,b2 varchar2,b3 varchar2).
    how to check the data in both the table are same( including all columns).
    data in a.a1 is same as b.b1 and a.a2 is same as b.b2 like that.
    if they not same , i need to know which field differs.
    Kindly Share ur ideas.

    887268 wrote:
    thanks Sven W. ,
    above reply clearly shows what my question is.
    one column must be primary key, based on that key i need to find out which are the fields having different data..
    im strugling with this, i tried the following already, but not able to get.
    select the columns from a MINUS select the columns from b.
    -- from this i can find whether the difference occurred or not.
    but i cant able to get which are the fields value changed.Good. Then you would match the rows using the PK column and need to compare the columns
    Instead of a MINUS + UNION ALL + MINUS we can now use a FULL OUTER JOIN
    It is a little task to write out all column names, but 40 columns can be handled.
    This statement would show you both tables with matching rows on the same line.
    select a.*, b.*
    from a
    FULL OUTER JOIN b on a.id = b.idNow filter/check for mismatches
    select case when a.col1 != b.col1 then 'COL1 value changed'
                    when a.col2 != b.col2 then 'COL2 value changed'
                    when a.col3 != b.col3 then 'COL3 value changed'
             end as compare_result
            ,a.*, b.*
    from a
    FULL OUTER JOIN b on a.id = b.id
    /* return only non matching columns */
    where (a.col1,a.col2,a.col3) != (b.col1,b.col2,b.col3) You might need to add nvls to take care of null values. Test this!
    Another way could be to group upon the primary key
    select *
    from (
      select id 
               ,count(distinct col1)-1 cnt_col1
               ,count(distinct col2)-1 cnt_col2
               ,count(distinct col3)-1 cnt_col3
       from
         select 'A' source, a.*
         from a
         UNION ALL
         select 'B' source, b.*
         from b)
       group by ID
    /* only records with differences */
    where 1 in (cnt_col1, cnt_col2, cnt_col3)
    ;The count columns will hold either 1 or 0. If it is 1 then this column has a difference.

  • Creating Time Dimension from date columns in fact tables.

    I remember watching a demo from a BI Tool a couple years ago, wich I swear was OBIEE, and the presentator stated it was possible to create a Time Dimension in the admin tool, based on a date column in other table.
    Can you guys tell me if there's such functionality in OBIEE?
    If so, how could I achieve that?!
    Thanks in advance!
    Marcos

    hi,
    You are trying to make Fact table as Dim table ???
    Fact table has some dim columns??
    We can do this by making a fact table as dim table ,create a dim hierarchy on that table
    Year level :Extract(year from fact_date_column)
    Month and year  level:CAST (Extract(month from fact_date_column) As CHAR(5) ) || CAST (Extract(yearfrom fact_date_column) As CHAR(5) )
    Like this
    But,be careful while doing this make sure that all joins and content levels are good
    As per my knowledge this is not a good way,Experts can add some words lets see!!!!!! :-)
    thanks,
    saichand.v

  • How can I select columns from a table EMP, using Select statement?.

    Hi Friends,
    How can I select columns from a table EMP?.
    I want to select columns of EMP table, using select statement.
    Please reply me urgently.
    Shahzad

    Something like this:
    scott@DBA> select empno,ename,job from emp;
         EMPNO ENAME      JOB
          7369 SMITH      CLERK
          7499 ALLEN      SALESMAN
          7521 WARD       SALESMAN
          7566 JONES      MANAGER
          7654 MARTIN     SALESMAN
          7698 BLAKE      MANAGER
          7782 CLARK      MANAGER
          7788 SCOTT      ANALYST
          7839 KING       PRESIDENT
          7844 TURNER     SALESMAN
          7876 ADAMS      CLERK
          7900 JAMES      CLERK
          7902 FORD       ANALYST
          7934 MILLER     CLERK
    14 rows selected.Check the documentation:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#sthref9697
    Message was edited by:
    Delfino Nunez

  • Update data provider queryspecification wiith columns from multiple tables

    Hi
    I have scenario like I need  updated a queryspecificaiton with columns from multiple tables
    1. Ex:
      <bOQuery name="Query">
              <resultObjects identifier="DS0.DO1" name="A$Application_ID"/>
              <resultObjects identifier="DS0.DO2" name="A$Column_Name"/>
    A$Application_ID is from Table A and A$Column_Name from table B
    The query is not adding to dataprovier when I am trying to updated from REST API.
    Please help me.
    Thanks
    Kalyan

    Have a look at the Business Intelligence platform RESTful Web Service Developer Guide, section 3.4.7 (p. 197) - Report structure: getting and updating the structure (specifications) of a report, may be a good place to start(?). Also see KBA 1952419 - How to update the properties of a web intelligence report using RESTful web service SDK .
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • Select a row from a table and throw an url

    Hi experts,
    I'm trying to select a row from a table in Visual Composer. What I need to do it's to click over this row and throw an Url. At the moment, I've added a column with a Pushbutton with the formula to show the link; it works fine. But I need to do it without buttons just selecting the row.
    Is there anyboby who knows about that?
    Thanks a lot.
    Belen

    Hi
    To do this you will have to use a data store and a guard condition on the line which is triggered by the select action. You need to store a value in the data store each time a select action is performed. The guard condition should check for this and only perform the action when the value in the data store is greater than 0.
    Jarrod Williams

  • Value Set whose Data come from customize table with distinct record

    Dear All,
    I am new in Oracle EBS, currently i am creating value set whose data come from customize table which have 40 duplicate record in which distinct column return 27 record .
    Table XX_ROUND_SET
    Columns (Transactions_id,set_record)
    Total Record (40)
    Distinct Record (Set_Record --> 27)
    I just want to show only 27 record in it.
    Thanks
    Rehan

    Hi Rehan,
    PL.IGNORE MY EARLIER UPDATE AND TREAT THIS UPDATE AS YOUR SOLUTION.
    Method 1
    Create the VIEW based on DISTINCT values; use the VIEW for creates the VALUESET.
    Method 2
    Paste the QUERY in TABLE field with alias name, and give the column name (with alias name).
    (in your case )
    TABLE NAME : ( select distinct transactions_id, set_record from XX_ROUND_SET ) Y
    VALUE : Y.transactions_id
    HTH
    Sanjay

  • Columns from different tables displayed in an ADF table format

    I have a many to one relationship between 2 tables (checklist -> subcontract). I would like to display columns from each table on a web page in an ADF Read Only Table format. I created a method that returns the data I need from the tables. When I drag that method over to my page JDev I'm only allowed to select columns from either the checklist table OR the subcontract table. I need one column from the subcontract table and several columns from the checklist table. I'm using JDev 10.1.3.2 and an Oracle 11g database. Thank you in advance.
    -Wade

    Thank you for your response. I ended up creating a new getter in the Checklist table which refers to the column in the Subcontract table. Then I was able to create a table column for that returned value.
    Thanks again!
    -W

  • I have a table with info and would like to select an item from that table

    Hi
    I have a table with info (course info that I searched for) and would like to select an item from that table to use for further use in my application.
    It must work more or less like the tree structure where I can use an On Action select.
    In other words; let say I am looking for all courses with "Advisor" it its descriptin / name, I want to click on one of the names and use it lets say to book people on.
    Could some please assist me with this.
    Regards
    Debbie

    Hi
    The datasource for my table is the node searchcatalog.  Under this node there is an attribute calles description where the items found are displayed.
    I changed my code as follow:
    data: ls_table type wd_This->Elements_searchcatalog,
          lr_element type ref to if_wd_context_element.
      DATA lo_nd_searchcatalog TYPE REF TO if_wd_context_node.
      DATA lo_el_searchcatalog TYPE REF TO if_wd_context_element.
      DATA ls_searchcatalog TYPE wd_this->element_searchcatalog.
    navigate from <CONTEXT> to <SEARCHCATALOG> via lead selection
      lo_nd_searchcatalog = wd_context->get_child_node( name = wd_this->wdctx_searchcatalog ).
    @TODO handle not set lead selection
      IF lo_nd_searchcatalog IS INITIAL.
      ENDIF.
    get element via lead selection
      lo_el_searchcatalog = lo_nd_searchcatalog->get_element(  ).
    @TODO handle not set lead selection
      IF lo_el_searchcatalog IS INITIAL.
      ENDIF.
    get all declared attributes
      lo_el_searchcatalog->get_static_attributes(
        IMPORTING
          static_attributes = ls_searchcatalog ).
    lo_nd_searchcatalog->get_lead_selection->( exporting index = wdevent->index importing
    element = lr_element ).
    lr_element->get_static_attributes->( importing static_attributes = ls_table ).
    wd_context->set_attribute( exporting name = 'SELECTED' value = ls_table-description ).
    When I try to activate it errors with: List elements that take up more than one line is not allowed.  This error at the sentence: lo_el_searchcatalog->get_static_attributes(
    If you cannot assist me further I will understand.  Thank you.

Maybe you are looking for

  • ITunes will no longer sync photos to "my" iPod

    I get this message when I try to sync photos (Aperture3). The options are grayed out. iPod touch 2.2.1 version/ OSX 10.6.8 iMac24 duo core. iPod is almost empty(14gb avail) Anyone having this problem? Any solution?

  • Asset depreciation date setting

    Hi , I am facing difficulty . When asset is acquired through *Purchase order* and then *Goods Receipt* Document date: 10.03.2011, *Posting date: 14.06.2011,* system populate the *depreciation start date as 14.06.2011*, here system take this date from

  • Scroll bar and alternate row color in Trinidad table

    I am using Jdeveloper 11g I have two question on tinidad table see below sample code *1)How to set scroll bar on table* *2)how to set different colors for alternate rows* <tr:form> <tr:panelGroupLayout> <tr:panelFormLayout inlineStyle="width:965px; h

  • How do I connect airport to my stereo?

    All, Please forgive my NooB-ness, but I'm confused.  I am a new iPhone user (can't believe it took this long) and I want to stream music wirelessly to my stereo system.  The stereo has multiple speakers attached, but it is not attached to my TV.  It

  • Outlook201​0 Search finds non-visibl​e email headers?

    Dear fellow Turkey-weekenders, I'm trying to help someone configure their new Outlook 2010 email client to work with their existing Verizon POP3 email account.  I believe we've jumped through most of the hoops correctly but have a minor mystery! Afte