waterye

          #

          Spring JDBC's Bug

          聽過多次投訴Spring JDBC有bug, 今天自己總算遇到.

          String querySql = "......"// 400行左右
          Object[] params = new Object[] { beginDate, endDate,  beginDate, endDate, beginDate, endDate, beginDate, endDate, beginDate, endDate} ;
          return getJdbcTemplate().query(querySql, params, new OracleRowMapper());

          設置10個參數時, 導致出現ora-00932錯誤, 而在sqlplus or pl/sql developer中正常運行, 改成拼字符串后正常.

          Spring的版本為1.2.2, 具體原因還未查找, 估計是Spring JDBC的bug

          posted @ 2006-01-05 00:13 waterye 閱讀(780) | 評論 (0)編輯 收藏

          Happy New Year!

          Happy New Year To Everyone!

          posted @ 2005-12-31 18:04 waterye 閱讀(507) | 評論 (1)編輯 收藏

          使用utl_file包進行io操作

          1. 首先要創建目錄
          CREATE DIRECTORY log_dir AS 'd:/ora_log';

          2. 寫log
          DECLARE
            p_dir       
          varchar2(100);
            p_filename  
          varchar2(100);
            output_file utl_file.file_type;
          begin
            p_dir       :
          = 'log_dir';
            p_filename  :
          = 'log_' || to_char(sysdate, 'yyyy_mm_dd_HH24_MI_SS'|| '.txt';
            output_file :
          = utl_file.fopen(upper(p_dir), p_filename, 'w');
            
          delete from test;
            utl_file.put(output_file, 'test:  ' || SQL%ROWCOUNT || ' rows deleted.');

            utl_file.new_line(output_file);
            
          insert into test
              
          select * from test@remotedb;
            utl_file.put(output_file, 
          'test:  ' || SQL%ROWCOUNT || ' rows inserted.');
            utl_file.new_line(output_file);
            utl_file.fclose(output_file);
            
          commit;
          EXCEPTION
            
          WHEN OTHERS THEN
                utl_file.put(output_file, 'error: ' || to_char(sysdate, 'yyyy-mm-dd HH24:MI:SS'));
                utl_file.new_line(output_file);
                utl_file.put(output_file, 'SQLCODE:'||SQLCODE);
                utl_file.new_line(output_file);
                utl_file.put(output_file, 'SQLERRM:'||SQLERRM);
                utl_file.new_line(output_file);
                utl_file.fclose(output_file);   
              
          ROLLBACK;
          end;
          /

          參考:
          1. PL/SQL Packages and Types Reference
          2. AskTom
          3. Itpub

          posted @ 2005-12-31 17:57 waterye 閱讀(864) | 評論 (0)編輯 收藏

          通過Database Links訪問Remote Database

          -- create database link
          create database link remotedb connect to user identified by pwd using 'remotedb';

          -- access remote object
          select * from test@remotedb;

          參考: SQL Reference

          posted @ 2005-12-31 15:27 waterye 閱讀(1176) | 評論 (0)編輯 收藏

          使用DBMS_SCHEDULER定時執行任務

          The DBMS_JOB package has been superseded by the DBMS_SCHEDULER package.

          create job
          BEGIN
            DBMS_SCHEDULER.CREATE_JOB(job_name      
          => 'delete_goods_job',
                                      job_type      
          => 'STORED_PROCEDURE',
                                      job_action    
          => 'delete_goods',
                                      repeat_interval 
          => 'FREQ=SECONDLY; INTERVAL=6',
                                      enabled       
          => true,
                                      comments      
          => 'delete goods data'                  
                                      );
          END;
          /
          drop job
          BEGIN
              DBMS_SCHEDULER.DROP_JOB(job_name 
          => 'delete_goods_job'); 
          END;
          /
          disable job
          BEGIN
              DBMS_SCHEDULER.DISABLE(name 
          => 'delete_goods_job'); 
          END;
          /
          enable job
          BEGIN
              DBMS_SCHEDULER.ENABLE(name 
          => 'delete_goods_job'); 
          END;
          /
          select jobs
          select * from USER_SCHEDULER_JOBS;
          query logs(感謝itpub的teddyboy)
          select * from ALL_SCHEDULER_JOB_RUN_DETAILS
          where owner = 'SCOTT'
          order by log_date desc
          delete logs
          delete from ALL_SCHEDULER_JOB_RUN_DETAILS
          where owner = 'SCOTT'

          參考:
          1. PL/SQL Packages and Types Reference
          2. http://www.itpub.net/378320.html

          posted @ 2005-12-30 18:42 waterye 閱讀(1509) | 評論 (0)編輯 收藏

          PL/SQL中顯示DML操作結果

          SET SERVEROUTPUT ON;
          BEGIN    
              
          delete from t;
              dbms_output.put_line(
          't:  ' || SQL%ROWCOUNT || ' rows deleted.');     
              
          COMMIT;
          EXCEPTION
            
          WHEN OTHERS THEN
              
          ROLLBACK;
          END;
          /

          參考: PL/SQL User's Guide and Reference

          posted @ 2005-12-30 13:55 waterye 閱讀(581) | 評論 (0)編輯 收藏

          PL/SQL Transaction

          spool log.txt;
          select to_char(sysdate, 'yyyy-mm-dd HH24:MI:SS'from dual;
          BEGIN    
              
          delete from t where id = 2;
              
          delete from abc where id = 5;     
              
          COMMIT;
          EXCEPTION
            
          WHEN OTHERS THEN
              
          ROLLBACK;
          END;
          /
          select to_char(sysdate, 'yyyy-mm-dd HH24:MI:SS'from dual;
          spool 
          off;

          參考: PL/SQL User's Guide and Reference

          posted @ 2005-12-29 12:13 waterye 閱讀(664) | 評論 (0)編輯 收藏

          查看所有表的記錄數

          select 'select ''' || tname || ''' , count(rowid) from  ' || tname || ';' from tab where tabtype = 'TABLE';

          運行上面的查詢結果可以查看所有表的記錄數

          SQL*Plus:
          SQL>set feedback off;
          SQL
          >set heading off;
          SQL
          >spool count.sql
          SQL
          >select 'select ''' || tname || ''' , count(rowid) from  ' || tname || ';'  from tab where tabtype = 'TABLE';
          SQL
          >spool off;

          posted @ 2005-12-27 17:27 waterye 閱讀(1470) | 評論 (0)編輯 收藏

          IntelliJ IDEA Companion Products

          http://www.jetbrains.com/companions/index.html

          Refactor-J
           $49, Refactor-X  $39, Insepction-JS $49

          感覺有點奢侈, 實用性不高(有待進一步實踐), 安裝后并沒有快捷鍵, 需要自定義

          posted @ 2005-12-20 12:06 waterye 閱讀(612) | 評論 (0)編輯 收藏

          行列互換

               摘要: 使用sql進行行列互換  閱讀全文

          posted @ 2005-12-17 01:32 waterye 閱讀(868) | 評論 (0)編輯 收藏

          僅列出標題
          共18頁: First 上一頁 6 7 8 9 10 11 12 13 14 下一頁 Last 
          主站蜘蛛池模板: 太和县| 永济市| 万安县| 阳西县| 兰溪市| 龙陵县| 云阳县| 黄石市| 屏东市| 永春县| 稻城县| 尚义县| 岳阳市| 南溪县| 六枝特区| 海兴县| 华安县| 铅山县| 射阳县| 鲁山县| 沾化县| 江门市| 平塘县| 浦东新区| 泾阳县| 恩平市| 北京市| 梁河县| 镶黄旗| 固安县| 瑞昌市| 清流县| 金堂县| 剑川县| 崇义县| 荆门市| 涟水县| 长宁县| 云龙县| 万盛区| 繁昌县|