0

I have the following MySQL query specified within a JSP. I want to figure out an equivelant query that I can run properly against Oracle Database as I am migrating my project from MySQL to Oracle DB.

Primary key of this "clips" table is "clip_id" which is actually not included in this query. In Oracle I created a sequence and trigger on "clip_id" because its value is supposed to auto-increment.

stmt.executeUpdate("INSERT INTO clips " +
        "(camera_id, num_recording, num_references, block_id_start,  
                    block_duration ) " +
        "VALUES ("+camera_id + ","+"1, " +
            "1,"+block_id_start + "," +
            block_duration + ");",
            Statement.RETURN_GENERATED_KEYS);

        rs = stmt.getGeneratedKeys();

        if( rs.next() )
        {
            clip_id = rs.getInt(1);
        }

Any comment or advice is appreciated.Thanks.

4

1 に答える 1

1

私のコメントを答えにするには:

RETURNING INTO 句を使用します。こちらを参照してください。

于 2011-06-14T18:24:59.920 に答える