Query on default serial(1) (auto increment)

Hi all,
1. is there a max integer value, when we create/add a column of type INTEGER?
if yes,
2. what happens when column value reaches that value?
    - does it starts from 1 again or what happens?
     Because, i want to create a table with a column of type INTEGER and it is enabled with auto increment and it is primary key. If i delete all rows(say, 100 rows) and insert values into it, it starts with 101... so i was wondering whether it starts with 1 again? or i should change the type of the column to some other type(VARCHAR()).
thank you,
regards,
sudhir.

hi
try this sentence:
ALTER TABLE schemaname.tablename COLUMN colname DROP DEFAULT;
this eliminate default value and this recreate that value
ALTER TABLE schemaname.tablename COLUMN colname ADD DEFAULT SERIAL (integer value);
good luck

Similar Messages

  • Auto increment field with reset in a query

    Hi,
    I have the following query, I want 'field number' should count as a auto increment number and reset accordingly a group. e.g
    for the group 1 if there are 10 rows then it should give me rownum as 1--10
    for the group 2 if therea are 5 rows then it should give me rownum as 1--5
    select d.drop_prog_id,
    a.opre_cms_oppty_id,
    c.more_tipo_revisione,
    decode(f.grdo_prog_id,16,null,
    decode(f.grdo_prog_id,75,'Other','Euro')
    ) Field_Number,
    decode(f.grdo_prog_id,16,e.doma_testo, f.grdo_descrizione) GROUP1,
    decode(f.grdo_prog_id,16,h.risp_valore,d.drop_valore_risposta) MILESTONE_RESPONSE,
    d.drop_valore_commento1,
    d.drop_valore_commento2
    from wrt.tr002_opportunita_revisioni a,
    wrt.tr005_opportunita_rev_moduli b,
    wrt.tr008_moduli_revisione c,
    wrt.tr006_domande_risposte_oppor d,
    wrt.tr009_moduli_domande g,
    wrt.tr010_domande e,
    wrt.tr012_gruppo_domande f,
    wrt.tr015_risposte h
    where b.ormo_opre_prog_id = a.opre_prog_id and c.more_prog_id in (1, 19) and
    d.drop_ormo_prog_id = b.ormo_prog_id
    and d.drop_modo_prog_id = g.modo_prog_id
    and g.modo_more_prog_id = c.more_prog_id and
    g.modo_doma_prog_id = e.doma_prog_id
    and e.doma_grdo_prog_id = f.grdo_prog_id
    and (f.grdo_prog_id in (76, 75)
    or (e.doma_testo like '%Are payment terms from invoice%' and
    f.grdo_prog_id = 16))
    and a.opre_ultima_revisione = 'S'
    and h.risp_prog_id = d.drop_risp_prog_id
    group by d.drop_prog_id,
    a.opre_cms_oppty_id,
    c.more_tipo_revisione,
    drop_prog_id,
    e.doma_testo,
    d.drop_valore_risposta,
    h.risp_valore,
    d.drop_valore_commento1,
    d.drop_valore_commento2,
    f.grdo_descrizione,
    f.grdo_prog_id
    order by a.opre_cms_oppty_id,
    min(f.GRDO_ORDINE) ,
    min(g.MODO_ORDINE)

    row_number() over (partition by <group> order by <whatever>)

  • Auto Increment column query

    I have a very simple table used for debugging:
    CREATE TABLE APPS.XX_DEBUG_TMP
      TEMP_VALUE  VARCHAR2(255 BYTE),
      TEMP_DATE   DATE
    )Then I can use it to store values as my pl/sql is processed - e.g.:
    INSERT INTO XX_DEBUG_TMP (TEMP_VALUE,TEMP_DATE) VALUES ('line 740 l_username value check:' || l_username,SYSDATE);  COMMIT;Trouble is that if a load of debug statements get processed with the same timestamp, I can't see which came first.
    Can I modify my table creation SQL to include an ID column which just increments for each row that is added to the table?
    I'm familiar with how to do it in MySQL (sorry - I know this is an Oracle forum - but am just putting this here to show what I mean):
    CREATE TABLE  `XX_DEBUG_TMP` (
    `TEMP_ID` MEDIUMINT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `TEMP_VALUE` VARCHAR( 255 ) NOT NULL ,
    `TEMP_DATE` DATETIME NOT NULL
    ) ENGINE = MYISAM ;Is it that simple with Oracle? Probably not!
    Any advice much appreciated.
    Thanks

    There is no auto increment column in Oracle. However, you can create a sequence.
    CREATE TABLE APPS.XX_DEBUG_TMP
      TEMP_ID     NUMBER NOT NULL PRIMARY KEY,
      TEMP_VALUE  VARCHAR2(255 BYTE),
      TEMP_DATE   DATE
    CREATE SEQUENCE APPS.XX_DEBUG_TMP_SEQ;Then in your insert statement do this:
    INSERT INTO XX_DEBUG_TMP (TEMP_ID,TEMP_VALUE,TEMP_DATE) VALUES (APPS.XX_DEBUG_TMP_SEQ.NEXTVAL,'line 740 l_username value check:' || l_username,SYSDATE);  Another possible solution to your problem would be to use a TIMESTAMP data type instead of a DATE data type. It has fractional second resolution (up to 9 places I believe).

  • Trying to create cmp correctly(auto-increment);error while running

    I am using the latest versions of Jboss(4.0.5.GA) and Lomboz(R-3.2-200610201336) along with SQL Server 2005 and Microsoft's SQL Server 2005 JDBC driver.
    Lomboz used xdoclet to create the java files based on the SQL table but it did not put anything in the DoctorBean.java file telling it that the primary key was auto-incremented.
    Using the JSP files, I can retreive data out of the database fine so I know the connection and drivers are set up properly.
    Here is the error:
    09:16:46,815 WARN  [ServiceController] Problem starting service jboss.j2ee:service=EjbModule,module=MedicalEJB.jar
    java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(Unknown Source)
        at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:197)
        at org.jboss.mx.loading.UnifiedLoaderRepository3.loadClassFromClassLoader(UnifiedLoaderRepository3.java:277)
        at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:284)
        at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:511)
        at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.jboss.util.loading.DelegatingClassLoader.loadClass(DelegatingClassLoader.java:89)
        at org.jboss.mx.loading.LoaderRepositoryClassLoader.loadClass(LoaderRepositoryClassLoader.java:90)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.jboss.util.loading.DelegatingClassLoader.loadClass(DelegatingClassLoader.java:89)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityCommandMetaData.<init>(JDBCEntityCommandMetaData.java:73)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityMetaData.<init>(JDBCEntityMetaData.java:952)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.<init>(JDBCApplicationMetaData.java:378)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:89)
        at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.java:736)
        at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:424)
        at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:368)
        at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:172)
        at org.jboss.ejb.EjbModule.startService(EjbModule.java:414)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:417)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy25.start(Unknown Source)
        at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:662)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
        at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
        at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInterceptor.java:92)
        at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
        at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy26.start(Unknown Source)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
        at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy8.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:417)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy4.start(Unknown Source)
        at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy5.deploy(Unknown Source)
        at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
        at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
        at org.jboss.Main.boot(Main.java:200)
        at org.jboss.Main$1.run(Main.java:490)
        at java.lang.Thread.run(Unknown Source)
    09:16:46,862 INFO  [EJBDeployer] Deployed: file:/C:/java/jboss-4.0.5.GA/server/default/deploy/MedicalEJB.jar
    09:16:46,987 INFO  [TomcatDeployer] deploy, ctxPath=/MedicalWeb, warUrl=.../tmp/deploy/tmp63256MedicalWeb-exp.war/
    09:16:47,315 INFO  [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
    09:16:47,503 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
    --- MBeans waiting for other MBeans ---
    ObjectName: jboss.j2ee:service=EjbModule,module=MedicalEJB.jar
      State: FAILED
      Reason: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
    ObjectName: jboss.j2ee:service=EjbModule,module=MedicalEJB.jar
      State: FAILED
      Reason: java.lang.StringIndexOutOfBoundsException: String index out of range: 01Simple Doctor table:
    CREATE TABLE [dbo].[Doctors](
        [DoctorId] [int] IDENTITY(1,1) NOT NULL,
        [firstName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [lastName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    CONSTRAINT [PK_Doctors] PRIMARY KEY CLUSTERED
        [DoctorId] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]Most of DoctorBean.java was createded automatically with xdoclet, I created these items manually but with no success:
    * @jboss.entity-command
    * name="mssql-get-generated-keys"
    * @jboss.unknown-pk
    * class="java.lang.Integer"
    * column-name="doctorid"
    * field-name="doctorid"
    * jdbc-type="INTEGER"
    * sql-type="int"
    * auto-increment="true"DoctorBean.java:
    package com.bdintegrations.MedicalApp.EJB;
    import java.rmi.RemoteException;
    import javax.ejb.EJBException;
    import javax.ejb.EntityContext;
    import javax.ejb.RemoveException;
    * <!-- begin-xdoclet-definition -->
    * @ejb.bean name="Doctor"
    *    jndi-name="Doctor"
    *    type="CMP"
    *  primkey-field="doctorid"
    *  schema="DoctorSCHEMA"
    *  cmp-version="2.x"
    *  @ejb.persistence
    *   table-name="dbo.Doctors"
    * @ejb.finder
    *    query="SELECT OBJECT(a) FROM DoctorSCHEMA as a" 
    *    signature="java.util.Collection findAll()" 
    * @ejb.pk
    *  class="java.lang.Object"
    *  generate="false"
    * @jboss.entity-command
    * name="mssql-get-generated-keys"
    * @jboss.unknown-pk
    * class="java.lang.Integer"
    * column-name="doctorid"
    * field-name="doctorid"
    * jdbc-type="INTEGER"
    * sql-type="int"
    * auto-increment="true"
    * @jboss.persistence
    * datasource="java:/MSSQLDS"
    * datasource-mapping="MS SQLSERVER2005"
    * table-name="dbo.Doctors"
    * create-table="false" remove-table="false"
    * alter-table="false"
    * <!-- end-xdoclet-definition -->
    * @generated
    public abstract class DoctorBean implements javax.ejb.EntityBean {
         * <!-- begin-user-doc -->
         * The  ejbCreate method.
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.create-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public java.lang.Object ejbCreate(String firstName, String lastName) throws javax.ejb.CreateException {
            setFirstname(firstName);
            setLastname(lastName);
            return null;
            // end-user-code
         * <!-- begin-user-doc -->
         * The container invokes this method immediately after it calls ejbCreate.
         * <!-- end-user-doc -->
         * @generated
        public void ejbPostCreate() throws javax.ejb.CreateException {
            // begin-user-code
            // end-user-code
         * <!-- begin-user-doc -->
         * CMP Field doctorid
         * Returns the doctorid
         * @return the doctorid
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.persistent-field
         * @ejb.persistence
         *    column-name="DoctorId"
         *     jdbc-type="INTEGER"
         *     sql-type="int identity"
         *     read-only="false"
         * @ejb.pk-field
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract java.lang.Integer getDoctorid();
         * <!-- begin-user-doc -->
         * Sets the doctorid
         * @param java.lang.Integer the new doctorid value
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract void setDoctorid(java.lang.Integer doctorid);
         * <!-- begin-user-doc -->
         * CMP Field firstname
         * Returns the firstname
         * @return the firstname
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.persistent-field
         * @ejb.persistence
         *    column-name="firstName"
         *     jdbc-type="VARCHAR"
         *     sql-type="varchar"
         *     read-only="false"
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract java.lang.String getFirstname();
         * <!-- begin-user-doc -->
         * Sets the firstname
         * @param java.lang.String the new firstname value
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract void setFirstname(java.lang.String firstname);
         * <!-- begin-user-doc -->
         * CMP Field lastname
         * Returns the lastname
         * @return the lastname
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.persistent-field
         * @ejb.persistence
         *    column-name="lastName"
         *     jdbc-type="VARCHAR"
         *     sql-type="varchar"
         *     read-only="false"
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract java.lang.String getLastname();
         * <!-- begin-user-doc -->
         * Sets the lastname
         * @param java.lang.String the new lastname value
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract void setLastname(java.lang.String lastname);
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbActivate()
        public void ejbActivate() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbLoad()
        public void ejbLoad() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbPassivate()
        public void ejbPassivate() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbRemove()
        public void ejbRemove() throws RemoveException, EJBException,
                RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbStore()
        public void ejbStore() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
        public void setEntityContext(EntityContext arg0) throws EJBException,
                RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#unsetEntityContext()
        public void unsetEntityContext() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        public DoctorBean() {
            // TODO Auto-generated constructor stub
    }JSP client page snippet:
    <%
    DoctorHome home = DoctorUtil.getHome();
    Doctor doctor = home.create("Jon","Smith");
    %>
    <%=doctor.getDoctorid() %>thanks

    Nevermind.. no one bothered to inform the developer that the path to the collection AND the path to the directory that the collection is for are different on this other server.
    Fixed.

  • How can I automatically increment an auto incremented column?

    Hello!
    I have a table with an auto incremented "id" field.
    It looks like this:
    id (PK, auto_increment) name address phone
    I would like to make an insertion like:
    INSERT INTO Person (name, address, phone) VALUES (?,?,?)
    ...but it says that all fields have to be used.
    I get
    java.sql.SQLException: Field 'id' doesn't have a default value
    How can I bypass this?
    I have looked at [this example|http://blog.taragana.com/index.php/archive/java-how-to-get-auto-increment-values-after-sql-insert/] , but it didn´t work for me, it still says the "id" column has not a default value:

    Sorry, it is a MySQL database.
    The table consists of 4 columns:
    id (PK, auto_increment)
    name (Varchar)
    address (Varchar)
    phone (Varchar)
    If I use PHPMyAdmin to insert a new row, then this query works:
    INSERT INTO `mydb`.`person` (
    `id` ,
    `name` ,
    `address` ,
    `phone`
    VALUES (
    NULL , 'Test', 'Roxxor', 'Europe', '12345'
    );{code}I tested to use the method setNull() on the first column in the preparedStatement but it didn&acute;t work.
    Do you need more info from me to be able to help me?
    I have tried this (but got the error that the "Field 'id' doesn't have a default value"):
    [code]con.setAutoCommit(true);
                String query = "INSERT INTO person(id, name, address, phone) VALUES (?, ?, ?, ?)";
                PreparedStatement stmt = con.prepareStatement(query);
                stmt.setNull(1, java.sql.Types.NULL);
                stmt.setString(2, name); 
                stmt.setString(3, address);     
                stmt.setString(4, phone); 
                stmt.executeUpdate(); 
                stmt.close();[/code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Impossible to use service without causes error in auto increment ContentID

    Description of the bogue : impossible to use a service from a filter or idscriptextension without causing an error in a database, which causes an error auto increment ContentID
    UCM  : Version:10.1.3.5.1 (100623) (Build:7.2.4.74)
    Database : Oracle XE or ORACLE 11g (same bogue)
    OS : windows XP
    Specific Configuration : Automatically assign a content ID on check in : is checked
    We create an UCM componnent  with : One Query : Q1, one Service S1, the service call the Query. The query is simple retrieve query. We create a filter « ValidateStandard » and we call service S1. In this filter, We do not change the Content ID.
    Call service works great via url ... idc / idcplg? IdcService = S1 ..
    The Check Is Ok, document has been published but in « Console output from the Content Server » we have this error :
    the log :
    +(internal) 07.15 10:49:36.395 IdcServerThread-26 !csJdbcCommitCalledInAutoCommitMode,IdcServerThread-26 (!csJdbcCommitCalledInAutoCommitMode,IdcServerThread-26)-exception stack+
    intradoc.data.DataException: !csJdbcCommitCalledInAutoCommitMode,IdcServerThread-26
    at intradoc.jdbc.JdbcWorkspace.commitTran(JdbcWorkspace.java:1113)
    at intradoc.data.WorkspaceTransactionWrapper.commitTransaction(WorkspaceTransactionWrapper.java:61)
    at intradoc.server.ServiceRequestImplementor.commitTransaction(ServiceRequestImplementor.java:358)
    at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1211)
    at intradoc.server.Service.doActions(Service.java:447)
    at intradoc.server.ServiceRequestImplementor.executeActions(ServiceRequestImplementor.java:1121)
    at intradoc.server.Service.executeActions(Service.java:433)
    at intradoc.server.ServiceRequestImplementor.doRequest(ServiceRequestImplementor.java:635)
    at intradoc.server.Service.doRequest(Service.java:1707)
    at intradoc.server.ServiceManager.processCommand(ServiceManager.java:359)
    at intradoc.server.IdcServerThread.run(IdcServerThread.java:197)
    +(internal) 07.15 10:49:38.788 TaskMonitor c:/oracle/ucm/server/custom/ContentAccess-win32/win32/lib/contentaccess//htmlexport.exe -c c:/oracle/ucm/server/vault/~temp/htmlexport/550541262.hda -f c:/oracle/ucm/server/vault/~temp/550541261/550541261.htm+
    +(internal) 07.15 10:49:38.888 TaskMonitor Unexpected abort by process 'HtmlExport'.+
    requestaudit    07.15 10:50:00.499      Audit Request Monitor   Request Audit Report over the last 120 Seconds****
    requestaudit    07.15 10:50:00.499      Audit Request Monitor   -Num Requests 12 Errors 0 Reqs/sec. 0,1 Avg. Latency (s
    In the counter table the RevClassId column is not incremented but the RevId is incremented
    If we re publish a document, we have a failure
    Content Server Request Failed Content item 'SGTI-000146' was not successfully checked in. The content ID 'SGTI-000146' is not unique.
    We encounter the same problem when the service is called from an extended Idoc function. Idoc function is called in a rule from a derivedField
    We are inspired by the book example of B. "Bex" Huff
    and we use as recomanded
    serviceBinder.clearResultSets();
    serviceBinder.getLocalData().clear();
    any ideas ?

    You need to install the same major version of the runtime as the executable was built in. Installing older/newer versions of the runtime won't make any difference (although that doesn't hold true for device drivers like VISA, DAQmx) and won't allow you to run your executable.
    LabVIEW executables REQUIRE the runtime - it is not possible to run a LabVIEW executable without it.
    You need:
    - Your application
    - The LabVIEW runtime installed that matches the version the application was built in
    - Any appropriate additional device drivers (e.g. NI VISA) or NI components
    You are missing *something* from your installation...if you are using the MODBUS library I'm almost certain you will need NI VISA (as it uses serial or TCP/IP).
    If your PC isn't booting, like I said - try to boot it without a network connection and see if that works.
    Edit: Have you tried searching the forums for that specific error? I very quickly found this: https://forums.ni.com/t5/LabVIEW/HTTP-Client-Error​-OpenHandle-vi-returns-error-code-1967362015/td-p/​.... You might need to include some additional components in your installer like the web application server or the system web server.
    Certified LabVIEW Architect, Certified TestStand Developer
    NI Days (and A&DF): 2010, 2011, 2013, 2014
    NI Week: 2012, 2014
    Knowledgeable in all things Giant Tetris and WebSockets

  • Identifying auto-increment columns

    Hi,
    I am developing a database management package for mysql. I want to be able to provide a sql dump facility, which will produce the sql code for creating a table and populating it.
    I do not seem to be able to find a function for identifying if a field is auto-incrementing?
    The only thing that I could find it the DatabaseMetaData.getTypeInfo() will let you know if a field can used for an auto-increment value, not if it is actually auto-incrementing.
    Please help!

    If you do a query of this table and then have a look at
    the ResultSetMetaData you can use the methode:
    boolean isAutoIncrement(int column)
    Indicates whether the designated column is
    automatically numbered, thus read-only.
    Or you can use the MYSQL-command :
    show columns from table to get all the info of each
    column.
    mysql> show columns from table;
    -----------------------------------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    -----------------------------------------------------------------------------+
    where the Extra column contains 'auto_increment ' if it is...
    ...what in fact is not that DB-independent.....
    Regards
    Fredy

  • How can i create an auto increment column

    Hello Everyone
    We are working on an EAM package which has an auto number facility but that is not meeting our requirement because some 10s and 100s of numbers keep on jumping based on the number of records the child table has.Means every record in my parent table will have some child records in another table which we call it a child table.The number of numbers that will be jumped each time will depend on the number of child records it has. Now we want to create a new column and generate a sequential unique number in my parent table with out linking it to its child table and use this number as a reference number. And we cant do that through our package customization. Can any one guide us if we can meet our requirement through oracle triggers or so.
    Thanks and Regards

    Hi,
    For "Auto-Increment" functionality - you can use a combination of a sequence and a trigger like so:
    create table roles ( role_id INT
                       , role_name VARCHAR2(30) NOT NULL
                       , creation_date DATE DEFAULT SYSDATE NOT NULL
                       , role_description VARCHAR2(255)
                       , CONSTRAINT roles_pk PRIMARY KEY (role_id)
                       , CONSTRAINT roles_uk1 UNIQUE (role_name)
    create sequence role_id_seq
    start with 1
    increment by 1
    nocache;
    CREATE OR REPLACE TRIGGER roles_pk_trig
    BEFORE
    insert on roles
    for each row
    begin
    IF :new.role_id IS NULL THEN
       SELECT role_id_seq.NEXTVAL
       INTO :new.role_id
       FROM dual;
    END IF;
    end;
    /Now any insert which leaves the "ROLE_ID" column NULL will have an auto-incremented value put in for that column. This is similar to an "Autonumber" column in Access.
    Hope this helps...
    Take care.

  • HSQL DB Identity & Auto Increment

    We are trying to write records to this table:
    create table location_groups
    group_id identity
    ,jdoversion integer
    ,jdoclass varchar(255) default 'path.impl.LocationGroup' not null
    ,group_name varchar(100) not null
    ,group_parent_id integer
    Package.jdo is:
    <package name="path">
    <class name="LocationComponent">
    </class>
    </package>
    <package name="path.impl">
    <class name="LocationGroup" persistence-capable-superclass="path.LocationComponent">
    <!--<extension vendor-name="kodo" key="jdbc-field-map" value="one-one"/>-->
    <extension vendor-name="kodo" key="jdbc-auto-increment" value="true"/>
    <field name="children" persistence-modifier="persistent" default-fetch-group="true">
    <collection element-type="path.impl.Location"/>
    </field>
    </class>
    and package.mapping is:
    <package name="path">
    <class name="LocationComponent">
    <jdbc-class-map type="horizontal"/>
    </class>
    </package>
    <package name="path.impl">
    <class name="LocationGroup">
    <jdbc-class-map type="base" pk-column="GROUP_ID" table="LOCATION_GROUPS"/>
    <jdbc-version-ind type="version-number" column="JDOVERSION"/>
    <jdbc-class-ind type="in-class-name" column="JDOCLASS"/>
    <field name="path.LocationComponent.name">
    <jdbc-field-map type="value" column="GROUP_NAME"/>
    </field>
    <field name="children">
    <jdbc-field-map type="one-many" table="LOCATIONS" ref-column.GROUP_ID="GROUP_PARENT_ID"/>
    </field>
    </class>
    </package>
    I have tried all manner of configurations but the error remains the same:
    25-Apr-2008 16:05:24 com.ea.albt.infrastructure.persistence.jdo.JDODataStore BeginTransaction
    CONFIG: Starting transaction
    25-Apr-2008 16:05:24 com.ea.albt.infrastructure.persistence.jdo.JDODataStore updateObjects
    FINE: Updating object ALBT Loc1209135924484 (has not yet been persisted)
    25-Apr-2008 16:05:25 com.ea.albt.infrastructure.persistence.jdo.JDODataStore updateObjects
    WARNING: Failed to persist/update objectALBT Loc1209135924484
    kodo.util.FatalDataStoreException: Attempt to update the sequence table "JDO_SEQUENCE" failed. The sequence table is typically created when you run the mappingtool's refresh action on any datastore identity class. If you have not run the mappingtool but want to create the sequence table, run:
    java kodo.jdbc.schema.DBSequenceFactory -action add
    NestedThrowables:
    Why is Kodo trying to use the jdo_sequence table when we want it to use the HSQLdb identity field ?

    We have many users using single field identity and auto-increment together.

  • Retrieve new row's auto-increment key from dataprovider

    ** cross posted on SDN JSC Forum and Netbeans J2EE Nabble forum **
    I have a page that is bound to a MySQL table rowset or, alternately, a new (append()'ed) row. The row's Primary Key is a MySQL auto-increment Integer (translates to a Long.) After commit()'ing the the new row to the database, how would I then get the new row's ID (fieldname "ID")? If I refresh() the dataprovider and try to get the value an error is thrown.
    Some background: The dataprovider's backing rowset has a query parameter for the ID field. I set it to "0" if the page is creating a new row or I set it to the unique ID if the page is displaying an existing row. After the new row is committed, I need the new ID set the query parameter and synch up related rows in different tables that are keyed off the ID in this (master) table. I'd like to do this without "guessing" what the ID would be in advance as that method isn't foolproof in heavy usage.
    Additionally, it strikes me as a useful workaround if the unique ID was a UUID (mySQL UUID() function) that does not run the risk of any concurrency issues. Has anyone used this solution in VWP? How would I make the call for the underying DB (in this case MySQL, but could be anything) to generate the UUID? Is the call DB specific or is there a JDBC equivalent?
    UPDATE: never mind the GUID question, I can use the java.rmi.dgc.VMID class to autogenerate unique GUID's for this purpose. Being from a Lotus Notes background, I'm used to the power and flexibility such Unique ID's bring to the app. dev's portfolio.
    Thanks in adv. for any help .
    -Jake
    Message was edited by:
    jakeochs

    JSF together with JBoss Seam offers some real good possibilities to improve developer productivity. Right now, with JSF you can create forms where fields are persistent (saved in a database), but you have to write code to persist fields. In Notes/Domino, every field you drop in the form is automatically set to persist without writing a single piece of code. JBoss Seam aims to provide the missing glue to tie the JSF beans with business logic (EJB) and persistent layer (JPA). I think tools for Seam are still not mature. I would love to see JSC/VWB utilizing Seam. I know there is a NetBean plugin for Seam but it was written for old NetBeans (not VWP or JSC), so it doesn't work with the visual web pack where you can drag and drop JSF components.

  • Bug in auto-increment for MSSQL

    I am using kodo 3.1.0 and have a scenario where I am persisting a new object
    that uses an auto-increment PK and the database has an on-insert trigger
    that inserts a log into an audit table.
    At the database level, what is happing is:
    1) kodo calls "insert into t_timeentry (........)
    2) the database calls "insert into t_timeentrylog (......)
    3) kodo calls @@IDENTITY to get the ID to associate with the new timeentry.
    The problem is, @@IDENTITY is getting back the last identity used,
    regardless of table, so it is returning the id inserted into t_timeentrylog
    and kodo thinks that's the id of the timeentry. In the end, I get a
    optimistic lock exception when I try to update the new timeentry because it
    is trying to update based on the id of the timeentrylog.
    What you need to do is call SCOPE_IDENTITY or IDENT_CURRENT rather than
    @@IDENTITY when you get auto-incremented columns. Unfortunately, those
    functions only exist in SQL 2000 (maybe 7), so people with SQL6.5 (and maybe
    7) are just out luck if they have triggers on inserts.
    Is there a work-around for this? It's causing problems throughout my
    system.
    Nathan

    If the query string you want executed to get the last auto-inc value
    does not rely on context, you can set it easily with:
    kodo.jdbc.DBDictionary: LastGeneratedKeyQuery="<sql>"
    If it is more complex, then you'll need to extend
    kodo.jdbc.sql.SQLServerDictionary and override the following method:
    public long getGeneratedKey (kodo.jdbc.schema.Column col,
    Connection conn)
    throws SQLException
    // if you need the col or table name:
    String colName = col.getName ();
    String tableName = col.getTable ().getName ();
    // execute the necessary SQL to return the last inserted value...
    Then you can plug your dictionary into Kodo with:
    kodo.jdbc.DBDictionary: your.custom.Dictionary

  • Using an DB auto-increment feature on a PK

    Hi,
    I work with an Oracle target DB and I have a trigger which auto-increment the field ID (it's my pk).
    In my interface, I map all the fields and let my ID field empty in order to let Oracle filling it.
    But when I run the interface, I have this error message at step "insert flow into $ table" :
    936 : 42000 : java.sql.SQLException : ORA-00936: expression absente
    If I change my PK, it works so I think the issue is there. Can I easily solve this ?
    Thanks

    Thanks for your answer but didn't work better.
    I solved the issue using the IK SQL Control Append in the flow tab and disabling the PK constraint in the check tab. All other options set as default.
    I don't know if it's the better solution but it works...

  • Primary key violation exception in auto increment column

    Hi All,
    I am facing one issue in Multi threaded environment.
    I am getting Primary key violation exception in auto increment column. I have a table and the primary key is the auto increment column, and I have a trigger which is populating this column.
    5 threads are running and inserting the data in the table and throwing Primary key violation exception randomly.
    create table example (
    id number not null,
    name varchar2(30)
    alter table example
    add constraint PK1example primary key (id);
    create sequence example_id_seq start with 1 increment by 1;
    create or replace trigger example_insert
    before insert on example
    for each row
    begin
    select example_id_seq.nextval into :new.id from dual;
    end;
    Any idea how to handle auto increment column(trigger) in Multi threaded environment??
    Thanks,

    user13566109 wrote:
    Thanks All,
    Problem was in approach; removed the trigger and placed a seq.nextval in insert query. It has resolved the issue.I very much suspect that that was not the issue.
    The trigger would execute for each insertion and the nextval would have been unique for each insertion (that's how sequences work in oracle), so that wouldn't have been causing duplicates.
    I suspect, more likely, that you had some other code somewhere that was using another sequence or some other method of generating the keys that was also inserting into the same table, so there was a conflict in the sources of the sequences being generated.
    The way you showed you had coded above, was a perfectly normal way to assign primary keys from a sequence, and is not a problem in a multi user/threaded environment.

  • Auto-Increment a String of data

    OK, I see to be going round and round with the same problem.
    I have UDF that contains 12 digits but the first 6 digits will always be the same.
    The next 5 digits are the set of digits I need to auto increment
    The last digit is a check digit that is pre-determined.
    So I need assistance on a formatted search that looks at just the 5 digits and auto-increments those.
    What seems to be the problems is once the UPC gets 12 digits, it only seems to start auto updating the 12 check digit and I do not want the 12th digit even touched.
    I started out with 84573410001
    After I made a update to that number the final value of the UDF is 845734100011
    When a user used the formatted search the next value it should update is 84573410002
    This is the query I got from teh forum a few days ago and it works as long as there is only 11 digits in the UDF, once I add teh 12th digit then it starts to auto increment the 12th digit.
    Thanks,
    Craig

    That was the posting I did the first time around and the Query of:
    SELECT str(CAST(MAX(T.U_UPC) as numeric)+1,12)
    FROM RDR1 T
    Works great when there is only 11 digits to increment but I want to only auto-increment a string of 5 digits with in the value.
    First String (Will always be the same) 845734
    Second String (THIS IS THE SET OF DIGITS I WANT TO AUTO_INCREMENT) Starts at 10001 and goes up.
    Third string - 1 digit that is updated based on a set of values I built into a User Defined table and adds to the first 2 strings based on a comparison.

  • Gets the new id of auto-increment field by jdbc

    There is a auto-increment index field of a table. I would like to add a row in that table by jdbc. The process is success and the index will increase automatically. However i would like to get the newly added index number. How can i do this? Thanks a lot.

    This is off of Microsoft's T-SQL site http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_tsqlcon_6lyk.asp
    @@IDENTITY and SCOPE_IDENTITY will return the last identity value generated in any table in the current session. However, SCOPE_IDENTITY returns the value only within the current scope; @@IDENTITY is not limited to a specific scope.
    IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the identity value generated for a specific table in any session and any scope. For more information, see IDENT_CURRENT.

Maybe you are looking for