<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


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


    網站導航:
     
    主站蜘蛛池模板: 亚洲1234区乱码| 久久精品7亚洲午夜a| 91午夜精品亚洲一区二区三区| 天堂亚洲免费视频| 亚洲av无码片vr一区二区三区| 美女被艹免费视频| 国产午夜影视大全免费观看| 亚洲国产精品18久久久久久| 真实乱视频国产免费观看| 国产A在亚洲线播放| 久久久精品免费国产四虎| 日韩免费视频一区| 精品亚洲国产成人av| 亚洲国产成人久久综合区| 中文字幕亚洲免费无线观看日本| 理论秋霞在线看免费| 亚洲无码黄色网址| 在线综合亚洲欧洲综合网站| 好爽又高潮了毛片免费下载| 亚洲av永久无码精品漫画| 免费A级毛片无码A∨中文字幕下载| 亚洲福利电影一区二区?| 成年大片免费视频| 午夜不卡AV免费| 亚洲成人免费在线| 成人黄18免费视频| 一级做a爱过程免费视| 大地资源免费更新在线播放| 亚洲久本草在线中文字幕| 日日麻批免费40分钟日本的| 亚洲精品乱码久久久久久久久久久久| 亚洲欧美中文日韩视频| 中文免费观看视频网站| 亚洲大尺度无码无码专线一区| 爱情岛论坛网亚洲品质自拍| 最近免费中文字幕大全高清大全1| 亚洲黄页网在线观看| 伊伊人成亚洲综合人网7777| 国产大片免费网站不卡美女 | 国产高清不卡免费在线| 亚洲美国产亚洲AV|