<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Neil的備忘錄

    just do it
    posts - 66, comments - 8, trackbacks - 0, articles - 0

    While reading through this thread http://forum.sun.com/jive/thread.jspa?threadID=99306 I had to check out how to invoke sequence.nextval for new row being appended.


    Here's how i did achieve this: 

    1. Created a Sequence and a Table: 
    CREATE SEQUENCE userid_seq MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE; 
    create table user_seq_test ( seq_col int not null primary key, char_col char(10) ); 

    2. Creating a Page to append rows into this table: 
    Add a datadource (say ora9i) to access this database table in Servers Window. Create a New Project, drag and drop user_seq_test table onto page. Dropa text field and bind it to user_seq_test.char_col. Add a button for "Append Row". Add a message group to be able to see the error messages on the page, when it happens.

    In the prerender, append a row to the dataprovider and get the sequence value for the new row and set it:
    try {
        RowKey rk 
    = user_seq_testDataProvider.appendRow();
        user_seq_testDataProvider.setCursorRow(rk);
                
        Connection conn 
    = null ;
        Statement sqlStatement 
    = null ;
        ResultSet rs 
    = null ;
                
        javax.naming.Context ctx 
    = new javax.naming.InitialContext() ;
        DataSource ds 
    = (DataSource)ctx.lookup("java:comp/env/jdbc/ora9i") ;                      
        conn 
    = ds.getConnection() ;                        
        
    // setup the connection             
        conn.setAutoCommit(true) ;                         
        
    // execute the query            
        sqlStatement = conn.createStatement() ;
        rs 
    = sqlStatement.executeQuery("select userid_seq.NEXTVAL from dual" ) ;
        rs.next() ;
        
    int nextvalue = rs.getInt(1) ;
        user_seq_testDataProvider.setValue(
    "seq_col"new Integer(nextvalue));
        rs.close();
        sqlStatement.close();
        conn.close();
    catch (Exception ex) {
        error(ex.getMessage());
        log(
    "Error Description", ex);
    }
    In the append Row Button action:
    try {
                user_seq_testDataProvider.commitChanges();
                user_seq_testDataProvider.refresh();
     } 
    catch (Exception ex) {
                log(
    "Error Description", ex);
                error(ex.getMessage());
     }

    So, when we want to use Sequence.NEXTVAL, you need to fetch the value and set this value on the auto-increment column in the appended row.

    We could use similar technique for calling functions and stored procedures.


    Author:  Sakthi

    Link  :  http://blogs.sun.com/sakthi/entry/a_scenario_with_oracle_sequence


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 国产亚洲精品a在线观看app| 亚洲Av无码乱码在线znlu| 亚洲精品狼友在线播放| 亚洲精品视频免费观看| 亚洲免费在线观看| 久久99精品免费一区二区| 久久亚洲国产精品五月天婷| 国产免费区在线观看十分钟| 亚洲综合日韩久久成人AV| 免费无码av片在线观看| 亚洲欧洲日韩国产综合在线二区| 污视频在线观看免费| 亚洲乱码一二三四区麻豆| 无码视频免费一区二三区| 亚洲AV综合色区无码一二三区 | 狠狠亚洲婷婷综合色香五月排名| 一个人看的www视频免费在线观看 一个人看的免费观看日本视频www | 日日噜噜噜噜夜夜爽亚洲精品 | 中国一级特黄的片子免费| 久久亚洲国产中v天仙www| 亚洲午夜免费视频| 亚洲伊人久久大香线蕉在观| 免费毛片在线播放| 国产精品青草视频免费播放| 亚洲成年人在线观看| 毛片免费在线播放| 人妻仑刮八A级毛片免费看| 亚洲不卡av不卡一区二区| 免费观看的毛片大全| 国产成人亚洲精品蜜芽影院| 亚洲精品亚洲人成人网| 成人午夜免费福利视频| 免费国产a理论片| 亚洲伊人tv综合网色| 国产乱色精品成人免费视频| 日本中文字幕免费高清视频| 中文字幕无码精品亚洲资源网久久 | 亚洲日本在线观看| 日本免费一区二区三区最新| 青柠影视在线观看免费| 亚洲欧好州第一的日产suv|