To_date
DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: To_date

  1. #1
    Join Date
    Feb 2003
    Location
    Slovakia, Europe
    Posts
    72

    To_date

    Hi

    I have a problem with cross-impact TO_DATE function and column name.

    In table TAB_A is a column with name "TO_DATE" and I would like to use TO_DATE function by selecting from this table in PL/SQL block.

    BEGIN
    SELECT ..., TO_DATE(NULL,'dd.mm.yyyy'), ... FROM tab_a
    UNION ALL
    SELECT ..., date_column, ... FROM tab_b;
    END;
    -- in this case pl/sql compilation failed, because of bad table column using


    BEGIN
    SELECT ..., STANDARD.TO_DATE(NULL,'dd.mm.yyyy'), ... FROM tab_a
    UNION ALL
    SELECT ..., date_column, ... FROM tab_b;
    END;
    -- in this case pl/sql compilation is ok, but when pl/sql is running, the following error is returned -> "invalid column name"


    Pls. don't tell me, why i've created a column with that name... I haven't, it has been existed.

  2. #2
    Join Date
    Jan 2003
    Location
    Hull, UK
    Posts
    220
    Hi,

    How about giving a Column Alias, Wud it work ?

    SS

  3. #3
    Join Date
    Feb 2003
    Location
    Slovakia, Europe
    Posts
    72

    Oracle 8i

    It is Oracle 8i (I've forgotten to write it)

  4. #4
    Join Date
    Feb 2003
    Location
    Slovakia, Europe
    Posts
    72

    Alias ?

    I don't know what do you mean with column alias ?

    .., to_date(..) as alias_name, ..


    ??

  5. #5
    Join Date
    Jan 2003
    Location
    Hull, UK
    Posts
    220
    Hi,

    select to_date as TODAYS_DATE from EMP;

    Does the above works in 8i or not.

    SS

  6. #6
    Join Date
    Feb 2003
    Location
    Slovakia, Europe
    Posts
    72

    of course

    yes it works... but i still don't know how can alias help me in this problem...

  7. #7
    Join Date
    Jan 2003
    Location
    Hull, UK
    Posts
    220
    hey i tried the below thing and it works fine for me..

    create table abc1(to_date date);

    insert into abc1 values (to_date('10/01/04','dd/mm/rr'))

    select to_date(to_date,'dd/mm/rrrr') as new_date from abc1

    I m not sure whether i m understanding the problem correctly or not

    SS

  8. #8
    Join Date
    Feb 2003
    Location
    Slovakia, Europe
    Posts
    72

    probalby not :)

    of course it is working like you have written...

    but when it is in PL/SQL block and you use statement with union all... i don't know why it doesn't work...

  9. #9
    Join Date
    Feb 2003
    Location
    Slovakia, Europe
    Posts
    72

    try it

    try to run this

    begin
    select to_date(to_date,'dd/mm/rrrr') as new_date from abc1;
    end;

  10. #10
    Join Date
    Jan 2003
    Location
    Hull, UK
    Posts
    220
    Why do u want to do that,,,unless u want to store it in a variable or open a cursor.

    dont u thin u shuld have a INTO clause.

    do u get me?

    SS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width