Catching Exceptions updating z tables.
Hello there, I´m trying to update a z-table , but I´m not sure if the way i´m working is the best , First I do a Select in order to check if the register exists ant then I make an update , but where I can catch any exception.???
SELECT * FROM zpx_ci_docs_proc
INTO TABLE ti_zpx_ci_docs
WHERE nume_docu = num_doc.
If sy-subrc = 0.
update zpx_ci_docs_proc set DATA_ENVI = dat_envi WHERE nume_docu = num_doc.
if sy-subrc = 0.
MESSAGE s000(zpb) WITH
" register update''
endif.
Thanks again.
Hi,
Use enqueue FM before updating the table and After updation use dequeue FM.
DO.
Use ENQUEUE_E_TABLE FM
IF sy-subrc = 0.
EXIT.
ENDIF.
ENDDO.
UPDATE statement.
IF sy-subrc = 0.
Use DEQUEUE_E_TABLE FM
ELSE.
Error Handling.
ENDIF.
Do enddo is used to ensure that there are no locks apart from yours on the table before you update it.
Thanks,
Kartavya
Similar Messages
-
Exception while updating a table
Hi
while updating a table throw entity bean i am getting
Base EJBException
java.sql.SQLException: ORA-01401: inserted value too large for column
how to resolve this problem
com.sap.engine.services.ejb.exceptions.BaseEJBException: SQLException while the data is being flushed. The persistent object is com.chep.portfolio.da.ejb.admin.UserPreferencesEJBBean4_0Persistent.
at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:101)
at com.sap.engine.services.ejb.entity.pm.TransactionContext.flushAll(TransactionContext.java:429)
at com.sap.engine.services.ejb.entity.pm.TransactionContext.flush(TransactionContext.java:378)
at com.sap.engine.services.ejb.entity.pm.TransactionContext.beforeCompletion(TransactionContext.java:506)
at com.sap.engine.services.ejb.entity.SynchronizationList.beforeCompletion(SynchronizationList.java:136)
at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:226)
at com.chep.portfolio.da.ejb.admin.UserPreferencesEJBLocalLocalObjectImpl4_0.setUserProfileId(UserPreferencesEJBLocalLocalObjectImpl4_0.java:614)
at com.chep.portfolio.admin.business.facade.user.UserFacadeBean.updateUserPreferences(UserFacadeBean.java:774)
at com.chep.portfolio.admin.business.facade.user.UserFacadeLocalLocalObjectImpl0_0.updateUserPreferences(UserFacadeLocalLocalObjectImpl0_0.java:247)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:157)
at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:79)
at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
at SoapServlet.doPost(SoapServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Caused by: java.sql.SQLException: ORA-01401: inserted value too large for column
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1144)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2152)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2035)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2876)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:240)
at com.chep.portfolio.da.ejb.admin.UserPreferencesEJBBean4_0Persistent.ejb_iUpdate(UserPreferencesEJBBean4_0Persistent.java:552)
at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:80)
... 33 more
java.sql.SQLException: ORA-01401: inserted value too large for column
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1144)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2152)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2035)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2876)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:240)
at com.chep.portfolio.da.ejb.admin.UserPreferencesEJBBean4_0Persistent.ejb_iUpdate(UserPreferencesEJBBean4_0Persistent.java:552)
at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:80)
at com.sap.engine.services.ejb.entity.pm.TransactionContext.flushAll(TransactionContext.java:429)
at com.sap.engine.services.ejb.entity.pm.TransactionContext.flush(TransactionContext.java:378)
at com.sap.engine.services.ejb.entity.pm.TransactionContext.beforeCompletion(TransactionContext.java:506)
at com.sap.engine.services.ejb.entity.SynchronizationList.beforeCompletion(SynchronizationList.java:136)
at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:226)
at com.chep.portfolio.da.ejb.admin.UserPreferencesEJBLocalLocalObjectImpl4_0.setUserProfileId(UserPreferencesEJBLocalLocalObjectImpl4_0.java:614)
at com.chep.portfolio.admin.business.facade.user.UserFacadeBean.updateUserPreferences(UserFacadeBean.java:774)
at com.chep.portfolio.admin.business.facade.user.UserFacadeLocalLocalObjectImpl0_0.updateUserPreferences(UserFacadeLocalLocalObjectImpl0_0.java:247)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:157)
at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:79)
at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
at SoapServlet.doPost(SoapServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
how to solve this oneHi, vanaja,
"inserted value too large for column" - this is the reason for the exception. That is, you are trying to persist a value that exceeds the table column capacity.
What you can do is reduce the length of the data element you want to update, or, 2) first increase the relevant column maximum length, then try to update the table again.
If you choose 2), and if you are using the system database, then you can use Java Dictionary and follow [THIS|http://help.sap.com/saphelp_nw70/helpdata/en/fe/53fb40f17af66fe10000000a1550b0/frameset.htm] procedure to increase the maximum length of a column.
Hope that helps!
Regards,
Yordan -
Progammatic update a table with a database view in the page
Hi All,
I am using JDev 11g. With FOD database schema, I have one database view Products which comes from two tables Products_Base and Product_Transactions. I created three EOs (ProductEO, ProductsBaseEO, ProductTransactionsEO) and three VOs (ProductVO, ProductsBaseVO, ProductTransactionsVO) based on their EOs respectively.
Here is my scenario. I have an ADF form which is based on the database view Products and is dragged and dropped from Data Controls->ProductVO. When an existing record is submitted, a backing bean method will be called to update the data against the table Products_Base (and the table Product_Transactions at the same time) programmatically. An update method updateProductPrice() is added into the Application Module and published it to UI Client. The submit button in the page is created by directly dragging and dropping Data Controls->updateProductPrice into the page. When I run it, I got the following error message,
Failed to post data to database during "Update": SQL Statement "UPDATE PRODUCTS ProductEO SET COST_PRICE=:1 WHERE PRODUCT_ID=:2".
What I don't understand here is that, in my update method updateProductPrice(), it supposes to update the table Products_Base. But from the error, it appears that it is trying to update the view Products. Can anyone give me a help on what I did wrong here? When I try to debug it, it throws an exception to this line in the method updateProductPrice(),
getDBTransaction().commit();
Here are my codes,
The method which got called in the backing bean
public String cb6_action() {
DCBindingContainer bc = (DCBindingContainer)getBindings();
FacesCtrlAttrsBinding ProductId = (FacesCtrlAttrsBinding)bc.get("ProductId");
FacesCtrlAttrsBinding CostPrice = (FacesCtrlAttrsBinding)bc.get("CostPrice");
JUCtrlActionBinding action =
(JUCtrlActionBinding)bc.findCtrlBinding("updateProductPrice");
DCDataControl dc = action.getDataControl();
ApplicationModule am = (ApplicationModule)dc.getDataProvider();
AppModule service = (AppModule)am;
service.updateProductPrice(new Long(ProductId.toString()), CostPrice.toString());
return null;
public BindingContainer getBindings() {
return BindingContext.getCurrent().getCurrentBindingsEntry();
The update method defined in the Application module (AppModuleImpl.java)
public void updateProductPrice(long productId, String costPrice) {
ProductsBaseEOImpl product = retrieveProductById(productId);
if (product != null) {
try {
product.setCostPrice(new Number(costPrice));
getDBTransaction().commit();
catch (JboException ex) {
getDBTransaction().rollback();
throw ex;
catch (SQLException ex1) {
getDBTransaction().rollback();
private ProductsBaseEOImpl retrieveProductById(long productId) {
EntityDefImpl productDef = ProductsBaseEOImpl.getDefinitionObject();
Key productKey = ProductsBaseEOImpl.createPrimaryKey(new DBSequence(productId));
return (ProductsBaseEOImpl)productDef.findByPrimaryKey(getDBTransaction(),productKey);
Edited by: john wang on Oct 27, 2009 7:14 AMor
merge into test
using (select rowid rid
, id
, sub_id
, startdate
, lead (startdate) over (order by id, sub_id) - 1 ed
from test) x
on (x.rid = test.rowid)
when matched then
update set end_date = x.ed
; -
I'm using a view and am able to create a grid that allows editing of one of the columns. Let's call the table where the column is updated "DepartmentFeeDetail." The view has several joins but up till now the column was editable.
Today I needed to join DepartmentFeeDetail with itself to pick up the debit side of a debit/credit pair. I want to show the gl account number for both
the debit and credit on the same row. I also need to update the value for both debit and credit.
I can no longer edit the column to no surprise. When updating using MSSQLMS I get the following error:
View or function 'MyTestView' is not updatable because the modification affects multiple base tables.
What should my strategy be in lightswitch? The grid is populated by a query that includes my lynq expressions in DepartmentFeeRateQuery_PreprocessQuery. The query may return 1000+ rows. I need to allow the accountant to edit either a single row's column
or enter a value in a field outside the grid and click a button "Apply fee rate to entire page."
All this was working fine until the requirement to show the debit side gl account number and to change the debit side value somehow.
I've tried adding a property to DepartmentFeeDetail but the "Is Computed" property wouldn't allow me to uncheck it. Is there a way to add an editable property for each grid row and initialize it to the
current value of the column returned by the view? I could then update a collection when one of the fields changes. If they change the global value and press "Apply fee rate to entire page"
I can update the collection as well.
Scott MitchellWhat I do is instead of using a View I use a updatable
WCF RIA Service.
This is an example of an updateable method:
public void UpdateQuestionDetailForUser(QuestionDetailForUser objQuestionDetailForUser)
// Get the current user
string strCurrentUserName = System.Web.HttpContext.Current.User.Identity.Name;
// We are under Forms Authentication so if user is blank then we
// are debugging and we are TestUser
if (strCurrentUserName == "")
strCurrentUserName = "TestUser";
// Check for an existing Answer for this Question for this User
var objSurveyAnswer = (from SurveyAnswers in this.Context.SurveyAnswers
where SurveyAnswers.SurveyQuestion.Id == objQuestionDetailForUser.QuestionId
where SurveyAnswers.UserName == strCurrentUserName
select SurveyAnswers).FirstOrDefault();
if (objSurveyAnswer != null)
try // This is an update ****
// Set values
objSurveyAnswer.Choice = Convert.ToInt32(objQuestionDetailForUser.SelectedChoice);
objSurveyAnswer.Comment = objQuestionDetailForUser.Comments;
// Update LightSwitch Database
this.Context.SaveChanges(
System.Data.Objects.SaveOptions.DetectChangesBeforeSave);
catch (Exception ex)
throw new Exception("Error inserting QuestionId " + objQuestionDetailForUser.QuestionId, ex);
else // This is an Insert ****
// Query the GetAllQuestionsForUser method because it calculates if a Question
// is Active or not for the QuestionId being inserted
// If it is not in the collection, do not allow the insert
var objUserQuestion = (from QuestionForUser in this.GetAllQuestionsForUser()
where QuestionForUser.UserName == strCurrentUserName
where QuestionForUser.QuestionId == objQuestionDetailForUser.QuestionId
select QuestionForUser).FirstOrDefault();
if (objUserQuestion != null)
try
// Get the Survey Question
var objSurveyQuestion = (from SurveyQuestions in this.Context.SurveyQuestions
where SurveyQuestions.Id == objQuestionDetailForUser.QuestionId
select SurveyQuestions).FirstOrDefault();
// Create a SurveyAnswer object
SurveyAnswer objNewSurveyAnswer = this.Context.CreateObject<SurveyAnswer>();
// Set values
objNewSurveyAnswer.UserName = strCurrentUserName;
objNewSurveyAnswer.Choice = Convert.ToInt32(objQuestionDetailForUser.SelectedChoice);
objNewSurveyAnswer.Comment = objQuestionDetailForUser.Comments;
objNewSurveyAnswer.SurveyQuestion = objSurveyQuestion;
// Update LightSwitch Database
this.Context.SurveyAnswers.AddObject(objNewSurveyAnswer);
this.Context.SaveChanges(
System.Data.Objects.SaveOptions.DetectChangesBeforeSave);
catch (Exception ex)
throw new Exception("Error inserting QuestionId " + objQuestionDetailForUser.QuestionId, ex);
else
throw new Exception("Error inserting Answer. Answer is not marked Active.");
Unleash the Power - Get the LightSwitch 2013 HTML Client / SharePoint 2013 book
http://LightSwitchHelpWebsite.com -
ODP OracleCommandBuilder. Updating a table including DATE columns.
Hi
I have a problem with the OracleCommandBuilder not creating the correct update commands when I have DATE type columns in the table.
I have created a test table (called DATETEST) with three columns:
STRINGCOLUMN VARCHAR2 10
DATECOLUMN DATE
NUMBERCOLUMN NUMBER
The STRINGCOLUMN is the primary key.
Then I created a typed dataset that looks like this:
STRINGCOLUMN string
DATECOLUMN string
NUMBERCOLUMN long
This is the XML schema for the typed dataset:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DateDS" targetNamespace="http://tempuri.org/DateDS.xsd" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns="http://tempuri.org/DateDS.xsd" xmlns:mstns="http://tempuri.org/DateDS.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DateDS" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="DATETEST">
<xs:complexType>
<xs:sequence>
<xs:element name="DATECOLUMN" type="xs:string" minOccurs="0" />
<xs:element name="STRINGCOLUMN" type="xs:string" minOccurs="0" />
<xs:element name="NUMBERCOLUMN" type="xs:long" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
And this is the test code:
Dim connection As Oracle.DataAccess.Client.OracleConnection
Dim adapter As New Oracle.DataAccess.Client.OracleDataAdapter()
Dim dbCommand As New Oracle.DataAccess.Client.OracleCommand()
Dim sqlstring As String
Dim data As New DateDS() 'Typed dataset
Const ConnectionString As String = "User Id=............."
Try
'Connect to database
connection = New OracleConnection(ConnectionString)
connection.Open()
'Get data from table DATETEST
dbCommand.CommandText = "SELECT STRINGCOLUMN, TO_CHAR(DATECOLUMN) AS DATECOLUMN, NUMBERCOLUMN FROM DATETEST"
dbCommand.Connection = connection
adapter.SelectCommand = dbCommand
adapter.Fill(data, "DATETEST")
'Make changes to dataset
data.DATETEST(0).DATECOLUMN = Now()
data.DATETEST(0).NUMBERCOLUMN = data.DATETEST(0).NUMBERCOLUMN + 1
'Update database
sqlstring = "SELECT * FROM DATETEST"
adapter.SelectCommand = New OracleCommand(sqlstring, connection)
Dim custCB As New Oracle.DataAccess.Client.OracleCommandBuilder()
custCB.DataAdapter = adapter
adapter.Update(data, "DATETEST")
'Disconnect
connection.Close()
connection.Dispose()
Catch exc As Exception
MessageBox.Show(exc.Message)
End Try
Getting the data from the database is not a problem.
The dataset contains the correct information.
But updating the database is impossible.
I get errors like:
ORA-01861: literal does not match format string
And if I don't specify a DATE format in the TO_CHAR statement I get this error:
Concurrency violation: the UpdateCommand affected 0 records.
I think I've tried everything.
I've used the OracleGlobalization class, with the SetSessionInfo method.
I've tried all different types of date conversions to make sure that
the date format on the database is the same as in the dataset.
I've tried to change the NLS parameters on the DB server and in the registry on the client.
I've tried to change the DATECOLUMN type in the typed dataset from string to Oracle.DataAccess.Types.OracleDate
But it still doesn't work.
The default date format on the DB 9i server is AMERICAN,(DD-MON-RR).
A strange thing is that when I instead of using the ODP classes use
the System.Data.OracleClient and its OracleCommandBuilder
the code works perfectly without any errors.
This is the test code that works:
Dim connection As System.Data.OracleClient.OracleConnection
Dim adapter As New System.Data.OracleClient.OracleDataAdapter()
Dim dbCommand As New System.Data.OracleClient.OracleCommand()
Dim data As New DateDS()
Dim sqlstring As String
Const ConnectionString As String = "User Id=......."
Try
'Connect to database
connection = New System.Data.OracleClient.OracleConnection(ConnectionString)
connection.Open()
'Get data from table DATETEST
dbCommand.CommandText = "SELECT STRINGCOLUMN, TO_CHAR(DATECOLUMN,'YYYY-MM-DD HH24:MI:SS') AS DATECOLUMN, NUMBERCOLUMN FROM DATETEST"
dbCommand.Connection = connection
adapter.SelectCommand = dbCommand
adapter.Fill(data, "DATETEST")
'Make changes to dataset
data.DATETEST(0).DATECOLUMN = Now()
data.DATETEST(0).NUMBERCOLUMN = data.DATETEST(0).NUMBERCOLUMN + 1
'Update database
sqlstring = "SELECT * FROM DATETEST"
adapter.SelectCommand = New System.Data.OracleClient.OracleCommand(sqlstring, connection)
Dim custCB As New System.Data.OracleClient.OracleCommandBuilder()
custCB.DataAdapter = adapter
adapter.Update(data, "DATETEST")
'Disconnect
connection.Close()
connection.Dispose()
Catch exc As Exception
MessageBox.Show(exc.Message)
End Try
My experience until this came up is that the ODP provider is better on everything
than the microsoft Oracle provider so I don't want to switch unless I have to.
Could someone that have used the ODP OracleCommandBuilder for updating a table including DATE columns with a typed dataset please give me some tips on how to make this work?
I would be the happiest man on earth if someone had a solution :-)
ErikDon't convert the dates to strings. Ever.
The command builder uses the metadata returned from the select command to build the insert/update commands. Using to_char in the query tells ODP that that is a varchar2 column. If you omit the to_char the commandBuilder will know to bind a date parameter in that spot.
Also in your typed dataset you should change the type from a string to a date.
David -
Updating a table entry when remoteexception occures
Hi,
We are having the requirement that if remoteexception happens from EJB 1.1 then we need to update one table with status set to false.
Since remoteexception is a system exception the transaction is marked for rollback and when we catch remoteexception and try to update the table
it is not getting updated because the client transaction is also rolledback.
we are actually using Websphere commerce server and we saw that WCS is able to update some of its own DB tables even when remoteexception occurs but we are not able to do it.
So is there a way that when remotexception happens from EJB 1.1 we can update one of our tables.
if yes then how can we do it.
Thanks
RaviTry by putting this update code in a separate EJB with REQUIRES_NEW transaction scope.
The the update is done in it's own transaction, and will not get affected by the other transactions 'marked for rollback' setting.
-Roy -
How to update many tables using the same code
<%@ page language = "java" import = "java.sql.*" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.text.*" %>
<%
String custname1=request.getParameter("custname");
session.setAttribute("custname",custname1);
String custtin1=request.getParameter("custtin");
session.setAttribute("custtin",custtin1);
%>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn;
conn=DriverManager.getConnection("jdbc:odbc:loginval");
Statement stat=conn.createStatement();
String stmt="insert into custdetails values('"+custname1+"','"+custtin1+"')";
stat.executeUpdate(stmt);
stat.close();
conn.close();
%>
<jsp:forward page = "success.html"/>
<%
catch(Exception e)
%>
<jsp:forward page = "tinerror.jsp"/>
<%
%>---------------------------------------------------------------
this is my code, now this code will be used by many users to update their corresponding tables. so my problem is based on the username i need to change the table name in the insert query, for example if the username is sai, then the table name has to be saicustdetails and if the user name is ram then the table name in the query has to be ramcustdetails. and so on.
please help*<%@ page language = "java" import = "java.sql.*" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.text.*" %>
<%
String tin1=request.getParameter("tin");
session.setAttribute("tin",tin1);
tin1=tin1+"custdetails";
String custname1=request.getParameter("custname");
session.setAttribute("custname",custname1);
String custtin1=request.getParameter("custtin");
session.setAttribute("custtin",custtin1);
//String tin2;
%>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn;
conn=DriverManager.getConnection("jdbc:odbc:loginval");
Statement stat=conn.createStatement();
String tin2;
tin2=tin1;
String stmt="insert into "+tin2+"values('"+custname1+"','"+custtin1+"')";
stat.executeUpdate(stmt);
stat.close();
conn.close();
%>
<jsp:forward page = "success.html"/>
<%
catch(Exception e)
%>
<jsp:forward page = "tinerror.jsp"/>
<%
%>i tried what u have said but still it does not work, anyother way????? -
Updating a table on DB considering changes on a grid in Csharp
I'm filling a Data Grid in C# (WinForms) via a System.Data.DataTable. DataTable is filled from a DB table via ODP.
I have a data navigator in Data Grid for updating, deleting and inserting rows.
I want to use DataTable to commit all changes made in Data Grid to the database.
I have to use OracleDataAdapter but I couldn't figure out how to achieve this.
What kind of a CommandText should I use to achieve all three commands (update, delete, insert)?
The code below didn't work (maybe because CommandText I inserted is not appropriate)
public void ExecuteNonQuery(string commandText, OracleCommand oracleCommand, CommandType commandType, DataTable dataTable)
oracleCommand.CommandText = commandText;
oracleCommand.CommandType = commandType;
try
oracleCommand.Connection = m_Connection;
OracleDataAdapter oracleDataAdapter = new OracleDataAdapter(oracleCommand);
oracleDataAdapter.Update(dataTable);
catch (Exception)
LoggerTrace.Instance.Write(TraceEventType.Error, LoggerTrace.LoggerTraceSource.DatabaseManagerError, "Query could not be executed!");
throw;
}Hey,
use the update method of the dataadapter object and the adatagrid input object: <adapater>.update(<datagrid>)
but i think you post in the wrong forum.
Use the knowledge base of Microsoft and .Net!
Marcel
Edited by: Marcel S. on 27.05.2013 11:12 -
Why is my update code running fine yet not actually updating the table?
When I step through this, it runs fine - the call to Commit executes without dropping into the Rollback block. Yet, the grid (and the underlying table) are not updated.
private void buttonUpdate_Click(object sender, EventArgs e)
const int TICKETID_COLUMN = 0;
String _ticketID = Convert.ToString(dataGridView1.CurrentRow.Cells[TICKETID_COLUMN].Value);
UpdateRecord(
_ticketID,
textBoxTicketSource.Text,
textBoxContactEmail.Text,
textBoxAboutLLSID.Text,
textBoxCategoryID.Text);
private void UpdateRecord(string ATicketID, string ATicketSource, string AContactsEmail, string AAboutLLSID, string ACategoryID)
try
con = new OracleConnection(oradb);
con.Open();
String update = @"UPDATE LLS.INTERPRETERTICKETS
SET TICKETSOURCE = :p_TICKETSOURCE,
ABOUTLLSID = :p_ABOUTLLSID,
CATEGORYID = :p_CATEGORYID,
CONTACTEMAIL = :p_CONTACTEMAIL
WHERE TICKETID = :p_TICKETID";
cmd = new OracleCommand(update, con);
cmd.CommandType = CommandType.Text;
// TICKETSOURCE, ABOUTLLSID, CATEGORYID, CONTACTEMAIL, TICKETID
OracleParameter p_TICKETSOURCE =
new OracleParameter("p_TICKETSOURCE", OracleDbType.NVarchar2, ParameterDirection.Input);
p_TICKETSOURCE.Size = 20;
p_TICKETSOURCE.Value = ATicketSource;
cmd.Parameters.Add(p_TICKETSOURCE);
OracleParameter p_ABOUTLLSID =
new OracleParameter("p_ABOUTLLSID", OracleDbType.Int32, ParameterDirection.Input);
p_ABOUTLLSID.Value = AAboutLLSID;
cmd.Parameters.Add(p_ABOUTLLSID);
OracleParameter p_CATEGORYID =
new OracleParameter("p_CATEGORYID", OracleDbType.Int32, ParameterDirection.Input);
p_CATEGORYID.Value = ACategoryID;
cmd.Parameters.Add(p_CATEGORYID);
OracleParameter p_CONTACTEMAIL =
new OracleParameter("p_CONTACTEMAIL", OracleDbType.NVarchar2, ParameterDirection.Input);
p_CONTACTEMAIL.Size = 100;
p_CONTACTEMAIL.Value = AContactsEmail;
cmd.Parameters.Add(p_CONTACTEMAIL);
OracleParameter p_TICKETID =
new OracleParameter("p_TICKETID", OracleDbType.NVarchar2, ParameterDirection.Input);
p_TICKETID.Size = 20;
p_TICKETID.Value = ATicketID;
cmd.Parameters.Add(p_TICKETID);
try
using (var transaction = con.BeginTransaction())
cmd.Transaction = transaction;
cmd.ExecuteNonQuery();
transaction.Commit();
catch (Exception ex)
ot.Rollback();
throw;
MessageBox.Show("Apparent success");
finally
con.Close();
con.Dispose();
dataGridView1.Refresh();
}It's hard to say with the limited information available. Nothing jumps out at me as being "wrong" in your code.
What is the Records Affected return value from cmd.ExecuteQuery?
I tested this and it worked fine for me:
SQL
========
SQL> create table interpretertickets (ticketsource nvarchar2(100),
2 aboutllsid number,
3 categoryid number,
4 contactemail nvarchar2(100),
5 ticketid nvarchar2(100));
Table created.
SQL>
SQL> insert into interpretertickets values(null,null,null,null,1);
1 row created.
SQL> commit;
Commit complete.
/////////////// CODE //////////////////////
private void button1_Click(object sender, EventArgs e)
string constr = "data source=orcl;user id=scott;password=tiger";
OracleConnection con = new OracleConnection(constr);
con.Open();
String update = @"UPDATE INTERPRETERTICKETS
SET TICKETSOURCE = :p_TICKETSOURCE,
ABOUTLLSID = :p_ABOUTLLSID,
CATEGORYID = :p_CATEGORYID,
CONTACTEMAIL = :p_CONTACTEMAIL
WHERE TICKETID = :p_TICKETID";
OracleCommand cmd = new OracleCommand(update, con);
cmd.CommandType = CommandType.Text;
// TICKETSOURCE, ABOUTLLSID, CATEGORYID, CONTACTEMAIL, TICKETID
OracleParameter p_TICKETSOURCE =
new OracleParameter("p_TICKETSOURCE", OracleDbType.NVarchar2, ParameterDirection.Input);
p_TICKETSOURCE.Size = 20;
p_TICKETSOURCE.Value = "newval1";
cmd.Parameters.Add(p_TICKETSOURCE);
OracleParameter p_ABOUTLLSID =
new OracleParameter("p_ABOUTLLSID", OracleDbType.Int32, ParameterDirection.Input);
p_ABOUTLLSID.Value = 123;
cmd.Parameters.Add(p_ABOUTLLSID);
OracleParameter p_CATEGORYID =
new OracleParameter("p_CATEGORYID", OracleDbType.Int32, ParameterDirection.Input);
p_CATEGORYID.Value = 456;
cmd.Parameters.Add(p_CATEGORYID);
OracleParameter p_CONTACTEMAIL =
new OracleParameter("p_CONTACTEMAIL", OracleDbType.NVarchar2, ParameterDirection.Input);
p_CONTACTEMAIL.Size = 100;
p_CONTACTEMAIL.Value = "[email protected]";
cmd.Parameters.Add(p_CONTACTEMAIL);
OracleParameter p_TICKETID =
new OracleParameter("p_TICKETID", OracleDbType.NVarchar2, ParameterDirection.Input);
p_TICKETID.Size = 20;
p_TICKETID.Value = 1;
cmd.Parameters.Add(p_TICKETID);
using (var transaction = con.BeginTransaction())
cmd.Transaction = transaction;
int recaff = cmd.ExecuteNonQuery();
MessageBox.Show("records affected: " + recaff);
transaction.Commit();
} -
While updating a table i am getting ORA-00600 error.
Hi all,
While updating a table i am getting the following:
**SQL Error: ORA-00600: internal error code, arguments: [qkebCreateConstantOpn1], [], [], [], [], [], [], [], [], [], [], []**
**00600. 00000 - "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"**
I am not getting how to proceed on this. Please guide me.
Thanks,
RiteshWhile performing some unspecified action (no DML) on an unknown table (no DDL) in an unknown version and edition of the Oracle database you had an untrapped Oracle exceptions.
There are too many unknowns to help you beyond recommending you open an SR at MyOracleSupport. -
How to catch exception while validating the username and password in hbm
Hi,
I do want to set the username and password dynamically in hibernate.cfg.xml
Here below is my configuration file.
{code<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>{code}
Also im getting that session factory object like the below code.
public class Sessions { private static SessionFactory sessionFactory; private static Configuration configuration = new Configuration(); static { try { String userName = GuigenserviceImpl.userName; String password = GuigenserviceImpl.password; String hostName = GuigenserviceImpl.hostName; String portNo = GuigenserviceImpl.portNo; String sId = GuigenserviceImpl.sId; configuration .setProperty("hibernate.connection.username", userName); configuration .setProperty("hibernate.connection.password", password); configuration.setProperty("hibernate.connection.url", "jdbc:oracle:thin:@" + hostName + ":" + portNo + ":" + sId); try { configuration.configure("/hibernate.cfg.xml"); sessionFactory = configuration.buildSessionFactory(); GuigenserviceImpl.strAccpted = "true"; } catch (Exception e) { e.printStackTrace(); GuigenserviceImpl.strAccpted = "false"; } } catch (HibernateException hibernateException) { GuigenserviceImpl.strAccpted = "false"; hibernateException.printStackTrace(); } catch (Throwable ex) { GuigenserviceImpl.strAccpted = "false"; ex.printStackTrace(); throw new ExceptionInInitializerError(ex); } } public static SessionFactory getSessionFactory() { return sessionFactory; }
So, in this above scenario, suppose if im giving the wrong password means exception should be caught and the string variable "GuigenserviceImpl.strAccpted" should be assigned to false.
But im getting the SQL Exception only in console like wrong username and password. And finally i couldn't able to catch the exception in Sessions class, static block.
Anyone can help me in catching that SQL Exception in my Sessions class and i need to handle that SQL Exception in my class.
Im getting this following exception message in my console.
INFO: configuring from resource: /hibernate.cfg.xml Apr 6, 2009 2:47:00 PM org.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml Apr 6, 2009 2:47:00 PM org.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: Using Hibernate built-in connection pool (not for production use!) Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: Hibernate connection pool size: 10 Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: autocommit mode: false Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@192.168.1.12:1521:orcl Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: connection properties: {user=scott, password=****} Apr 6, 2009 2:47:01 PM org.hibernate.cfg.SettingsFactory buildSettings WARNING: Could not obtain connection metadata java.sql.SQLException: ORA-01017: invalid username/password; logon denied at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:131) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:204) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:406) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399) at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:799) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:368) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:508) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510) at java.sql.DriverManager.getConnection(DriverManager.java:525) at java.sql.DriverManager.getConnection(DriverManager.java:140) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298) at com.beyon.ezygui.server.Sessions.<clinit>(Sessions.java:39) at com.beyon.ezygui.server.GuigenserviceImpl.testRPC(GuigenserviceImpl.java:322) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Thanks in advance.
Thanks & Regards,
Kothandaraman N.Hi,
Myself hardcoded that username and password checking like the below code.
String name = loginData.get("userName").toString();
String pswd = loginData.get("pswd").toString();
String hstName = loginData.get("hName").toString();
String prtNo = loginData.get("portNo").toString();
String sid = loginData.get("sId").toString();
SessionFactory sessionFactory = null;
try {
if (name.trim().equals(userName) && pswd.trim().equals(password)
&& hstName.trim().equals(hostName)
&& prtNo.trim().equals(portNo) && sid.trim().equals(sId)) {
sessionFactory = Sessions.getSessionFactory();
strAccpted = "true";
} else {
strAccpted = "false";
} catch (Exception e) {
e.printStackTrace();
strAccpted = "false";
}I have my own values in string objects, then comparing that values with the values from login form. If both values are matching, then i will do configurations in hibernate.
ResourceBundle resourceBundle = ResourceBundle
.getBundle("com.beyon.ezygui.server.Queries");
public static final String connection_url = resourceBundle
.getString("connection.url");
public static final String userName = resourceBundle.getString("userName");
public static final String password = resourceBundle.getString("password");
public static final String hostName = resourceBundle.getString("hostName");
public static final String portNo = resourceBundle.getString("portNo");
public static final String sId = resourceBundle.getString("sId");The above are the String objects i'm checking for the match with values from login form.
Thanks & Regards,
Kothandaraman N. -
Issue while Updating a table having Unique Secondary Index
Hi,
I am trying to update a 'Z' table in which there are 5 fields comprising of primary key. Out of them 2 key fields are defined as a part of seconadry index with 'Unique' option selected.
As per the requirement, I am trying to update the table using modify statement so whenever this statement occurs it will check the primary keys and accordingly try to m958572 wrote:
Hi,
We have observed the exception *'JDBC activity timed out while updating the table -Table1"* in our logs in prod environment.
1)we verified the AWR report for that particular time and observed that one update statement was trying to update the table table1.
its a simple update statement as below
UPADTE TABLE1 SET COL1=VAL1,COL2=VAL2 WHERE ID1=VAL1 AND ID2=VAL2;
there is a PK index on ID2 column.
2)we also came to know that there were no locks on TABLE1 during this time.
can some one please let me know what could be the possible reason for this kind of exception?
ThanksOS/Networking mis-configuration.
Oracle does not know or care about the type or flavor of remote client (JDBC, OCI, ODBC, etc).
Oracle's default configuration contains no timeout.
I suspect a FireWall setting. -
Error updating the table condition table 372 in J1IIN
Hello all,
I am facing the problem in the transaction code J1IIN (In CIN).
I have maintained the condition type JEXP ( A/R BED %) as 16% with the Key combination Country/Plant/Control Code (Table 357). While iam saving the Excise invoice the system is throwing the error like Error updating the table condition table 372
I have gone through the post given by Ms. Jyoti few days back and tried to do some changes in the customisation.
I tried to maintain a different access sequence for the condition type JEXP i.e In the access sequence except condition table 372, I have maintained all other condition tables.
Still the error is persisiting. Can anyone put some light on the issue.
I have even traced the values being hit in the tables directly. There is no relation of table 372, then why is it being cause of the error.
Gurus plz give ur suggestions.
Thanks
SrinivasHello Srinivas/Sandeep
Please ensure that access sequence in the condition type JEXC has got the table 372. If it is not there please maintain it.
The standard access sequence used in all duty condition type
is JEXC which has got the table 372 this will get updated once
you save your excise invoice.
If the issue is resolved, kinldy close the message.
Regards
MBS -
Hi Gurus,
I maintained the JCEP ( A/R Cess %) as 3%. While iam saving the Excise invoice the system is throwing the error like error updating the table condition table 372
Gurus plz give u r suggestions.
regards,
jyothi.
Edited by: jyothi. on Feb 25, 2008 7:26 AMHi Murali!
Even I am facing the same problem while working in ECC 6.0 environment. I am continuing in the same post as I feel it is most relevant post to continue the issue instead of opening a new issue.
I tried to maintain a different access sequence for the condition type JEXP i.e a new Access sequence(ZJEX) and also a new condition tpe (ZJEP). We don't have other Excise condition type in our Pricing procedure.
In the access sequence except condition table 372, I have maintained all other condition tables.
We have maintained the values against table 357- Country/Plant/Control Code.
Still the error is persisiting. Can you put some light on the issue.
I have even traced the values being hit in the tables directly. There is no relation of table 372, then why is it being cause of the error.
Thanks in advance,
Regards,
Karthik. -
Variable values updation in table TVARV- for SCMA - very urgent..
Hi all,
Can anyone pass on the code or logic for udating the values of variables like
SAP_SCMA_FISC_YEAR
SAP_SCMA_PERIOD
or the variables I define like
Current fiscal year
Current period
The program should update the values for above variables based on system date, by the period end dates maintained in T009B table
Your help in this regard is highly appreciated
Thanks in advance
KumarHere you go !!
<b>FM "UPDATE_TECHN_PERIODEN_ERWEIT"</b>
<b>FYI</b>
see the source code of FM "MCP_TECH_PERIODEN_GEN"
call function 'UPDATE_TECHN_PERIODEN_ERWEIT' "IN UPDATE TASK
tables
uw_t009b = mt_t009b
exceptions
others = 0.
<b>Pl... award the points.</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise"
Maybe you are looking for
-
How can I change the Apple ID on a device?
I have two cell phones, one for my wife and one for me, and an Ipad. Somehow I ended up paying for ICloud back up twice because one phone is under a different apple ID. I want to change the apple ID on that phone so it can have the same Icloud backup
-
Can i put my sim card from my iphone3 and put it into my iphone4
can i put the sim card out of my iphone3 and put it in to my iphone4
-
Twist S230U Display Port Version
I had some compatibility problems and ended up returning a 3-in-1 DisplayPort video adapter that converted to VGA, DVI and HDMI for my Twist due to compatibility problems. I was told that I need to find out the version of the DisplayPort on my comput
-
Hi Experts Im Facing an issue in Document Numbering Series in this Financial Year I had Created New Posting Period And in this I want to create two Document Numbering Series that in same period 14-15 but it is not allowing giving an e
-
Preview won't open PDF or jpegs error -1712
yesterday I started getting a Preview can't open -1712 message, whenever I try to open a jpeg or PDF file. How do I fix this?