execute immediate 'update temp1 set c10= (select ''['' || to_char(LogTIME,''YYYY.MM'') || '']'' from TempTable )';
--上面结果返回[2009.01]execute immediate 'update temp1 set c10= (select to_char(LogTIME,''YYYY.MM'') from TempTable )';
--上面结果返回2009.01.01为什么?我怎么才能让下面的语句返回2009.01这种格式?

解决方案 »

  1.   

    呵呵,就是啊,超级奇怪的问题.我郁闷了两天了.--如果象下面这样直接执行,也没有问题update temp1 set c10= (select to_char(LogTIME,'YYYY.MM') from TempTable )
      

  2.   

    execute immediate 'update temp1 set c10= (select substr(to_char(LogTIME,''YYYY.MM''),1,7) from TempTable )';
    这样呢
      

  3.   

    但是不加[.]是可以的.execute immediate 'update temp1 set c10= (select to_char(LogTIME,''YYYYMM'') from TempTable )'; 
    返回的是200901
      

  4.   

    蒙了从来没遇到过这事SQL> select to_char(csrq,'YYYY.MM') from dbzg where rownum<10;TO_CHAR(CSRQ,'
    --------------
    1956.01
    1954.05
    1957.11
    1954.05
    1954.07
    1958.06
    1969.02
    1954.02
    1982.02已选择9行。SQL> ed
    已写入文件 afiedt.buf  1* select to_char(csrq,'YYYY.MM.dd') from dbzg where rownum<10
    SQL> /TO_CHAR(CSRQ,'YYYY.M
    --------------------
    1956.01.07
    1954.05.16
    1957.11.25
    1954.05.30
    1954.07.07
    1958.06.11
    1969.02.23
    1954.02.15
    1982.02.15已选择9行。
      

  5.   

    tryexecute immediate 'update temp1 set c10= (select to_char(LogTIME,''YYYY"."MM'') from TempTable )
      

  6.   

    如果按照楼上的这么写,返回的是200901,呵呵和直接写yyyyMM效果是一样的.我是想在中间加个.或者加个-什么的
      

  7.   


    execute immediate 'update temp1 set c10= (select ''['' || to_char(LogTIME,''YYYY.MM'') || '']'' from TempTable )'; 
    --上面结果返回[2009.01] execute immediate 'update temp1 set c10= (select to_char(LogTIME,''YYYY.MM'') from TempTable )'; 
    --上面结果返回2009.01.01 但是不加.取出来的数据是正确的. 
    execute immediate 'update temp1 set c10= (select to_char(LogTIME,''YYYYMM'') from TempTable )'; 
    返回的是200901 为什么? 我怎么才能让上面的语句返回2009.01这种格式?
      

  8.   

    问题解决,疑问还在:execute immediate 'update temp1 set c10= (select to_char(LogTIME,''YYYY" - "MM'') from TempTable )yyyy和MM当中用一个全角的-就解决了,但是用.或者半角的-就是不行.超级奇怪,怀疑是不是Oracle的BUG.