java隨記

          堅持就是勝利!

           

          oracle 嵌套游標以及java,oracle的時間處理

           

          create or replace procedure test is
           
                 ids VOD_CMS_OPERATION_REGION.id%type; //變量ids與VOD_CMS_OPERATION_REGION表的id字段的類型一致
                 cursor cur_region is    select id from VOD_CMS_OPERATION_REGION; //定義游標
                 phoneId VOD_CMS_OPERATION_REGION2PHONE.id%type;
                 cursor cur_phone is select id from   VOD_CMS_OPERATION_REGION2PHONE  //第二個游標
                         where VOD_CMS_OPERATION_REGION2PHONE.REGION_ID=ids ;
                  
          begin
                 open cur_region;  //打開游標
                 loop    //循環(huán)
                   fetch cur_region  into ids;    //逐行處理游標把值放入變量 ids
                   exit when cur_region%notfound; //沒找到游標退出循環(huán)
                  
                   open cur_phone;
                   
                   loop                           
                     fetch cur_phone into phoneId; 
                     exit when cur_phone%notfound;
                     update VOD_CMS_OPERATION_REGION2PHONE set creater=1 where VOD_CMS_OPERATION_REGION2PHONE.id=phoneId;
                   end loop;
                   close cur_phone;
                  
                 end loop;
                 close cur_region; 關閉游標
                 commit;
          end test;


          程序處理oracle時間

            Calendar ca = Calendar.getInstance(Locale.CHINA);
            ca.setTime(new Date());
            ca.set(Calendar.HOUR_OF_DAY, 0);
            ca.set(Calendar.MINUTE,0);
            ca.set(Calendar.SECOND, 0);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            StringBuffer buffer = new StringBuffer();
            buffer.append("select cmsAssetObject.regionIds from CmsAssetObject cmsAssetObject where cmsAssetObject.validdate >= " );
            buffer.append("to_date('"+sdf.format(ca.getTime())+ "','yyyy-MM-dd hh24:mi:ss') ");
            ca.set(Calendar.HOUR_OF_DAY, 23);
            ca.set(Calendar.MINUTE,59);
            ca.set(Calendar.SECOND,59);
            buffer.append(" and cmsAssetObject.expiredate <= ");
            buffer.append("to_date('"+sdf.format(ca.getTime())+ "','yyyy-MM-dd hh24:mi:ss') ");
            buffer.append(" and cmsAssetObject.isWeather = 1");

          posted on 2009-03-09 10:50 傻 瓜 閱讀(800) 評論(0)  編輯  收藏 所屬分類: 雜項

          導航

          統(tǒng)計

          常用鏈接

          留言簿(7)

          我參與的團隊

          隨筆分類

          隨筆檔案

          文章分類

          友情鏈接

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 崇文区| 盐山县| 固始县| 伽师县| 巴青县| 电白县| 南投县| 蓬溪县| 镶黄旗| 顺昌县| 西充县| 咸阳市| 若尔盖县| 喀喇| 木里| 肥西县| 翁牛特旗| 山阴县| 平度市| 阿尔山市| 房山区| 资阳市| 无为县| 健康| 信宜市| 太和县| 西畴县| 淮北市| 桃园市| 吉安县| 庄河市| 惠东县| 正镶白旗| 沈丘县| 满城县| 台前县| 临潭县| 沾化县| 临高县| 潞城市| 五寨县|