Auto-Increment a UDF with correct format
Hope someone can help.
I am trying to auto-increment a UDF and everytime I do it SAP seems to be reformating it incorrectly.
Here is the query:
SELECT CAST(MAX(T.[U_UPC]) as numeric)+1
FROM RDR1 T
The results should look like 12345678
But instead SAP places a value of 12,345,678.00
I have tested this is SQL by itself and it works fine but when I make it into a Formatted Search in SAP it adds the commas and decimal places.
Thanks in Advance,
Craig
Really close,
Here is what I have.
I started out with 84573410001
I need to increment the last 5 digits by 1 each time the formated search is used.
So next the number should be 84573410002, 84573410003, 84573410003, etc....
Edited by: Craig Spehar on May 18, 2009 4:25 PM
Similar Messages
-
LINQ: Update a column with auto increment value
Hi All,
Greetings.
I am very new to C# (though with lot of experience in VC++). Now a days, I am engaged in a C# project where I need to deal with ADO.NET DataTable and related classes. I am stuck up in a scenario as follows:
I have a data table (of DataTable type) pre-populated with many rows (50000+), parsed from a log file. Now I need to add a column that will be holding index number for each records; eg. 1, 2, 3......
I have tried to add the auto-incremented column dynamically, with seed = 0 and increment = 1, but it is not working.
Is there any LINQ query that I can run to update the DataTable at once? Or foreach loop per DataRow is the only option here?
I appreciate any quick suggestion on this.
Thanks in advance.
Sanjoy Jana.You should add the auto increment column to the DataTable before you pouplate it with the other data:
//1. Create a datatable
DataTable dt = new DataTable();
//2. add the autoincrement column:
DataColumn column = new DataColumn();
column.DataType = System.Type.GetType("System.Int32");
column.AutoIncrement = true;
column.AutoIncrementStep = 1;
column.AutoIncrementSeed = 1;
//3. Fill the dataTable using an SqlDataAdapter or whatever
dt.Columns.Add(new DataColumn("name"));
dt.Rows.Add("1");
dt.Rows.Add("2");
dt.Rows.Add("3");
dt.Rows.Add("4");
Then you don't have to add the "auto incremented" values yourself in some kind of a loop (using for example LINQ or foreach).
If you want to know how to poplulate the DataTable from a database query using an adapter, please refer to the following page:
http://www.dotnetperls.com/sqldataadapter
Hope that helps.
Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question. -
Auto Increment Not Working - SQL Identity field
I am new to Visual Basic & SQL server but have some experience in Access & VBA. But this is a steep learning curve!
I am banging my head against a wall with a problem..
All of my tables in this database are in the dataset. The main one being tblItems with a PK 'ITEMID'
I have 2 forms - the first one is used to lookup an item the second displays the item's full details.
On the first form (lookup) I have a 'Add New' button which launches the second form with the code - frmProductDetail.VItemsBindingSource.AddNew()
This opens the form with empty boxes as expected. I have a 'Save' button on the second form with the following code -
Dim row As SASHItemsDataSet.tblItemsRow
row = SASHItemsDataSet.tblItems.NewRow
With row
.ITEMCODE = txtItemCode.Text
.ITEMDESCRIPTION = txtItemDescription.Text
.CATEGORY = cmbItemCategory.SelectedValue
.PURCHCOST = txtPurchCost.Text
.SELLCOST = txtSellPrice.Text
.UNIT = cmbUOM.SelectedValue
.VATID = cmbVAT.SelectedValue
.WHLOCATION = cmbWHLoc.SelectedValue
End With
SASHItemsDataSet.tblItems.Rows.Add()
Try
Me.Validate()
Me.VItemsBindingSource.EndEdit()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "UPDATE FAILED")
End Try
My problem is I get the error msg box with the following error 'Column 'ITEMID' does not allow nulls'
This field is set as a auto incrementing identity field with all the correct settings shown in Visual Studio so it shouldn't be coming back as null.
I have Googled for hours & tried all sorts with no luck..
I have clearly gone wrong somewhere but I can't work out where... any help appreciated!
JamesThis is the code on frmProductLookup that opens the form...
frmProductDetail.Show()
frmProductDetail.VItemsBindingSource.AddNew()
This is the code on frmProductDetail_Load...
'TODO: This line of code loads data into the 'SASHItemsDataSet.tblVAT' table. You can move, or remove it, as needed.
Me.TblVATTableAdapter.Fill(Me.SASHItemsDataSet.tblVAT)
'TODO: This line of code loads data into the 'SASHItemsDataSet.tblWarehouseLocations' table. You can move, or remove it, as needed.
Me.TblWarehouseLocationsTableAdapter.Fill(Me.SASHItemsDataSet.tblWarehouseLocations)
'TODO: This line of code loads data into the 'SASHItemsDataSet.tblStockUnits' table. You can move, or remove it, as needed.
Me.TblStockUnitsTableAdapter.Fill(Me.SASHItemsDataSet.tblStockUnits)
'TODO: This line of code loads data into the 'SASHItemsDataSet.tblItemCategory' table. You can move, or remove it, as needed.
Me.TblItemCategoryTableAdapter.Fill(Me.SASHItemsDataSet.tblItemCategory)
'TODO: This line of code loads data into the 'SASHItemsDataSet.vItems' table. You can move, or remove it, as needed.
'Me.VItemsTableAdapter.Fill(Me.SASHItemsDataSet.vItems)
Me.VItemsTableAdapter.Fill(Me.SASHItemsDataSet.vItems)
Me.VItemsBindingSource.Position = Me.VItemsBindingSource.Find("ITEMID", _passedText)
Me.txtWKSName.Text = Environment.MachineName
Me.txtSellPrice.Text = FormatCurrency(Me.txtSellPrice.Text)
Me.txtPurchCost.Text = FormatCurrency(Me.txtPurchCost.Text)
Me.txtPriceIVAT.Text = FormatCurrency(Me.txtSellPrice.Text + (Me.txtSellPrice.Text * 0.2))
On the tblItemTableAdapter this is the Command Text for the Insert Command...
INSERT INTO tblItems
(ITEMCODE, ITEMDESCRIPTION, UNIT, WHLOCATION, VATID, PREFSUPPLIER, CATEGORY, PURCHCOST, SELLCOST, INACTIVE)
VALUES (@ITEMCODE,@ITEMDESCRIPTION,@UNIT,@WHLOCATION,@VATID,@PREFSUPPLIER,@CATEGORY,@PURCHCOST,@SELLCOST,@INACTIVE)
SQL Server Management Studio clearly shows the column as an Identity column. If I add a row through SSMS it does create an PK identity automatically. I have also dropped the ITEMID column & recreated through SSMS which has no effect.
I am now considering creating a separate form just for adding an item but I have managed it in Access but am just struggling with VB!
Thanks,
James -
Creating auto-increment field in SharePoint List
In SharePoint, we can create the auto-incremental field by many ways, I am going to discuss two ways of doing it.
Calculated field
Item Event Receiver
1. Using Calculated field:
Using this we can accomplish it without doing any programing and it is a relatively simple way of doing it. By using “Calculated” column in SharePoint List we can create auto-increment field. We can accomplish this by creating a new column and choosing the
column type as “Calculated (calculation based on other columns)”. And in Formula field, we have to enter [ID]
In fact this will be using the values from “ID” field from SharePoint list that starts from 1.
For example, if we want to start our auto-increment column from 100, we can modify the “Formula” field of Create New column screen, we can have to enter [ID] + 99
For detailed info please follow the blog I wrote here: http://faisalrafique.wordpress.com/2011/03/19/creating-auto-increment-field-in-sharepoint-list/
2. Using Item Event Receiver:
By using this strategy, users have advantage to edit the existing values, we can also avoid it by making field read-only on feature activation. Using item event receiver, on ItemAdded event, we have to find the highest value among previously added items
and then save the incremented value to current newly created auto-incremental column.
For code of event reciever please follow the blog I wrote here:
http://faisalrafique.wordpress.com/2011/03/19/creating-auto-increment-field-in-sharepoint-list/
Happy CodingUse Sharepoint Designer to create a Workflow for the list containing the field to increment. For my project I had an Invoice field that I wanted to start with 1001 and increment from there so I made the following workflow to do this.
In the new workflow screen in Sharepoint Designer create two actions in Step 1:
Calculate Current Item:ID plus 1000 (Output to Variable: calc)
then Set AutoIncrementNumber to Variable: calc
This is just a guide. If you just want the auto-increment to start with 1 then you can just use this step
Set AutoIncrementNumber to Current Item:ID
Also, make sure you select the correct name for your field in the Workflow action instead of AutoIncrementNumber.
Save the Workflow, close it, and then open it again in Sharepoint Designer. Check the box for "Start workflow automatically when an item is created." Save it again and then click on the Publish button to make it active on the sharepoint site. The value should
now increment for each new item created in the list. -
Hi there experts,
I'm just curious if its possible to have an auto increment number on udf ? I have a test server and I'm just curios about it but I don't know if its possible or not.
Thanks in advance guys.
Warm regards,
TonyHi Tony,
Say you created an udf U_Test for marketing document AR Invoice.
Now you want an auto increment on that udf for every invoice created, then you need to use the following FMS;
Select max(T0.[U_Test])+1 from OINV T0 where T0.Series = $[OINV.Series]
execute this query in query generator and save it. Press AltshiftF2 on udf and assign this formatted search in this udf.
You may set it to auto refresh on docnum else you may press shift+F2 to get the desired output. Hope this helps.
All the best!!
Thanks,
Joseph -
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. -
Help with Oracle Connection- "Input string was not in a correct format"
Hello, can some one, anyone please help me. I have a simple VS 2005 C# application that connects to oracle. I've set it up to take the username, password and tnsname as arguments. I am using Client 9i, version 9.2.0.401 of Oracle.DataAccess.dll, and .NET Framework 2.0.
It works fine when I run it from VS 2005, I have also set up a test machine w/o VS 2005 and ran my install package and it runs fine. I sent it to one of my co-workers and when he tries it the OracleConnection obect fails with the error.
"Input string was not in a correct format"
strange in that it is not an ORA error, just the identifed text!?
Here is the code:
## begin code
OracleConnection dbc = new OracleConnection();
string sConnectString = "User Id=" + username.ToString() + ";Password=" + password.ToString() + ";Data Source=" + tnsname.ToString();
dbc.ConnectionString = sConnectString.ToString();
MessageBox.Show("Attempting to Connect to Oracle");
dbc.Open();
MessageBox.Show("Connected to Oracle: " + dbc.ServerVersion);
## end code
Pretty basic, what could be going on?
Since this only happens with an installation, I put in the message boxes to verify exactly where it chokes. I get the first message box, then an error with the identified text. I've seen a number of posts regarding input string format problems, but not a one dealing with OracleConnection.Open(). I added all the ToString() calls just to make sure everything was a string but it did not change the end result.
Anyone? Thanks In advance!
Eric S.Hello,
well, i got a message "...string not wellformed format...", too.
If you have defined the parameters as string, you don't need the additonal "ToString()". Please ckeck your tnsnames -string. Try to debug this. I believe you have copy the format from the tnsnames.ora and there you have much brackets.
For example, two code snippets:
As datasource i use <Server>:<Port>/<Instance>
try
string FDsn ="User Id="+FDbUser+";Password="+FDbPwd;
FDsn +=";Data Source=wth5:1521/Ora9.wth5";
FConn = new OracleConnection(FDsn);
FConn.Open();
if (FConn.State == ConnectionState.Open )
FConn.Close();
catch (Exception ex)
FStateMsg = "Connection to database failed. Check Configuration in parameter: ConnectionString. " + ex.Message;
Above i connect to a Ora 9.2.0.1
by using
FDsn +=";Data Source=wth5:1522/XE";
i connect to an OraExpress database on the same machine.
My Oracle.dataAccess.dll ist the newest, 10.2.... and it runs under Framework 1.1.x and Framework 2.x
I'll hope it will help you. Best regards! -
Auto increment with collection is not working
I am using KODO 3.0 with MYSQL 4.0.16. I have created two JDO object as
follows
BankAccount contains a collection of Contacts object. My metadata looks
like this
<class name="BankAccount">
<field name="contacts">
<collection element-type="Contacts"/>
<extension vendor-name="kodo" key="element-dependent"
value="true"/>
</field>
</class>
<class name="Contacts" objectid-class="Contacts$contactId">
<field name="contactId" primary-key="true">
<extension vendor-name="kodo" key="jdbc-auto-increment"
value="true"/>
</field>
</class>
There is no problem in the persisting of BankAccount object and adding
Contacts to it, but Contacts collation is not retrieved along with parent
object. In the database join table, the contact Id value it is always set
to null.
Things are working well with out contact id in Contacts.
Can anyone help?
Regards,
dharmiSet the following property:
kodo.jdbc.AutoIncrementConstraints: true
Described here:
http://www.solarmetric.com/Software/Documentation/latest/docs/ref_guide_pc_oid.html#ref_guide_pc_oid_pkgen_autoinc -
I was backing up my MacBook with Time Machine and using my new (correctly formatted) external hard drive. All was going well when my 2 yo knocked the disk leading to a "failure" by time machine (Latest Backup: Failed). Now the MacBook will not even recognize the hard drive. I have rebooted, tried all I can think of, but no acknowledgement of the drive. The drive itself makes noise and vibrates as if working, but nothing from the Mac. Please help or $100 down the drain... Thank you.
You may have already done these resets in the "tried all I can think of " portion of your post.....if not then here they are.....
PRAM
support.apple.com/kb/HT1379
SMC
support.apple.com/kb/HT3964
.....hopefully that is all that is required..... -
CMP with auto-increment primary key.Please help
Hi all,
I new with EJB technology so please bear with me.
Env: 2k Server, SQL 2k Server
Sun One(Forte EE) to develop and deploy CMP
I got the servlet to load the data from CMP's business mehods
is fine. Calling the findPrimaryKey is OK too. Even when I try to insert the row into DB is OK. At this time I make key PK is int AND NOT
AUTO INCREMENT everything is OK. In the ejbCreate method
I called setPK, setName ...It's fine.
The problem comes when I try to make the PK(still int) to be auto-increment field.In ejbCreate not call setPK because of in SunOne IDE, under the J2EE RI tab of EJB Module property, the Auto generate SQL I set to false so that I can
modify the SQL statement under SQL Deployment.createRow not taking the PK. I thought that will do it but it doesnot like it at all (I got Exception with transaction rollback)I just want to insert a single row with ID and name that's all.
Then I changed the SQL statment take PK and changed the Auto Generate SQL to True and in ejbCreate the PK as one of the args and called setPK this time with null object. It doesn't like neither.(Exception Cannot set the primary key with null. That is reasonable.)
I thought using EJB fast and clean technique would help developer to develop application with easiness.
So I realy stuck with this, I wonder ejb 2.0 support for auto increment at all because I would like to take advantage of the auto increment feature of the DB without writing the PrimaryKeySequence generator at all.
Am I missing something with this? May be just config thing to tell
that my PK is auto-increment field so that when the ejbCreate called it knows not taking the PK or even not asking to call setPK in ejbCreate.
Any help would appreciated.Check out this thread, there's a bunch of good info:
http://www.theserverside.com/patterns/thread.jsp?thread_id=4976 -
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. -
How can I use a mySQL database schema with numeric auto increment primary key instead of GUID?
Hello!
I'm using the TestStand "MySQL Insert (NI)" database schema with GUID as primary key. So everything works fine.
But I prever using numeric values as primary key, because the database is in conjunction with another database which uses numeric values as primary key.
Is this possible?
Has anyone an idea how I can modify the "Generic Recordset (NI)" for use with MySQL?
Thanks!
Configuration:
Microsoft Windows XP
TestStand 3.1
MySQL 4.1.12a
MySQL ODBC 3.51 Driver
BrosigAdam -
The TestStand Database Logging feature does not allow you to run a separate SQL command after executing the command for a statement(table), so I do not think that you can use an auto incrementing column for the tables. There is just no way to get it back in a generic way. One option that I tried is something similar to the Oracle schema where you call a store procedure to return a sequence ID for each record that you want to add.
So you would have to create the following sequence table in MySQL:
CREATE TABLE sequence (id INT NOT NULL);
INSERT INTO sequence VALUES (0);
Then create a stored procedure as shown below that will increment the sequence value and return it in a recordset:
CREATE PROCEDURE `getseqid`()
BEGIN
UPDATE sequence SET id=LAST_INSERT_ID(id+1);
SELECT LAST_INSERT_ID();
END
Then update the MySQL tables to use INT primary and foreign key values, so the TestStand MySQL SQL file to create all tables would have text like this:
CREATE TABLE UUT_RESULT
ID INT PRIMARY KEY,
~
CREATE TABLE STEP_RESULT
ID INT PRIMARY KEY,
UUT_RESULT INT NOT NULL,
~
Then update the schema primary and foreign key columns in the TestStand Database Options dialog box to be INT to match the table. For the primary key columns, you will have to set the Primary Key Type to "Get Value from Recordset" and set the Primary Key Command Text to "call getseqid()". This will call the stored procedure to determine the next value to use as the ID value.
Hope this helps...
Scott Richardson
National Instruments -
Update table column with same auto-increment value, via T-SQL stored procedure
Good Evening to every one,
I have a table 'Contracts' as we can see in the picture below (I exported my data on An Excel Spreadsheet). Table's primary key is 'ID' column.
I am trying to create a stored procedure (i.e. updContractNum), through which I am going to update the 'Contract_Num' column, in every row where the values on Property_Code, Customer, Cust_Category and Amnt ARE EQUAL, as we can see in the schema above.
The value of Contract_Num is a combination of varchar and auto_increment (integer). For example, the next value on 'Contract number' column will be 'CN0005' for the combination of 11032-14503-02-1450,00
I' m trying to use CURSORS for this update but I am new in using cursors and I am stuck in whole process. I atttach my code below:
CREATE PROCEDURE updContractNum
AS
--declare the variables
DECLARE @CONTRACT_NUM VARCHAR(10); -- Contract Number. The value that will be updated on the table.
DECLARE @CONTRACT INTEGER; -- Contract number, the auto increment section on contract number
DECLARE @CONTR_ROW VARCHAR(200); -- Contract row. The row elements that will be using on cursor
DECLARE CONTRACT_CURSOR CURSOR FOR -- Get the necessary fields from table
SELECT PROPERTY_CODE, CUSTOMER, CUST_CATEGORY, AMNT
FROM CONTRACTS;
OPEN CONTRACT_CURSOR -- open a cursor
FETCH NEXT FROM CONTRACT_CURSOR INTO @CONTR_ROW
WHILE @@FETCH_STATUS = 0 -- execute the update, for every row of the tabl
BEGIN
--update Contract_Num, using the format coding : contract_number = 'CN' + 0001
UPDATE CONTRACTS
SET CONTRACT_NUM = 'CN'+@CONTRACT_NUM+1
END
CLOSE CONTRACT_CURSOR
Thank you in advance!You dont need cursor
You can simply use an update statement like this
UPDATE t
SET Contract_Num = 'CN' + RIGHT('00000' + CAST(Rnk AS varchar(5)),5)
FROM
SELECT Contract_Num,
DENSE_RANK() OVER (ORDER BY Property_Code,Customer,Cust_category,Amnt) AS Rnk
FROM table
)t
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
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' -
Auto Increment No in Sales Order Title Level UDF
Dear Experts,
Please provide me query for Auto Increment No in Sales Order Title Level UDF.
BR
DeepHello Friend
Try this
Select max(T0.[U_AUN])+1 from ORDR T0 where T0.series = $[ORDR.series]
and make it referesh.
Thanks
Manvendra Singh Niranjan
Edited by: Manvendra Singh Niranjan on Feb 21, 2012 12:38 PM
Maybe you are looking for
-
Download for BI 7.0 Front-end components
Hi, Im trying to find the place where I can download the BI Bex Suite of programs mainly BEx QD, BEx Analyzer and BEx Web Analyzer. Do you know where I can download this software or does anybody have the software that they could send to me. The softw
-
Can a db with character set UTF8 be restored to AL32UTF8?
Hello Everyone, Good Day. Our present production and non-production databases are configured with NLS_CHARACTERSET as UTF8. However, as we are in the process of migrating to a new server, we intend to configure the new databases with NLS_CHARACTERSET
-
Restart: Outbound Error in SXMB_MONI
Hi ALL I have an error in SXMB_MONI in outbound status. couldnt see any worklogs in PE also. The message status shows success but error in outbound. <u>Howto restart the message.</u> 1. IP is 0 in sxi_cache 2. CC configuration are correct thkx Prabhu
-
The DVD wont work either with DVD-films, Application DVD or music CD. I have tried a lens cleaner disc but it will not work. The disks is "spinning around" for a while and then they ejects. What to to? Reisnstall Mac OS?
-
Apple TV2. black screen
I have a magnavox 42"tv. When I plug in Apple TV2 it shows Apple home screen and in 10 sec. the screen goes black. Any ideas?