Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

How to use MySQL "Statement.RETURN_GENERATED_KEYS" in Oracle to retrieve key values?

0

34 views

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.

asked June 13, 2011 5:33 pm CDT
posted via StackOverflow

1 Answers

0
 

To make my comment an answer:

Use the RETURNING INTO clause, see here.

answered June 14, 2011 11:20 pm CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
Mysql to oracle
March 16, 2011
Mysql over Oracle..
February 13, 2011