URGENT - Insert into database error
Hi people.
I am using this code to insert multiple records into a table from a multi select box.
Sometimes it works, other times It throws an error saying:
Error. [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt
Why would this be? and how can I fix this?
<%
int memberId = 0;
int groupId = Integer.parseInt(request.getParameter("groupId"));
String[] x = request.getParameterValues("totalUsers");
String groupName = "";
String name = "";
String groupId2 = "";
String name2 = "";
int m = x.length;
String query = "SELECT MemberID FROM tGroup_X_Member WHERE (MemberID IN (SELECT memberID FROM tGroup_X_Member WHERE (MemberID IN (SELECT UogID FROM tSubject WHERE Name IN (SELECT CallerName FROM CALLS WHERE CallerName = ?)))))";
String insertQuery = "INSERT INTO tGroup_X_Member(MemberID, GroupID)" + "VALUES (?, ?)";
Connection conn = null;
PreparedStatement prep = null;
PreparedStatement prep2 = null;
ResultSet rSet = null;
try {
DBConnection db = new DBConnection();
conn = db.conn;
conn.setAutoCommit(false);
prep = conn.prepareStatement(query);
prep2 = conn.prepareStatement(insertQuery);
for (int i=0; i<m; i++) {
prep.setString(1, x);
ResultSet resSet = prep.executeQuery();
if (resSet.next()) {
memberId = resSet.getInt(1);
prep2.setInt(1, memberId);
prep2.setInt(2, groupId);
prep2.executeUpdate();
conn.commit();
response.sendRedirect("modifyGroupExpand.jsp?groups=" + groupId);
} catch (Exception ex) {
try {conn.rollback();} catch (Exception ex1) {ex1.printStackTrace();}
out.println("Error. " + ex.getMessage());
finally {
try {rSet.close();} catch (Exception ex1) {ex1.printStackTrace();}
try {prep.close();} catch (Exception ex1) {ex1.printStackTrace();}
try {prep2.close();} catch (Exception ex1) {ex1.printStackTrace();}
try {conn.close();} catch (Exception ex1) {ex1.printStackTrace();}
}%>
Thanks
Looks like you might be trying to insert a row before all of the rows are returned from the query, this is possible - how many rows do you get back on the members that fail the insert?
You could create a seperate connection for the inserts or move to your last row before starting to insert.
Secondly, your query seems very intense with all the sub selects. Will the following not work?
Select tGroup_X_Member.MemberId
From tGroup_X_Member, tSubject, CALLS
Where tGroup_X_Member.MemberID = tSubject.UogID And
tSubject.Name = CALLS.CallerName And
CALLS.CallerName = ?
Similar Messages
-
Inserting data into database error
for your information, i'm using jsp to create my web page. i am inserting sequence number into the database. When first data in insert into database it will show number 1 in the database. when second data in insert in database, it will show number 2 in the database. the data are inserted when user click submit button from the web page.
i am creating a page name main.jsp. when the user select option from the list bar, it will link to new page. the option value in the list bar are 'sentul view' and 'cityview'. if the user choose 'cityview', it will link to new page that allows user to key in their information. the problem is sequence number was enter wrongly into database. when the first user click submit after selected "city view', sequence in 'cityview' database will increase. then when the other user register 'sentul view', the database sequence will start from number 2 in 'sentul view' database. how to avoid the problem...
i enclosed some part of the code:
<%
String sql_selectMax = "SELECT max(smb_regr_seq_no) as maxNo "+
"FROM smbyer ";
Statement stmt_selectMax = conn.createStatement();
ResultSet rset_selectMax = stmt_selectMax.executeQuery(sql_selectMax);
while(rset_selectMax.next()){
reqNo = rset_selectMax.getInt("maxNo");
out.print (reqNo);
reqNo = reqNo + 1;
%>Note: Sequences are a feature provided by the Oracle database.
That code will not work in MySQL, Access or MS SQL Server.
And yeah, like the guy said, you need to keep track of a sequence number for each individual table you want to add records to.
There are a huge number of resources on the internet discussing issues of IDs. Google is your friend:
http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=database+unique+ids+java
Cheers,
evnafets -
Pool data from text file and insert into database
Can anyone tell me how to pool data from a text file and insert into database?
let's say my text file is in this format
123456 Peter 22
234567 Nicholas 24
345678 Jane 20
Then I need to insert the all the value for this three column into a table which has the three column name ID, Name, Age
Anyone knows? I need to do this urgently...Thank in advanced1. Use BufferedReader and read the file line by line.
2. Loop thru the file and do the following steps with in this loop.
3. Use StringTokenizer to seperate each line into three values (columns).
4. Now create a insert statement with these values and add the statement to the batch (using addBatch() method of PreparedStatement or Statement).
5. Finally (after exiting the loop), execute these batch of statements (using ps.executeBatch()).
Sudha -
XML document convert into String and Insert into Database
Hello all,
In the FIle to File Scenario I want to send the data to the Reciever System in xml Document and convert into String and insert into Database.
Please can you tell me exact way how to send it.
Thanks & Regards,
RajHI,
As per my understanding your scenario is File to file where you will get output fiel in XML format.
Now that XMl payload need to be passed as single string in the database via XI.
You cauld do this but you need to imply some manipulations such as
With the help of standard API you need to concatenate the XML tags and create the structre along with the data.
For e.g. in your outpuf file the XML structre contain data as
<field1>ABCD</field1>
Then in mapping
The source field will be mappeda s concat(<field1>) + value of Source field "ABCD" + concat(</field1>) to the target field.
This is the way that you could achive the requirments else there is no direct way avaialble for it.
thanks
Swarup -
Date not changing based on timezone during insert into database...
I have a bpel project that gets data in GMT and insert into a database that's based on EST timezone...for some reason during insert into database, I expect it to reflect the time in EST time, but it's not doing so. It's a standard oracle bpel project and there was no customization to the date input. The following are the details:
input data:
<InvoiceDate>
<GLogDate>20110613213249</GLogDate>
<TZId>UTC</TZId>
<TZOffset>+00:00</TZOffset>
</InvoiceDate>
date I get after transformation:
<ns5:invoiceDate> 2011-06-13T21:32:49 </ns5:invoiceDate>
date that gets inserted into the database:
6/13/2011 9:32:49 PM
Any thoughts as to what's going on? Is this the intended fuctionality or how does it adjust itself to the daylight saving? I thought database itself would handle it in this case.
Thanks,
AmkayWpgMom --
From your description, it sounds totally like you are using Manually Scheduled tasks, which is not what you should be using in your project. If you look at the Gantt bars in the Gantt Chart view of your project, if the Gantt bars are a turquoise color,
you are using Manually Scheduled tasks, and that would be the reason that the dates do not automatically calculate for you. If this is the case, click the Select All button to select every task in the project. In the Tasks section of your Task
ribbon, click the Auto Schedule button. From this point forward, your project schedule will automatically recalculate every time you make any kind of schedule edit.
Also, in the lower left corner of the Microsoft Project application window, you will probably see a button that says New Tasks: Manually Scheduled. Click this button and select the Auto Scheduled option.
To avoid all of these problems in all future projects, click File > Options. In the Project Options dialog, click the Schedule tab. In the Scheduling Options for This Project section, click the pick list where you see the name of your project
and select the All New Projects item on the pick list. Click the New Tasks Created pick list and select the Auto Scheduled option. Click the OK button.
Hope this helps.
Dale A. Howard [MVP] -
Error while insert into database using DB adpater for Field BLOB
Hello All
I am trying to tranfer data from Database A to Database B using Oracle DB adapter.
Table of databse A contains field BLOB, which cotains the resume /doc file.After transformation in Database B format ,while invoking the DB adapter to insert, I am getting follwing error
<bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="code"><code>null</code>
</part><part name="summary"><summary>file:/u01/bpelvinc/product/10.1.3.1/OracleAS_1/bpel/domains/viapps/tmp/.bpel_ERecuit_Application_New_1.0_d1c2b2149a9e0c7c745279667ad1fc84.tmp/DB_APPL_111.wsdl [ DB_APPL_111_ptt::insert(RtmApplicantCollection) ] - WSIF JCA Execute of operation 'insert' failed due to: DBWriteInteractionSpec Execute Failed Exception.
insert failed. Descriptor name: [DBAPPL111.RtmApplicant]. [Caused by: Error in encoded stream, got 2]
; nested exception is:
ORABPEL-11616
DBWriteInteractionSpec Execute Failed Exception.
insert failed. Descriptor name: [DBAPPL111.RtmApplicant]. [Caused by: Error in encoded stream, got 2]
Caused by Exception [TOPLINK-3001] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070608)): oracle.toplink.exceptions.ConversionException
Exception Description: The object [xs:base64Binary 43524541544520544193B0D0A], of class [class java.lang.String], could not be converted to [class java.sql.Timestamp].
Internal Exception: java.io.IOException: Error in encoded stream, got 2.
</summary>
</part><part name="detail"><detail>
Exception Description: The object [xs:base64Binary 4352E616D65293B0D0A], of class [class java.lang.String], could not be converted to [class java.sql.Timestamp].
Internal Exception: java.io.IOException: Error in encoded stream, got 2</detail>
</part></bindingFault>
Please let me know ,what are the possibilities.
Thanks
SatendraHi...
well... My flow goes like Pl/SQl ---> BPEL,
Now PL/SQL code reads data from the Database A and Send it to BPEL which inserts into the Database B.
with respest to above design, I found the problem in pl/sql block.
Actually I am sending a BLOB field in the soap message. but some how pl/sql now ablt tot handle that or sending some wrong data.
my question is how to send a blob filed data to bpel using pl/sql block. this the reasion I am getting above error.
Thanks -
need help,am tryin to insert data into my database which contains date,
names,phone,address and deposit and it's giving this error message:
java.lang.ClassCastException:java.util.Date cannot be cast to java.sql.Date.
somebody help me please.thanks in advance.
code:
'\n'
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import java.text.*;
public class NewCustomerRecord extends JFrame{
private JTextField firstnameF,othernameF,phoneF,addressF,depositF,currentF,dateF;
private JButton registerbutton;
private Connection con;
private Statement st;
private ResultSet set;
private PreparedStatement stat;
public NewCustomerRecord(){
//super(f,"",true);
JPanel panel = new JPanel();
panel.setLayout(null);
JLabel firstL = new JLabel("First Name:");
firstL.setBounds(5,15,80,20);
panel.add(firstL);
firstnameF = new JTextField();
firstnameF.setBounds(70,15,100,20);
panel.add(firstnameF);
JLabel otherL = new JLabel("Other Names:");
otherL.setBounds(175,15,80,20);
panel.add(otherL);
othernameF = new JTextField();
othernameF.setBounds(255,15,100,20);
panel.add(othernameF);
JLabel phoneL = new JLabel("Phone No.:");
phoneL.setBounds(5,40,80,20);
panel.add(phoneL);
phoneF = new JTextField();
phoneF.setBounds(70,40,100,20);
panel.add(phoneF);
JLabel addressL = new JLabel("Address:");
addressL.setBounds(185,40,80,20);
panel.add(addressL);
addressF = new JTextField();
addressF.setBounds(255,40,100,20);
panel.add(addressF);
JLabel depositL = new JLabel("Deposit:");
depositL.setBounds(5,65,60,20);
panel.add(depositL);
depositF = new JTextField();
depositF.setBounds(70,65,100,20);
panel.add(depositF);
/*JLabel currentL = new JLabel("Current Bill:");
currentL.setBounds(135,65,80,20);
panel.add(currentL);
currentF = new JTextField();
currentF.setBounds(205,65,50,20);
panel.add(currentF);*/
JLabel dateL = new JLabel("Date:");
dateL.setBounds(185,65,50,20);
panel.add(dateL);
dateF = new JTextField();
dateF.setBounds(255,65,100,20);
panel.add(dateF);
registerbutton = new JButton("Register Customer");
registerbutton.setBounds(115,100,145,20);
registerbutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
insertRecord();
dispose();
registerbutton.setMinimumSize(new Dimension(50,20));
panel.add(registerbutton);
add(panel);
setSize(400,200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
public void insertRecord(){
double bal=0.0;
String s=depositF.getText();
double dep = Double.parseDouble(s);
bal+=dep;
//String ss=dateF.getText();
//short dd=Short.parseShort(ss);
String ss=Double.toString(dep);
String bb=Double.toString(bal);
String fullName=firstnameF.getText()+"\t"+othernameF.getText();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:sparkletransaction","","");
SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yy"); //added
Date d = (Date)sdf.parse(dateF.getText());
//java.sql.Date date = new java.sql.Date();
//date.setTime(d.getTime());
String insert="INSERT INTO personaltransaction(date,name,phone,addres,deposit,balance) VALUES(?,?,?,?,?,?)";
//insert=insert+;
stat=con.prepareStatement(insert);
stat.setDate(1,d);
stat.setString(2,fullName);
stat.setString(3,phoneF.getText());
stat.setString(4,addressF.getText());
stat.setString(5,ss);
stat.setString(6,bb);
stat.executeUpdate();
stat.close();
catch(Exception e){
System.out.println(e);
public static void main(String[] arg){
new NewCustomerRecord().setVisible(true);
}java.lang.ClassCastException:java.util.Date cannot be
cast to java.sql.Date.
Hint:
public static java.sql.Date convert2SqlDate(java.util.Date date) {
return new java.sql.Date(date.getTime());
} -
Date Format in servlet when i insert into database
I am inserting data into database through servlet, but i am getting NumberFormat Exception, and my datatype in database is DATE ,when i typecast my day and year because they r in int and changing into String,still i am getting the same error .So please can any one tell me where to cahnge the format of date and how to type cast to my Date format of database.
Thanks,
lalithaMy code is:import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.text.*;
import java.sql.Date;
import java.util.*;
public class RegisterServlet extends HttpServlet
Connection con;
PreparedStatement ps;
public void init(ServletConfig sc) throws ServletException
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:plk","scott","tiger");
System.out.println("connection created");
catch(Exception e)
System.out.println(e);
public void doPost(HttpServletRequest req, HttpServletResponse res)
try
res.setContentType("text/html");
PrintWriter pw= res.getWriter();
String ulogin=req.getParameter("login").trim();
String uph1=req.getParameter("ph1").trim();
int ph1=Integer.parseInt(uph1);
String upass=req.getParameter("pass").trim();
String uph2=req.getParameter("ph2").trim();
int ph2=Integer.parseInt(uph2);
String cpass=req.getParameter("cfm").trim();
String uweb=req.getParameter("web").trim();
String ufirst=req.getParameter("first").trim();
String uaddress=req.getParameter("address").trim();
String umiddle=req.getParameter("middle").trim();
String ucity=req.getParameter("city").trim();
String ulast=req.getParameter("last").trim();
String uzip=req.getParameter("zip").trim();
int zip=Integer.parseInt(uzip);
String ud=req.getParameter("Aday").trim();
String um=req.getParameter("Amonth").trim();
String uy=req.getParameter("Ayear").trim();
SimpleDateFormat din=new SimpleDateFormat("dd-mm-yyyy");
SimpleDateFormat dout=new SimpleDateFormat("yyyy/mm/dd");
String txtDate="2001-07-07";
Date date=din.parse(txtDate);
java.sql.Date dt=new java.sql.Date(txtDate);
dout.format(dt);
String usex=req.getParameter("sex").trim();
String uemail=req.getParameter("email").trim();
String ust=req.getParameter("st").trim();
String ucty=req.getParameter("cty").trim();
ps=con.prepareStatement("insert into Userdetails values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
ps.setString(1,ulogin);
ps.setString(2,uph1);
ps.setString(3,upass);
ps.setString(4,uph2);
ps.setString(5,cpass);
ps.setString(6,uweb);
ps.setString(7,ufirst);
ps.setString(8,uaddress);
ps.setString(9,umiddle);
ps.setString(10,ucity);
ps.setString(11,ulast);
ps.setString(12,uzip);
ps.setDate(13,dt);
ps.setString(14,usex);
ps.setString(15,uemail);
ps.setString(16,ust);
ps.setString(17,ucty);
int i=ps.executeUpdate();
if(i==1)
pw.println("<h3><center> Thankyou! Your details have been stored. </center></h3>");
res.sendRedirect("http://localhost:8080/SeekLogin.html");
pw.close();
else
pw.println("<h3><center>Sorry! you are not registered properly. </center></h3>");
pw.close();
catch(Exception e)
System.out.println(e);
Can anyone look this code and help me out where i am doing the mistake.
Thanks. -
How to insert into database using jsp
sir
the code below is to enter the items in the database but it is giving the error .......of null.................
<!-- JAI SHRI RAM -->
<%@ page import="java.sql.*" %>
<html>
<head><title>JAI SHRI RAM</title></head>
<body>
<%
String url = "jdbc:odbc:lala" ;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(url,"","");
Statement st = conn.createStatement();
for(int i=1 ; i<=13 ; i++)
String skill_type = request.getParameter("skill_type"+i);
String skill_name = request.getParameter("skill_name"+i);
String version = request.getParameter("version"+i);
String lastused = request.getParameter("last_used"+i);
int last_used = Integer.parseInt(lastused);
String proficiency_level = request.getParameter("proficiency_level"+i);
String expinyears = request.getParameter("exp_in_years"+i);
int exp_in_years = Integer.parseInt(expinyears);
String expinmonths = request.getParameter("exp_in_months"+i);
int exp_in_months = Integer.parseInt(expinmonths);
String query = "insert into skills values(1 , '" + skill_type + "' , '" + skill_name + "', '" + version + "', 1 , '" + proficiency_level + "', 1 ,1)";
st.executeUpdate(query);
out.println("JAI SHRI RAM ,,,,,,,, transcation is over");
%>
</body>
</html>
i m using MS ACCESS
please tell me the problem
thank you
gauravHi,
Most probably you have problem in proper initialization of the database driver or the connection url.
In lines shown bellow
String url = "jdbc:odbc:lala" ;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(url,"","");Try to do that with more simple operations e.g. insert in a table with one field. -
Can any body help plzzzzzzzzzzzzzzzz,
I establish a connection using connection pooling as given in netbeans
helps.With that ican retrieve data from database but cant insert into it.While inserting only null values ere entered into database.why?
please somebody helpMy Jsp page userRegistration.jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@taglib prefix="c"uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<html:errors/>
<table>
<html:form action="reg.do"method="post" >
<tr>
<td>
firstname<html:text property="firstName" />
</td>
</tr>
<tr>
<td>
lastname<html:text property="lastName" />
</td>
</tr>
<tr>
<td>
username<html:text property="userName" />
</td>
</tr>
<tr><td>
email<html:text property="email" />
</td>
</tr>
<tr>
<td>
phone<html:text property="phone" />
</td>
</tr>
<tr>
<td>
fax<html:text property="fax" />
</td>
</tr>
<tr>
<td>
password<html:password property="password" />
</td>
</tr>
<tr><td>
passwordcheck<html:password property="passwordCheck" />
</td>
</tr>
<tr>
<td>
<html:submit />
</td>
<td>
<html:cancel />
</td>
</tr>
</table>
</html:form>
</body>
</html>
my struts action
package action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import javax.servlet.http.HttpSession;
public class reg extends Action {
private String firstName;
private String lastName;
private String userName;
private String email;
private String phone;
private String fax;
private String password;
private String passwordCheck;
/* forward name="success" path="" */
private final static String SUCCESS = "success";
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.sendRedirect("complete.jsp");
return mapping.findForward(getSUCCESS());
public String getFirstName() {
return firstName;
public void setFirstName(String firstName) {
this.firstName = firstName;
public String getLastName() {
return lastName;
public void setLastName(String lastName) {
this.lastName = lastName;
public String getUserName() {
return userName;
public void setUserName(String userName) {
this.userName = userName;
public String getEmail() {
return email;
public void setEmail(String email) {
this.email = email;
public String getPhone() {
return phone;
public void setPhone(String phone) {
this.phone = phone;
public String getFax() {
return fax;
public void setFax(String fax) {
this.fax = fax;
public String getPassword() {
return password;
public void setPassword(String password) {
this.password = password;
public String getPasswordCheck() {
return passwordCheck;
public void setPasswordCheck(String passwordCheck) {
this.passwordCheck = passwordCheck;
public static String getSUCCESS() {
return SUCCESS;
private javax.sql.DataSource getHima() throws javax.naming.NamingException {
javax.naming.Context c = new javax.naming.InitialContext();
return (javax.sql.DataSource) c.lookup("java:comp/env/jdbc/hima");
my complete.jsp where insertion happens
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@taglib prefix="c"uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ page import="java.sql.*" %>
String firstName=("firstName");
String lastName = getInitParameter("lastName");
String userName = getInitParameter("userName");
String email= getInitParameter("email");
String phone = getInitParameter("phone");
String fax = getInitParameter("fax");
String password = getInitParameter("password");
String passwordCheck = getInitParameter("passwordCheck");
<%
String firstName=(String)request.getAttribute("firstName");
request.getSession().setAttribute("firstName",firstName);
%>
<sql:query var="queryresults" dataSource="jdbc/hima">
select phone from user
</sql:query>
<sql:update var="resultset" dataSource="jdbc/hima">
INSERT INTO user1 (firstName,lastName,userName,email,phone,fax,password,passwordCheck)
VALUES(firstName,lastName,userName,email,phone,fax,password,passwordCheck)
</sql:update>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="comp"></form>
<h1>JSP Page</h1>
<table>
<tr>
<th>first</th>
</tr>
<c:forEach var="row" items="${queryresults.rows}">
<tr>
<td><c:out value="${row.phone}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html> -
Insert into table error - ora-01722 invalid number
Need some assistance with inserting data into a table. The date column keeps on failing to insert.
here is my insert statement
insert into tab_mod_history (TABLE_OWNER, TABLE_NAME, PARTITION_NAME, SUBPARTITION_NAME, INSERTS, UPDATES, DELETES, TIMESTAMP, TRUNCATED)
values ('$i_owner','$i_table','$i_part_name','$i_subpart_name','$i_ins','$i_upd','$i_del','$time','$trunc');Script loads data for partition tables, but not normal tables with the timestamp column
I select the data using this select statement:
select table_owner, table_name, partition_name, subpartition_name, inserts, updates, deletes, timestamp, truncated
from dba_tab_modifications
where table_owner in ('scott','MAC')
order by table_name;ok here are the errors:
values ('MAC','WC_MST','11','1','1','12/04/2011','NO','','')
ERROR at line 2:
ORA-01722: invalid number
Session altered.
values ('MAC','WF_05A','208','128','208','18/02/2011','NO','','')
ERROR at line 2:
ORA-01722: invalid numberHere is the table structure
SQL> desc tab_mod_history
Name Null? Type
TABLE_OWNER VARCHAR2(30)
TABLE_NAME VARCHAR2(30)
PARTITION_NAME VARCHAR2(30)
SUBPARTITION_NAME VARCHAR2(30)
INSERTS NUMBER
UPDATES NUMBER
DELETES NUMBER
TIMESTAMP DATE
TRUNCATED VARCHAR2(3)
DROP_SEGMENTS NUMBERI used the column names to create the variables..that is why $time was used.
How else could I have done it????
thought this was easy..but to my dismay... -
Trigger a process when a record is inserted into database
Hi, could someone tell me how to do the following (if it's possible):
when a record is inserted into a table in a database,
I want it to somehow trigger an action which will put an item into user's To-Do inBox of the WorkSpace,
the user can then open the form in the To-Do and use it to view the data in the newly inserted record.
this "user"'s login ID is part of the inserted record.
thanksMmm, trigger? I don't know of a way.
But I supposed you could have a process that has a timer that peroidically queries the database for changes and then do the same thing.
You could also perhaps write a Service and then use the Java API to start a process?
Maybe take a look here
http://blogs.adobe.com/livecycle/2010/12/how-to-invoke-a-livecycle-process-periodically.ht ml -
Hi Guy's,
Please help me, trying to insert the records into database table. when i debug the program work area contain data records but not insert into databse table. Here pasted my code pls suggest me where i did mistake.
FUNCTION ZEXM_PHOTOCOPYDTLS_EP.
""Local Interface:
*" IMPORTING
*" VALUE(EXMCODE) TYPE ZEXMCODE OPTIONAL
*" VALUE(EXMMONTH) TYPE ZEXMMONTH OPTIONAL
*" VALUE(SEATNO) TYPE ZSEATNO OPTIONAL
*" VALUE(STDFIRSTNAME) TYPE ZSTDFIRSTNAME OPTIONAL
*" VALUE(STDMIDDLENAME) TYPE ZSTDMIDDLENAME OPTIONAL
*" VALUE(STDLASTNAME) TYPE ZSTDLASTNAME OPTIONAL
*" VALUE(ADDLINE1) TYPE ZADDLINE1 OPTIONAL
*" VALUE(CITY) TYPE ZCITY OPTIONAL
*" VALUE(COUNTRY) TYPE ZCOUNTRY OPTIONAL
*" VALUE(PIN) TYPE ZPIN OPTIONAL
*" VALUE(TELEPHONENO) TYPE ZTELEPHONENO OPTIONAL
*" VALUE(MOBNO) TYPE ZMOBNO OPTIONAL
*" VALUE(EMAIL) TYPE ZEMAIL OPTIONAL
*" VALUE(DDNO) TYPE ZDDNO OPTIONAL
*" VALUE(DDAMT) TYPE ZDDAMOUNT OPTIONAL
*" VALUE(DDDATE) TYPE ZDDDATE OPTIONAL
*" VALUE(BANKNAME) TYPE ZBANKNAME OPTIONAL
*" VALUE(COLNAME) TYPE ZCOLNAME OPTIONAL
*" VALUE(COLADDRESS) TYPE ZCOLADDRESS OPTIONAL
*" VALUE(COURSECODE) TYPE ZCOURSECODE OPTIONAL
*" VALUE(EXMYEAR) TYPE ZEXMYEAR OPTIONAL
*" VALUE(PAPERCODE) TYPE ZPAPERCODE OPTIONAL
*" VALUE(PAPERNO) TYPE ZPAPERNO OPTIONAL
*" VALUE(MARKSOBT) TYPE ZMARKSOBT OPTIONAL
*" VALUE(EXMDATE) TYPE ZEXMDATE OPTIONAL
*" VALUE(EXMTIME) TYPE ZEXMTIME OPTIONAL
*" VALUE(SUBCODE) TYPE ZSUBCODE OPTIONAL
*" EXCEPTIONS
*" SELECTION_ERROR
DATA : WA_OUTPUT TYPE ZEXM_PHOTOCOPYDT,
WA_COLL TYPE ZEXM_COLLEGEMST,
WA_COURSE TYPE ZEXM_COURSEMST,
WA_EXMCODE TYPE ZEXM_EXMCODEMST,
WA_PAPER TYPE ZEXM_PHOPAPERMAP,
WA_SUBJECT TYPE ZEXM_SUBJECTMST.
STUDENT DETAILS
MOVE : EXMCODE TO WA_OUTPUT-ZEXMCODE,
EXMMONTH TO WA_OUTPUT-ZEXMMONTH,
SEATNO TO WA_OUTPUT-ZSEATNO,
STDFIRSTNAME TO WA_OUTPUT-ZSTDFIRSTNAME,
STDMIDDLENAME TO WA_OUTPUT-ZSTDMIDDLENAME,
STDLASTNAME TO WA_OUTPUT-ZSTDLASTNAME,
ADDLINE1 TO WA_OUTPUT-ZADDLINE1,
CITY TO WA_OUTPUT-ZCITY,
COUNTRY TO WA_OUTPUT-ZCOUNTRY,
PIN TO WA_OUTPUT-ZPIN,
TELEPHONENO TO WA_OUTPUT-ZTELEPHONENO,
MOBNO TO WA_OUTPUT-ZMOBNO,
EMAIL TO WA_OUTPUT-ZEMAIL,
DDNO TO WA_OUTPUT-ZDDNO,
DDAMT TO WA_OUTPUT-ZDDAMT,
DDDATE TO WA_OUTPUT-ZDDDATE,
BANKNAME TO WA_OUTPUT-ZBANKNAME.
insert into ZEXM_PHOTOCOPYDT values wa_output.
if sy-subrc = 0.
commit work.
endif.
Thanks and Regards,
Sai.
Edited by: sai shanhu on Jun 4, 2008 11:13 AMHai,
move wa_output into ZEXM_PHOTOCOPYDT.
insert ZEXM_PHOTOCOPYDT.
Thanks,
Durai.V -
Parse xml data and insert into database
Hi Friends,
I have an xml document which needs to be parsed and the data need to be inserted into an oracle database table.
Please tell me which will be the easiest and optimal way of doing this.
Thanks,
AchayanTake a look at the JDOM xml parsing library - google for JDOM download or something.
This will allow you to build an object representation of the XML doc, from which you can then extract the data.
J -
Import parametes and insert into database table suggestions
experts need suggestions
created a table with 3 fields.
zstable.
field dataelement type length
kunnr kunnr char 10 key field
name dname char 30 key field
aedat aedat dats 8
aenam aenam char 12
now i am creating a function modlue with two input parameters
1)kunnr
2)name
i want to update this two fields into table zstable.
1. so suggest me the best way to do this.
Delcarations in import options which one of the below is best and why?
name type char30
kunnr type kunnr
or
name like zstable-name
kunnr like zstable-kunnr
or
kunnr type zstable-kunnr
name type zstable-name.
2. inserting into table
the data that we recieve from the import parameters need to be inserted into the zstable.
please suggest me the appropriate statement waht i need to code for this.
insert kunnr name into zstable.
can i ignore the third field as it is not the key field?
3. before inserting do i need to check whether kunnr and uname is initial ie import parametrs?
4. suppose if i delcared two input parameters in function module zfuntion say vbeln and posnr.
and source code
insert vbeln and posnr into zstable.
now i am calling from the program
zreport.
call function 'ZFUNCTION'.
EXPORT
NAME =
KUNNR =
Will the above statement updates the blank records into the table zstable?.Hi,
1) I think the best is either refer directly to data element or to table field. This is beacuse once any change is made to this data element it will automatically reflect in your parameters. For table fields it is a bit less safier but still correct. Golden rule - always try to refer to DDIC components like data elements.
name type dname
kunnr type kunnr
2) You need to provide all key fields. I recommend to use MODIFY as it would hanlde both INSERT (if yet no such record exists ) and UPDATE (if already exists).
data: wa_zstable type zstable. "declare work area
wa_zstable-kunnr = kunnr. "pass parameters here
wa_zstable-name = name.
modify zstable from wa_zstable.
3) good practise, for this use
if kunnr is initial and
name is initial.
"modify ...
endif.
"or if parameters are set as OPTIONAL, then use
if kunnr is supplied and
name is supplied.
endif.
4) No, the statment you want to use
insert vbeln and posnr into zstable.
is only used for FIELD GROUPS, not DB table. Please refer [INSERT|http://help.sap.com/abapdocu/en/ABAPINSERT_DBTAB_SHORTREF.htm] for correct syntax.
You can alternatively use somthing like
UPDATE zstable SET vbeln = ...
posnr = ...
WHERE ...
This will update fields VBELN and PONR for all records fullfilling WHERE condition. These however musn't be key fields, only non-key fields can be udpated.
Regards
Marcin
Maybe you are looking for
-
How can I process an xml/xsl file pair that require the Internet Explorer dom?
My personal navigation device (GPS) generates xml files that contain a record of where I have been, together with when I was there, how fast I was driving at the time, etc. taken at approx. 5 second intervals. This xml file has an xml-stylesheet with
-
Hi! I´m having problems with showing video files in Qlab on my Macbook Air. It started suddenly. Consulted a sound/video technician who told me to "blow out" my Mac. Was told to use cmd+r when restarting. Is this the right way to clean up my Mac? An
-
EWT-Tax on Down Payment and Invoice
Hello, I've activated the accumulation feature in the Withholding Tax Type for both IV as well as Payments. The tax code is the same for both tax types.I've also defined the minimum base amount for Witholding Tax code as Rs.5000 for Official Withhold
-
I have a problem in the itunes
I have a problem in the itunes when i try to update any a Application Because my billing info and i try to put my security code but every time is invalid ,,, why ???
-
i just updated my ipod with color screen, and i can't connect or turn it on. it just turns on for a moment displaying an ac adapter plugging into a wall. is there anyway around this, as i cannot find my ac adapter and dont feel like dropping 20 bucks