<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


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


    網站導航:
     
    主站蜘蛛池模板: 色网站在线免费观看| 久久国产亚洲精品麻豆| 亚洲av成人综合网| 69国产精品视频免费| 亚洲视频小说图片| 最近中文字幕大全中文字幕免费| 久久精品国产亚洲AV高清热| 日韩午夜理论免费TV影院| 亚洲AV无码国产精品麻豆天美| 另类免费视频一区二区在线观看| 亚洲精品成人片在线播放| 国产高清不卡免费视频| 久久亚洲国产精品成人AV秋霞 | 曰批全过程免费视频免费看| 在线观看永久免费视频网站| 美女免费精品高清毛片在线视| 亚洲av无码不卡私人影院| 国产伦精品一区二区免费| 亚洲人精品午夜射精日韩| 99久久免费观看| 涩涩色中文综合亚洲| 国产免费av片在线无码免费看| 麻豆一区二区三区蜜桃免费| 亚洲国产成人a精品不卡在线| 中文字幕a∨在线乱码免费看| 亚洲爱情岛论坛永久| 亚洲精品动漫免费二区| 色屁屁在线观看视频免费| 亚洲精品乱码久久久久久按摩| 3d成人免费动漫在线观看| 亚洲欧好州第一的日产suv| 国产中文在线亚洲精品官网| 国产成人无码区免费内射一片色欲| 久久精品国产亚洲AV电影| 四虎成人免费影院网址| 国产精品一区二区三区免费 | 国产无遮挡裸体免费视频在线观看 | 亚洲AⅤ视频一区二区三区 | 激情内射亚洲一区二区三区爱妻| 日本免费一区二区三区最新 | 日韩亚洲欧洲在线com91tv|