Getting cd_id of inserted data

User eda6f877b4

13-03-2014 12:42:30

Hi


Looking for guidance here..


I am inserting a structure and is allowing dublicate structures. After inserting, what is the best way to retrive the id of the inserted row (cd_id)??


Currently I am doing this:


  UpdateHandler uh = new UpdateHandler(conh, UpdateHandler.INSERT, structureTableName, null);


            try {


                uh.setStructure(Encoding.Default.GetBytes(molfile));


                uh.execute();


                // getting the id from the newly registered structure


                searcher.setQueryStructure(molfile);


                searcher.run();


                registered_cd_id = searcher.getResult(0);


            } catch (Exception ex) {


            } finally {


                uh.close();


            }

ChemAxon d9cc14700b

13-03-2014 13:24:44

Hi,


 


Alternatively, you could use UpdateHandler#execute(boolean):


 


int lastId = uh.execute(true);

 


Best Regards,


Gabor

User eda6f877b4

13-03-2014 13:36:10

Thanks.. easy easy.. :-)


 


Dann