Sequence generator problem

Sequence generator problem

Dear sir,
I have created one table by name massemailsendingdetails.

CREATE TABLE MASSEMAILDETAILS(
ID NUMBER,
SUBJECT VARCHAR2(20),
MATTER VARCHAR2(150),
MATTERFILE VARCHAR2(30),
STATUS VARCHAR2(20)
);
Then i created a sequence generator for an id as follows

CREATE SEQUENCE MASSEMAILDETAILS_SEQ START WITH 1 INCREMENT BY 1;

I used the following method to insert a values

public com.antares.DTO.MassMailDetailsDTO insertMassMAilDeails(
String pstrSubject, String pstrMatter, String pstrMatterFile,
String pstrStatus, String strFrom) {

ResultSet resultSet = null;
com.antares.DTO.MassMailDetailsDTO massMailDetails = null;

try {
connection = DBUtil.getOracleConnection();
statement = connection.createStatement();
System.out.println("**** Connection established ***");

int i = statement
.executeUpdate("insert into massemaildetails values(massemaildetails_seq.nextval,'"
+ pstrSubject
+ "','"
+ pstrMatter
+ "','"
+ pstrMatterFile
+ "','"
+ pstrStatus
+ "','"
+ strFrom + "')");
System.out.println("**** statement established is ***" + i);
resultSet = statement
.executeQuery("SELECT * FROM massemaildetails");

while (resultSet.next()) {
massMailDetails = new com.antares.DTO.MassMailDetailsDTO();
massMailDetails.setId(resultSet.getInt("Id"));
massMailDetails.setSubject(resultSet.getString("Subject"));
massMailDetails.setMatter(resultSet.getString("matter"));
massMailDetails
.setMatterFile(resultSet.getString("matterFile"));
massMailDetails.setStatus(resultSet.getString("status"));
massMailDetails
.setEmail_From(resultSet.getString("Email_From"));
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
return massMailDetails;
}

Its working fine,but problem is that when i insert a values it will work and inserted the values.this one i am showing in a table ,but problem is a that it is also created a new id with a dummy values first and then inserted the values what i have given .I am nt understanding where it is going wrong ..so please help me sir..

Thanks and Regards
Harini Veerapur.
View Answers

June 8, 2010 at 11:38 AM

Hi Friend,

You can simply declare the field 'id' as primary key and set it to Auto increment. Then there will be no need to generate the id values, you will get automatically incremented value.

Hope that it will work.
Thanks









Related Tutorials/Questions & Answers:
Sequence generator problem - JDBC
Sequence generator problem  Dear sir, I have created one...) ); Then i created a sequence generator for an id as follows CREATE SEQUENCE...,but problem is that when i insert a values it will work and inserted
how to use sequence as a generator class in hibernate for ms sql
how to use sequence as a generator class in hibernate for ms sql  Hi... as a generator class for ms sql database. Do we need to create an sequence in mssql prior to use sequence generator class?.If it is mandatory to create an sequence in mssql
Advertisements
Tab sequence problem with Radio buttons - JSP-Servlet
Tab sequence problem with Radio buttons  Hi, I have membership... button) courier delivery courier(radio button) currently tab sequence going from 1 year radiobutton to courier button but tab sequence has to go as from 1
Define sequence generated primary key in hibernate
="java.lang.Long"> <generator class="sequence"> <param name...Define sequence generated primary key in hibernate  How to define sequence generated primary key in hibernate?   Use value "sequence
ModuleNotFoundError: No module named 'sequence'
ModuleNotFoundError: No module named 'sequence'  Hi, My Python... 'sequence' How to remove the ModuleNotFoundError: No module named 'sequence... to install padas library. You can install sequence python with following
Processing Sequence of DispatcherServlet
In this section, you will get to know about the processing sequence of DispatcherServlet
HIbernate call for sequence - Hibernate
HIbernate call for sequence  I have created a sequence in oracle table. Now how to access this in java class through hibernate from dual table i am... the sequence using dual table. Thanks in advance
ModuleNotFoundError: No module named 'sequence-builder'
ModuleNotFoundError: No module named 'sequence-builder'  Hi, My... named 'sequence-builder' How to remove the ModuleNotFoundError: No module named 'sequence-builder' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'idempotent-sequence'
ModuleNotFoundError: No module named 'idempotent-sequence'  Hi, My... named 'idempotent-sequence' How to remove the ModuleNotFoundError: No module named 'idempotent-sequence' error? Thanks   Hi
ModuleNotFoundError: No module named 'nxpy-sequence'
ModuleNotFoundError: No module named 'nxpy-sequence'  Hi, My... 'nxpy-sequence' How to remove the ModuleNotFoundError: No module named 'nxpy-sequence' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'sequence_aligner'
ModuleNotFoundError: No module named 'sequence_aligner'  Hi, My... named 'sequence_aligner' How to remove the ModuleNotFoundError: No module named 'sequence_aligner' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'sequence-field'
ModuleNotFoundError: No module named 'sequence-field'  Hi, My... named 'sequence-field' How to remove the ModuleNotFoundError: No module named 'sequence-field' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'sequence-folder'
ModuleNotFoundError: No module named 'sequence-folder'  Hi, My... named 'sequence-folder' How to remove the ModuleNotFoundError: No module named 'sequence-folder' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'sequence-tagging'
ModuleNotFoundError: No module named 'sequence-tagging'  Hi, My... named 'sequence-tagging' How to remove the ModuleNotFoundError: No module named 'sequence-tagging' error? Thanks   Hi, In your
Generator in Hibernate
Generator in Hibernate  What is the generator in hibernate
DNA sequence - Java Beginners
DNA sequence  Write a java program to read a file that contains DNA sequences of arbitrary length one per line (note that each DNA sequence is just a String). Your program should sort the sequences in descending order
ModuleNotFoundError: No module named 'lazy-paged-sequence'
ModuleNotFoundError: No module named 'lazy-paged-sequence'  Hi, My... named 'lazy-paged-sequence' How to remove the ModuleNotFoundError: No module named 'lazy-paged-sequence' error? Thanks   Hi
ModuleNotFoundError: No module named 'lazy-paged-sequence'
ModuleNotFoundError: No module named 'lazy-paged-sequence'  Hi, My... named 'lazy-paged-sequence' How to remove the ModuleNotFoundError: No module named 'lazy-paged-sequence' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-account-analytic-sequence'
ModuleNotFoundError: No module named 'odoo10-addon-account-analytic-sequence...: ModuleNotFoundError: No module named 'odoo10-addon-account-analytic-sequence' How...-analytic-sequence' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo10-addon-base-partner-sequence'
ModuleNotFoundError: No module named 'odoo10-addon-base-partner-sequence' ...: ModuleNotFoundError: No module named 'odoo10-addon-base-partner-sequence' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-base-partner-sequence
ModuleNotFoundError: No module named 'odoo10-addon-hr-expense-sequence'
ModuleNotFoundError: No module named 'odoo10-addon-hr-expense-sequence' ...: ModuleNotFoundError: No module named 'odoo10-addon-hr-expense-sequence' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-hr-expense-sequence'
ModuleNotFoundError: No module named 'odoo10-addon-hr-expense-sequence'
ModuleNotFoundError: No module named 'odoo10-addon-hr-expense-sequence' ...: ModuleNotFoundError: No module named 'odoo10-addon-hr-expense-sequence' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-hr-expense-sequence'
ModuleNotFoundError: No module named 'odoo10-addon-l10n-es-account-invoice-sequence'
-sequence'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo10-addon-l10n-es-account-invoice-sequence...;odoo10-addon-l10n-es-account-invoice-sequence' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-product-sequence'
ModuleNotFoundError: No module named 'odoo10-addon-product-sequence'  ...: No module named 'odoo10-addon-product-sequence' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-product-sequence' error
ModuleNotFoundError: No module named 'odoo10-addon-sequence-check-digit'
ModuleNotFoundError: No module named 'odoo10-addon-sequence-check-digit' ...: ModuleNotFoundError: No module named 'odoo10-addon-sequence-check-digit' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-sequence-check-digit'
ModuleNotFoundError: No module named 'odoo10-addon-sequence-date-range'
ModuleNotFoundError: No module named 'odoo10-addon-sequence-date-range' ...: ModuleNotFoundError: No module named 'odoo10-addon-sequence-date-range' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-sequence-date-range'
ModuleNotFoundError: No module named 'odoo10-addon-sequence-check-digit'
ModuleNotFoundError: No module named 'odoo10-addon-sequence-check-digit' ...: ModuleNotFoundError: No module named 'odoo10-addon-sequence-check-digit' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-sequence-check-digit'
ModuleNotFoundError: No module named 'odoo10-addon-sequence-date-range'
ModuleNotFoundError: No module named 'odoo10-addon-sequence-date-range' ...: ModuleNotFoundError: No module named 'odoo10-addon-sequence-date-range' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-sequence-date-range'
ModuleNotFoundError: No module named 'odoo11-addon-account-analytic-sequence'
ModuleNotFoundError: No module named 'odoo11-addon-account-analytic-sequence...: ModuleNotFoundError: No module named 'odoo11-addon-account-analytic-sequence' How...-analytic-sequence' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo11-addon-account-analytic-sequence'
ModuleNotFoundError: No module named 'odoo11-addon-account-analytic-sequence...: ModuleNotFoundError: No module named 'odoo11-addon-account-analytic-sequence' How...-analytic-sequence' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo11-addon-base-partner-sequence'
ModuleNotFoundError: No module named 'odoo11-addon-base-partner-sequence' ...: ModuleNotFoundError: No module named 'odoo11-addon-base-partner-sequence' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-base-partner-sequence
ModuleNotFoundError: No module named 'odoo11-addon-hr-expense-sequence'
ModuleNotFoundError: No module named 'odoo11-addon-hr-expense-sequence' ...: ModuleNotFoundError: No module named 'odoo11-addon-hr-expense-sequence' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-hr-expense-sequence'
ModuleNotFoundError: No module named 'odoo11-addon-l10n-es-account-invoice-sequence'
-sequence'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo11-addon-l10n-es-account-invoice-sequence...;odoo11-addon-l10n-es-account-invoice-sequence' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo11-addon-maintenance-equipment-sequence'
-sequence'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo11-addon-maintenance-equipment-sequence...-maintenance-equipment-sequence' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'odoo11-addon-maintenance-equipment-sequence'
-sequence'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo11-addon-maintenance-equipment-sequence...-maintenance-equipment-sequence' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'odoo11-addon-maintenance-request-sequence'
ModuleNotFoundError: No module named 'odoo11-addon-maintenance-request-sequence...: ModuleNotFoundError: No module named 'odoo11-addon-maintenance-request-sequence...-maintenance-request-sequence' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo11-addon-product-sequence'
ModuleNotFoundError: No module named 'odoo11-addon-product-sequence'  ...: No module named 'odoo11-addon-product-sequence' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-product-sequence' error
ModuleNotFoundError: No module named 'odoo11-addon-sequence-check-digit'
ModuleNotFoundError: No module named 'odoo11-addon-sequence-check-digit' ...: ModuleNotFoundError: No module named 'odoo11-addon-sequence-check-digit' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-sequence-check-digit'
ModuleNotFoundError: No module named 'odoo11-addon-sequence-check-digit'
ModuleNotFoundError: No module named 'odoo11-addon-sequence-check-digit' ...: ModuleNotFoundError: No module named 'odoo11-addon-sequence-check-digit' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-sequence-check-digit'
ModuleNotFoundError: No module named 'odoo11-addon-sequence-reset-period'
ModuleNotFoundError: No module named 'odoo11-addon-sequence-reset-period' ...: ModuleNotFoundError: No module named 'odoo11-addon-sequence-reset-period' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-sequence-reset-period
ModuleNotFoundError: No module named 'odoo12-addon-account-analytic-sequence'
ModuleNotFoundError: No module named 'odoo12-addon-account-analytic-sequence...: ModuleNotFoundError: No module named 'odoo12-addon-account-analytic-sequence' How...-analytic-sequence' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo12-addon-account-analytic-sequence'
ModuleNotFoundError: No module named 'odoo12-addon-account-analytic-sequence...: ModuleNotFoundError: No module named 'odoo12-addon-account-analytic-sequence' How...-analytic-sequence' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo12-addon-account-analytic-sequence'
ModuleNotFoundError: No module named 'odoo12-addon-account-analytic-sequence...: ModuleNotFoundError: No module named 'odoo12-addon-account-analytic-sequence' How...-analytic-sequence' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence'
ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence' ...: ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence
ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence'
ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence' ...: ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence
ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence'
ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence' ...: ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-base-partner-sequence
ModuleNotFoundError: No module named 'odoo12-addon-hr-expense-sequence'
ModuleNotFoundError: No module named 'odoo12-addon-hr-expense-sequence' ...: ModuleNotFoundError: No module named 'odoo12-addon-hr-expense-sequence' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hr-expense-sequence'
ModuleNotFoundError: No module named 'odoo12-addon-hr-expense-sequence'
ModuleNotFoundError: No module named 'odoo12-addon-hr-expense-sequence' ...: ModuleNotFoundError: No module named 'odoo12-addon-hr-expense-sequence' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-hr-expense-sequence'
ModuleNotFoundError: No module named 'odoo12-addon-l10n-es-account-invoice-sequence'
-sequence'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo12-addon-l10n-es-account-invoice-sequence...;odoo12-addon-l10n-es-account-invoice-sequence' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo12-addon-l10n-es-account-invoice-sequence'
-sequence'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo12-addon-l10n-es-account-invoice-sequence...;odoo12-addon-l10n-es-account-invoice-sequence' error? Thanks   Hi

Ads