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.
Similar Messages
-
Auto increment between 2 inputed dates by 1
Hi
Can someone please tell me how to list the dates in order between 2 inputed dates.
for eg., if my input is just one date : 17-jan-98, I can give this SQL
select '17-jan-99', count(*) DAILYCOUNT from full_list where
'17-jan-99' between list_begin_date and list_end_date
This output gives me
17-jan-99 1561
What if my input is startdate 17-jan-99 and enddate is 20-jan-99, I would like to have the output as such
17-jan-99 1561
18-jan-99 1887
19-jan-99 1345
20-jan-99 1444
Please help, thanks
Joe.Never mind, I was able to do it myself, thanks
select a.newdate, count(*) DAILYCOUNT from full_list,
(select distinct list_begin_date newdate from full_list where
list_begin_date between '17-jan-99' and '20-jan-99') a
where
a.newdate between list_begin_date and list_end_date
group by a.newdate -
Auto-increment identity column through procedure in oracle 10g on windows
Hi,
I need identity primary key which should be auto increment before while inserting data into table.
for this i had use sequence and then trigger to increment it.
but now i need to increment it in Procedure, while my procedure is having code to insert data in same table which has primary keyHi,
SNEHA RK wrote:
Hi,
I need identity primary key which should be auto increment before while inserting data into table.
for this i had use sequence and then trigger to increment it.Right. Some database products have auto-increment columns, and they are really handy. Unfortunately, Oracle does not have auto-increment columns. A sequence is an auto-increment object, and it's the right way to automatically generate unique identifiers, but you need to explicity reference the sequence, either in you DML statements, or in a trigger that will automatically fire before a DML statement.
but now i need to increment it in Procedure, while my procedure is having code to insert data in same table which has primary keyAre you saying that you need to increment the sequence, completely aside from INSERTing into the table?
If so, just reference sequence_name.NEXTVAL wherever you want to. In PL/SQL, you can say
SELECT sequence_name.NEXTVAL
INTO number_variable
FROM dual;This works in any version of Oracle, but starting in Oracle 11, you also have the option of referencing te sequence without using dual, or any other table.
I hope this answers your question.
If not, post a complete script that people can run to re-create the problem and test their ideas.
For example:
-- Here are the table and the seqauence that I created:
CREATE TABLE table_x ...
CREATE SEQUENCE ...
-- Here is the BEFORE INSERT trigger I wrote:
CREATE OR REPLACE TRIGGER ...
-- The trigger works exactly how I want it to in statements like this:
INSERT INTO table_x ...
-- So there are no problems (that I know of) with anything up to this point.
-- Now I want to use the same sequence to ...
-- so that when I execute a statement like this
-- then the next time I add a new row to the orginal table, like this
INSERT INTO table_x ...
-- then the contents of table_x should be ... because ... -
Is there a auto-increment data type in Oracle
Is there a auto-increment data type in Oracle ?
How to do it if there is no auto-increment data type in Oracle ?
nulljackie (guest) wrote:
: Is there a auto-increment data type in Oracle ?
: How to do it if there is no auto-increment data type in Oracle
Hi,
I think you need unique ID's, for this purpose you use sequences
in Oracle. Example:
create table xy (
id number,
name varchar2(100)
alter table xy
add constraint xy_pk primary key(id);
create sequence xy_seq start with 1 maxvalue 99999999999;
(there are many other options for create sequence)
create or replace trigger xy_ins_trg
before insert on xy
for each row
begin
select xy_seq.nextval
into :new.id
from dual;
end;
This produces a unique value for the column id at each insert.
Hope this will help.
peter
null -
Is it possible to auto increment a streamname when publishing to FMS?
Instead of appending to the same folder/directory of the liveevent and stream files when publishing and unpublishing, is there an option to which if a stream is unpublished and republished to starts a new folder/directory _1, _2, _3, etc?
Or even better, to name the folder with a timestamp of the publish? instead of _1, _2, _3 -- _2012oct8-2101, _2012oct9-0644, _2012oct10-1833
Thanks.Hi,
I think we should be able to do this.
First - Do not specify any query string in your publish string. Just say 'livestream'. This means you are not assigning any event name.
In the livepkgr main.asc, check out the function application.onPublish. When no event name is defined, the application uses the stream name itself as the event name. The code in livepkgr main.asc corresponding to this;
if (queryString == undefined || (queryString.localeCompare("") == 0)) {
/* Did not find query string so use the streamname as the event id */
trace("Query string not specified. Using StreamName["
+streamObj.name+"] as eventname");
Now, to accomplish your task, all you need to do is append some marker to this stream name.
Essentially here:
var liveEventName = streamObj.name
I will leave it to you to make use of timestamps, shared objects etc. to keep track of the event name and incerement it for every publish attempt.
As as example, if you do something like this:
var liveEventName = streamObj.name + "Test"
Your event name will be livestreamTest
I hope this helps in some way.
Thanks,
Shiven -
Insert data into Access with Auto-Increment column
Is there anyone out there that has come across this problem I am experiencing?
I have a form I'm trying to submit to an Access DB that has an Auto-Incremented Table Column. I have followed Stefan Cameron's instructions to a "T" on his blog page here:
http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/
but I keep getting the following error"
GeneralError: Operation failed.
XFAObject.open:10:XFA:form1[0]:mysubform[0]:myEIFform[0]:overflowLeader[0]:Submit[0]:click
open operation failed. [Microsoft][ODBC Microsoft Access Driver] Number of query values and destination fields are not the same.
My OLEDB Connection Record Source is the SQL Query which reads: SELECT FedTaxID, LegalID FROM dbtest; My simple test DB is Access and its only 3 columns; dbID, FedTaxID, LegalID. dbID is the Auto-Incremented Column.
If I remove the Auto column from my DB table it inserts just fine but I get this error:
GeneralError: Operation failed.
XFAObject.open:10:XFA:form1[0]:mysubform[0]:myEIFform[0]:overflowLeader[0]:Submit[0]:click
ado2xfa operation failed. Item cannot be found in the collection corresponding to the requested name or ordinal.
I've looked over alot of the blogs and other help forums and there's info on Selects, I don't find much on Inserts.
Can anyone direct me in the right direction? Thank you.First, please pay attention to the forum in which you are posting. This particular post would be more appropriate to tsql rather than datamining. Second, what specific problem are you trying to solve. The code you posted appears to be
correct. I will say that your DataTable will likely be a source of future problems if it contains only the 2 columns. -
Hibernate data insertion not working with oracle auto increment
hi i have created a table and the id is set to auto increment by a sequence trigger pair
when i manually giving value to id its working fine
but when i tried without maually giving the id i am getting this error
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.pojo.Example
at org.hibernate.id.Assigned.generate(Assigned.java:33)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at hibernetsample.Main.main(Main.java:30)>
hi i have created a table and the id is set to auto increment by a sequence trigger pair
when i manually giving value to id its working fine
but when i tried without maually giving the id i am getting this error
org.hibernate.id.Assigned
>
That is because you are using the hibernate 'assigned' generator which, by definition
>
lets the application to assign an identifier to the object before save() is called.
This is the default strategy if no <generator> element is specified.
>
For your use case you can use the 'sequence' generator.
The valid generator options and one way to use a sequence generator is shown in this article
http://www.hibernate-training-guide.com/identifiers-generators.html
The hibernate section of this article also uses a trigger with sequence generator
http://blog.lishman.com/2009/02/auto-generated-primary-keys-in-oracle.html
You should check the hibernate documention and tutorial for examples or search 'hibernate generator sequence example' -
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() %>thanksNevermind.. 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. -
Filename generation & Auto increment filename
Hi,
I would like my program to create a filename automatically, im using the "Filename Generator" which was available online, and also the "Unique Filename" VI. The way im using this is, I let the user select a path, and feed the path to the filename generator.vi. The output of that VI is the input to the Unique filename.vi .And the output of this VI is the root where the actual output file will be located. Im getting an error:
Error 7 occurred at Open/Create/Replace File in Write Spreadsheet String.vi->Write To Spreadsheet File (string).vi->Write Header & Waveform Ref.vi->Main.vi
I have attached my main VI, and the two above mentioned VIs. Also attached is the png file of the frames that contains these functions.
Is there a way to get over this???
Thank you,
Eureka
Solved!
Go to Solution.
Attachments:
Main.vi 111 KB
Filename Generator.llb 117 KB
Unique File Name.vi 35 KBI think i see what the problem is,
This function creates a path, but not a file. So, the input given to the write to spreadsheet file is not actually the location of a file, i would say it is something virtual.
If i use the Unique filename.vi alone and not the filename generator.vi, my program works fine, it does increment the filename, but, the user has to select the file every time.
For instance, i have a txt file "Current". The VI generates a file path for "Current(1)" and writes the data in the new file.
The next time, if the user fails to select "Current(1)" as the input path, and if the input path is just the same as the 1st run, it over writes the data in "Current(1)", as expected!
The basic problem is, i need to avoid over writing data. Because, i read the waveforms from the file and it will me messed up big time.
Is there a function to auto-increment filenames as we write them?
Thank you,
Eureka -
I am using 3.0.3 and have a PC class that uses application identity and
MSSQL server, so we are using auto-increment fields for our primary keys.
In the past (with sequence-generated ids) we have used Integers for our
mapped attributes, but with the application identity, it seems we need to
use ints. Is there a reason for this, or is it a bug?
NathanGreat. Thanks for the help.
Nathan
"Marc Prud'hommeaux" <[email protected]> wrote in message
news:[email protected]...
Nathan-
This is a bug. I've reported it at:
http://bugzilla.solarmetric.com/show_bug.cgi?id=910
I expect it will be fixed in the next release. In the meantime, if you
want to use a numeric wrapper for your auto-increment field, it will
need to be of type java.lang.Long.
In article <[email protected]>, Nathan Voxland wrote:
It does work with Longs. I could switch my code to use Longs, although
I
don't always need that large of an id field.
Nathan
"Marc Prud'hommeaux" <[email protected]> wrote in message
news:[email protected]...
Nathan-
If you change them both from Integer to a Long field, then does it
work?
>>>
>>>
In article <[email protected]>, Nathan Voxland wrote:
Here is the code for the class and the ApplicationId class. The
ApplicationId class was generated using the appidtool.
public class Portfolio {
private Integer id;
private String name;
private String notes;
private Organization client;
private Portfolio parentPortfolio;
private Set subPortfolios;
private Set projects;
private Date created;
private Person createdBy;
private Date lastModified;
private Person lastModifiedBy;
public Portfolio(PersistenceManager pm) {
pm.makePersistent(this);
this.subPortfolios = new HashSet();
this.projects = new HashSet();
this.created = new Date();
this.createdBy = new PersonPeer(pm).findLoggedIn();
this.lastModified = this.created;
this.lastModifiedBy = this.createdBy;
public Integer getId() {
return new id;
public String getName() {
return name;
public void setName(String name) {
this.name = name;
public void jdoPostLoad() {
public void jdoPreStore() {
if (!((PersistenceCapable) this).jdoIsNew()) {
this.lastModified = new Date();
this.lastModifiedBy = new
PersonPeer(((PersistenceCapable)
this).jdoGetPersistenceManager()).findLoggedIn();
public void jdoPreClear() {
public void jdoPreDelete() {
* Auto-generated by:
* kodo.enhance.ApplicationIdTool
public class PortfolioId
implements Serializable
static
// register persistent class in JVM
Class c = Portfolio.class;
public Integer id;
public PortfolioId ()
public PortfolioId (String fromString)
if ("null".equals (fromString))
id = null;
else
id = new Integer (fromString);
public String toString ()
return String.valueOf (id);
public int hashCode ()
return ((id == null) ? 0 : id.hashCode ());
public boolean equals (Object obj)
if (this == obj)
return true;
if (!(obj instanceof PortfolioId))
return false;
PortfolioId other = (PortfolioId) obj;
return ((id == null && other.id == null)
|| (id != null && id.equals (other.id)));
Nathan
"Marc Prud'hommeaux" <[email protected]> wrote in message
news:[email protected]...
Nathan-
Is the primary key field an Integer in both the application
identity
class and the persistent class itself? They need to both be the same
class.
If they are the same, and you are still getting the exception, could
you post the code for the classes (or else mail them to
[email protected])?
In article <[email protected]>, Nathan Voxland
wrote:
When I have my object use an int id, my test runs fine, when Iswitch
to
an
Integer, I get the exception:
kodo.util.FatalException: java.lang.ClassCastException
NestedThrowables:
java.lang.ClassCastException
at
kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:563)
at
com.correlat.intranet.projectmanagement.PortfolioTest.testFlush(PortfolioTes
t.java:393)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at com.intellij.rt.execution.junit2.IdeaJUnitAgent.doRun(UnknownSource)
at
com.intellij.rt.execution.junit.TextTestRunner2.startRunnerWithArgs(Unknown
Source)
at
com.intellij.rt.execution.junit2.JUnitStarter.prepareStreamsAndStart(Unknown
Source)
at com.intellij.rt.execution.junit2.JUnitStarter.main(UnknownSource)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at com.intellij.rt.execution.application.AppMain.main(UnknownSource)
Caused by: java.lang.ClassCastException
at
com.correlat.intranet.projectmanagement.Portfolio.jdoReplaceField(Portfolio.
java)
atkodo.runtime.StateManagerImpl.replaceField(StateManagerImpl.java:2771)
at
kodo.runtime.StateManagerImpl.storeObjectField(StateManagerImpl.java:2272)
atkodo.runtime.StateManagerImpl.storeObject(StateManagerImpl.java:2252)
at
kodo.jdbc.meta.ValueFieldMapping.setAutoIncrementValue(ValueFieldMapping.jav
a:346)
atkodo.jdbc.meta.ClassMapping.setAutoIncrementValue(ClassMapping.java:381)
at
kodo.jdbc.runtime.PreparedStatementManager.flush(PreparedStatementManager.ja
va:137)
atkodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:357)
atkodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:153)
at
kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:72)
atkodo.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:507)
at
kodo.runtime.DelegatingStoreManager.flush(DelegatingStoreManager.java:158)
at
kodo.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:412)
at
kodo.runtime.PersistenceManagerImpl.flushInternal(PersistenceManagerImpl.jav
a:794)
at
kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:550)
... 24 more
NestedThrowablesStackTrace:
java.lang.ClassCastException
at
com.correlat.intranet.projectmanagement.Portfolio.jdoReplaceField(Portfolio.
java)
atkodo.runtime.StateManagerImpl.replaceField(StateManagerImpl.java:2771)
at
kodo.runtime.StateManagerImpl.storeObjectField(StateManagerImpl.java:2272)
atkodo.runtime.StateManagerImpl.storeObject(StateManagerImpl.java:2252)
at
kodo.jdbc.meta.ValueFieldMapping.setAutoIncrementValue(ValueFieldMapping.jav
a:346)
atkodo.jdbc.meta.ClassMapping.setAutoIncrementValue(ClassMapping.java:381)
at
kodo.jdbc.runtime.PreparedStatementManager.flush(PreparedStatementManager.ja
va:137)
atkodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:357)
atkodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:153)
at
kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:72)
atkodo.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:507)
at
kodo.runtime.DelegatingStoreManager.flush(DelegatingStoreManager.java:158)
at
kodo.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:412)
at
kodo.runtime.PersistenceManagerImpl.flushInternal(PersistenceManagerImpl.jav
a:794)
at
kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:550)
at
com.correlat.intranet.projectmanagement.PortfolioTest.testFlush(PortfolioTes
t.java:393)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at com.intellij.rt.execution.junit2.JUnitStarter.main(UnknownSource)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at com.intellij.rt.execution.application.AppMain.main(UnknownSource)
Nathan
"Patrick Linskey" <[email protected]> wrote in message
news:[email protected]...
What behavior are you seeing that is preventing you from using
Integers?
-Patrick
Nathan Voxland wrote:
I am using 3.0.3 and have a PC class that uses application
identity
and
MSSQL server, so we are using auto-increment fields for our
primary
keys.
In the past (with sequence-generated ids) we have used Integers
for
our
mapped attributes, but with the application identity, it seems
we
need
to
use ints. Is there a reason for this, or is it a bug?
Nathan
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com -
Auto Increment of primary key value in jdeveloper.
hi all,
i have one table with one primary key.
i want to increment that primary key when ever i go for CreateInsert or create operation in JSF page.
i have tried with db sequence value type, but i was not able to achieve my condition. in DB Sequence i got error like cannot convert java.class.string to java.class.dbsequence.
can any one suggest me in this to achieve my condition.
regards,
M vijayalakshmi.hi all,
from this i found the simple method to achive the auto increment of primary key.
http://www.techartifact.com/blogs/2012/10/adding-number-for-primary-key-in-oracle-adf-using-groovy-by-sequence.html#ixzz2EeU9CWo6
in this am facing an one small issue.
intial value of the primary key is 1.
for this value i have entered the row of data.
again i have clicked on the create button.
then the value of the primary key has increased to 2.
for this value i didnt entered the row of data to databse.
just i closed the browser.
if i run the run page again, the value of primary key is 3.
my requirment is i shd get the value of primary key is "2".
the increment shd happen the maxi value present in the primary key of the table.
can any one help me in this how to achive this.
thanks in advance.
regards,
M vijayalakshmi. -
Auto increment of month problem
public void AssignRTA(String date){
String[] StartDate = date.split("/");
GregorianCalendar calStart = new GregorianCalendar(Integer.parseInt(StartDate[2]), Integer.parseInt(StartDate[0]) , Integer.parseInt(StartDate[1]));
System.out.println("Date: " + dfmt.format(calStart.getTime()));
Hi, I passed in a String contain "2/7/2003" (mm/dd/yyyy). Split it and StartDate[0] = Month, StartDate[1]= Day, StartDate[2]= Year.
When I do it this way, the month will auto increment by 1.
The printout will be 3/7/20003. Why is that so?
Please advise. ThanksSorry for the triple post.
If you want to convert your date string to a Date object, use:Date yourDate = null;
try {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
yourDate = formatter.parse("05/06/2000");
} catch (ParseException e) { }tajenkins -
How to use auto-increment and search option for MS Access DB
Dear All,
I have configured our invoice in Adobe Livecycle and connected it to MS Acess 2007 as per http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/.
All is working fine, I can insert, retrieve data from DB to invoice and vice versa.
Now I want few things to be implemented on our invoice.
When ever I open our invoice, it populate the first entry from DB, Is it possible to populate the last entry ?
Auto increment invoice number from MS Access DB every time we open our invoice after save.
How to implement search option from DB for invoice number ?
Please let me know if someone can provide me help on my scenario, so that I can share more stuff related to invoice and DB.
Look forward to hearing soon from experts and other team members.
Thanks & Regards
Riyad...As far as I know there is not any auto increment data type in Oracle. Instead of this you should create a sequence and get the next value of the sequence while creating a row in your table.
CREATE SEQUENCE Test_Sequence ;
CREATE TABLE Test_Table ( Id NUMBER , Foo VARCHAR2(4) ) ;
ALTER TABLE Test_Table ADD CONSTRAINT Test_Table_PK_Id PRIMARY KEY ( Id ) ;
INSERT INTO Test_Table ( Id , Information ) VALUES ( Test_Sequence.NEXTVAL , 'FOO' ) ; -
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 RegardsHi,
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. -
How to create auto increment value in my column using identity ?
hi Team,
I have an requirement where i create an auto increment value ,with my table column
Create table Temp(
DeptID int IDENTITY(1,1) PRIMARY KEY,
Name varchar(50),
Emailid nvarchar(50),
Phone varchar(50)
so this is my table structure ,Here my column name is
Deptid here i need to creat an autoincrement value with today's date like below
ex:STM0000120012015
STM0000221012015
STM0000322012015(Currentdate)
.......................................... like this
Here i need only one column like identity column with the given incremental order,not more than one column
so can u pls help me out any one.
Thanks!Here the output came like this ,
1 STM0000120150121
2 STM0000220150121
3 STM0000320150121
4 STM0000420150121
5 STM0000520150121
6 STM0000620150121
7 STM0000720150121
8 STM0000820150121
9 STM0000920150121
10 STM00001020150121 --see this exceed length
and here i dnt need to increment that Stm000010,Here my output will come like this, idnt need to increment my charcter size
1 STM0000120150121
2 STM0000220150121
3 STM0000320150121
4 STM0000420150121
5 STM0000520150121
6 STM0000620150121
7 STM0000720150121
8 STM0000820150121
9 STM0000920150121
10 STM0001020150121
11 STM0001120150121
12 STM0001220150121
so here i dont need to increment my charcter length(16)
The length should be STM(3char)+00001(5Charcters)+CurrentDateFormat,
see the above suggested o/p
so can u pls help me out Dimant
Maybe you are looking for
-
I dowloaded some songs from soundcloud and they wont sync to my device
I downloaded some songs from soundcloud as a .m4v file, then went to itunes to convert it as a mp3 file. It converted it, but then it didn't sync the song to either my ipad nor my iphone. Help?
-
I have a macbook pro 13 inch running on mavericks 10.9.2 and i was wondering if i could just use the "Mini Display Port to HDMI Adapter" and connect it directly from my computer to my t.v? because i see a lot of people on youtube connecting the "hdm
-
Hi Friends, Can OCI be used to develop program in VB.Net or/and ASP.Net with Oracle like the way C or C++ can be used along with OCI - Oracle. If this can be used, It will be great if you can help in finding out the websites providing more informatio
-
Prime Infrastructure 2.1. Configuration template deploy problem.
Hello! I have a problem with the CLI template deployment on Cisco Prime. PI version is 2.1. There is the following template, which contains: logging on logging 10.10.10.10 When I try to deploy it on the router 1800 IOS Version 12.3(14)T7 all is going
-
How to read Filter selection variable values into ABAP code
HI IP Gurus, Requierement: In my filter characterstics, i have assigned variables, which use will enter when running th e planning sequence. so variable values entered by user , i would like to get those values into ABAP code and pass them to some f