INSERT into database Keyword
Hi Guys,
If I use the INSERT keyword to add new entries to a database table, will it append to the existing entries, or will it overwrite the existing entries...
I need it only to append, so if it does overwrite, which keywork can i use?
tks
C
Points will be awarded
hi,
INSERT command is used to APPEND the values .
for EXAMPLE :
Data: Begin of line,
col1 type I,
col2 type I,
End of line.
Data itab like line occurs 10.
Do 2 times.
Line-col1 = sy-index.
Line-col2 = sy-index ** 2.
Append line to itab.
Enddo
Line-col1 = 11.
Line-col2 = 22.
Insert line into itab index 2.
Insert initial line into itab index 1.
Loop at itab into line.
Write: / sy-tabix, Line-col1, Line-col2.
Endloop.
EXPLANATION :
Let us consider the example. Here the internal table ITAB is defined to have the structure of line and does not have a Header line.
In the DO LOOP, the columns of the structure are assigned the values of SY-INDEX and its square. SY-INDEX is another system variable which has the value of the loop iteration. At the end of the loop the table ITAB will have following contents:
1 1
2 4
Next we are trying to insert the line with values 11 and 22 at index 2.
1 1
11 22
2 4
The next line inserts an initial line at index 1. So, the table contents now become
0 0
1 1
11 22
2 4
Similar Messages
-
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 -
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 -
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 -
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. -
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 -
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. -
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());
} -
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 -
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> -
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 -
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();}
}%>
ThanksLooks 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 = ? -
Program to upload csv file to internal table and insert into database table
Hi I'm writing a program where I need to upload a csv file into an internal table using gui_upload, but i also need this program to insert the data into my custom database table using the split command. Anybody have any samples to help, its urgent!
Hi,
Check this table may be it will give u an hint...
REPORT z_table_upload LINE-SIZE 255.
Data
DATA: it_dd03p TYPE TABLE OF dd03p,
is_dd03p TYPE dd03p.
DATA: it_rdata TYPE TABLE OF text1024,
is_rdata TYPE text1024.
DATA: it_fields TYPE TABLE OF fieldname.
DATA: it_file TYPE REF TO data,
is_file TYPE REF TO data.
DATA: w_error TYPE text132.
Macros
DEFINE write_error.
concatenate 'Error: table'
p_table
&1
&2
into w_error
separated by space.
condense w_error.
write: / w_error.
stop.
END-OF-DEFINITION.
Field symbols
FIELD-SYMBOLS: <table> TYPE STANDARD TABLE,
<data> TYPE ANY,
<fs> TYPE ANY.
Selection screen
SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
PARAMETERS: p_file TYPE localfile DEFAULT 'C:\temp\' OBLIGATORY,
p_separ TYPE c DEFAULT ';' OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK b01.
SELECTION-SCREEN: BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.
PARAMETERS: p_table TYPE tabname OBLIGATORY
MEMORY ID dtb
MATCHCODE OBJECT dd_dbtb_16.
SELECTION-SCREEN: END OF BLOCK b02.
SELECTION-SCREEN: BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
PARAMETERS: p_create TYPE c AS CHECKBOX.
SELECTION-SCREEN: END OF BLOCK b03,
SKIP.
SELECTION-SCREEN: BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
PARAMETERS: p_nodb RADIOBUTTON GROUP g1 DEFAULT 'X'
USER-COMMAND rg1,
p_save RADIOBUTTON GROUP g1,
p_dele RADIOBUTTON GROUP g1.
SELECTION-SCREEN: SKIP.
PARAMETERS: p_test TYPE c AS CHECKBOX,
p_list TYPE c AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN: END OF BLOCK b04.
At selection screen
AT SELECTION-SCREEN.
IF sy-ucomm = 'RG1'.
IF p_nodb IS INITIAL.
p_test = 'X'.
ENDIF.
ENDIF.
At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
Start of selection
START-OF-SELECTION.
PERFORM f_table_definition USING p_table.
PERFORM f_upload_data USING p_file.
PERFORM f_prepare_table USING p_table.
PERFORM f_process_data.
IF p_nodb IS INITIAL.
PERFORM f_modify_table.
ENDIF.
IF p_list = 'X'.
PERFORM f_list_records.
ENDIF.
End of selection
END-OF-SELECTION.
FORM f_table_definition *
--> VALUE(IN_TABLE) *
FORM f_table_definition USING value(in_table).
DATA: l_tname TYPE tabname,
l_state TYPE ddgotstate,
l_dd02v TYPE dd02v.
l_tname = in_table.
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
name = l_tname
IMPORTING
gotstate = l_state
dd02v_wa = l_dd02v
TABLES
dd03p_tab = it_dd03p
EXCEPTIONS
illegal_input = 1
OTHERS = 2.
IF l_state NE 'A'.
write_error 'does not exist or is not active' space.
ENDIF.
IF l_dd02v-tabclass NE 'TRANSP' AND
l_dd02v-tabclass NE 'CLUSTER'.
write_error 'is type' l_dd02v-tabclass.
ENDIF.
ENDFORM.
FORM f_prepare_table *
--> VALUE(IN_TABLE) *
FORM f_prepare_table USING value(in_table).
DATA: l_tname TYPE tabname,
lt_ftab TYPE lvc_t_fcat.
l_tname = in_table.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = l_tname
CHANGING
ct_fieldcat = lt_ftab
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
WRITE: / 'Error while building field catalog'.
STOP.
ENDIF.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_ftab
IMPORTING
ep_table = it_file.
ASSIGN it_file->* TO <table>.
CREATE DATA is_file LIKE LINE OF <table>.
ASSIGN is_file->* TO <data>.
ENDFORM.
FORM f_upload_data *
--> VALUE(IN_FILE) *
FORM f_upload_data USING value(in_file).
DATA: l_file TYPE string,
l_ltext TYPE string.
DATA: l_lengt TYPE i,
l_field TYPE fieldname.
DATA: l_missk TYPE c.
l_file = in_file.
l_lengt = strlen( in_file ).
FORMAT INTENSIFIED ON.
WRITE: / 'Reading file', in_file(l_lengt).
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
filetype = 'ASC'
TABLES
data_tab = it_rdata
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
WRITE: /3 'Error uploading', l_file.
STOP.
ENDIF.
File not empty
DESCRIBE TABLE it_rdata LINES sy-tmaxl.
IF sy-tmaxl = 0.
WRITE: /3 'File', l_file, 'is empty'.
STOP.
ELSE.
WRITE: '-', sy-tmaxl, 'rows read'.
ENDIF.
File header on first row
READ TABLE it_rdata INTO is_rdata INDEX 1.
l_ltext = is_rdata.
WHILE l_ltext CS p_separ.
SPLIT l_ltext AT p_separ INTO l_field l_ltext.
APPEND l_field TO it_fields.
ENDWHILE.
IF sy-subrc = 0.
l_field = l_ltext.
APPEND l_field TO it_fields.
ENDIF.
Check all key fields are present
SKIP.
FORMAT RESET.
FORMAT COLOR COL_HEADING.
WRITE: /3 'Key fields'.
FORMAT RESET.
LOOP AT it_dd03p INTO is_dd03p WHERE NOT keyflag IS initial.
WRITE: /3 is_dd03p-fieldname.
READ TABLE it_fields WITH KEY table_line = is_dd03p-fieldname
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
FORMAT COLOR COL_POSITIVE.
WRITE: 'ok'.
FORMAT RESET.
ELSEIF is_dd03p-datatype NE 'CLNT'.
FORMAT COLOR COL_NEGATIVE.
WRITE: 'error'.
FORMAT RESET.
l_missk = 'X'.
ENDIF.
ENDLOOP.
Log other fields
SKIP.
FORMAT COLOR COL_HEADING.
WRITE: /3 'Other fields'.
FORMAT RESET.
LOOP AT it_dd03p INTO is_dd03p WHERE keyflag IS initial.
WRITE: /3 is_dd03p-fieldname.
READ TABLE it_fields WITH KEY table_line = is_dd03p-fieldname
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
WRITE: 'X'.
ENDIF.
ENDLOOP.
Missing key field
IF l_missk = 'X'.
SKIP.
WRITE: /3 'Missing key fields - no further processing'.
STOP.
ENDIF.
ENDFORM.
FORM f_process_data *
FORM f_process_data.
DATA: l_ltext TYPE string,
l_stext TYPE text40,
l_field TYPE fieldname,
l_datat TYPE c.
LOOP AT it_rdata INTO is_rdata FROM 2.
l_ltext = is_rdata.
LOOP AT it_fields INTO l_field.
ASSIGN COMPONENT l_field OF STRUCTURE <data> TO <fs>.
IF sy-subrc = 0.
Field value comes from file, determine conversion
DESCRIBE FIELD <fs> TYPE l_datat.
CASE l_datat.
WHEN 'N'.
SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
WRITE l_stext TO <fs> RIGHT-JUSTIFIED.
OVERLAY <fs> WITH '0000000000000000'. "max 16
WHEN 'P'.
SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
TRANSLATE l_stext USING ',.'.
<fs> = l_stext.
WHEN 'F'.
SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
TRANSLATE l_stext USING ',.'.
<fs> = l_stext.
WHEN 'D'.
SPLIT l_ltext AT p_separ INTO l_stext l_ltext.
TRANSLATE l_stext USING '/.-.'.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = l_stext
IMPORTING
date_internal = <fs>
EXCEPTIONS
OTHERS = 1.
WHEN 'T'.
CALL FUNCTION 'CONVERT_TIME_INPUT'
EXPORTING
input = l_stext
IMPORTING
output = <fs>
EXCEPTIONS
OTHERS = 1.
WHEN OTHERS.
SPLIT l_ltext AT p_separ INTO <fs> l_ltext.
ENDCASE.
ELSE.
SHIFT l_ltext UP TO p_separ.
SHIFT l_ltext.
ENDIF.
ENDLOOP.
IF NOT <data> IS INITIAL.
LOOP AT it_dd03p INTO is_dd03p WHERE datatype = 'CLNT'.
This field is mandant
ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
TO <fs>.
<fs> = sy-mandt.
ENDLOOP.
IF p_create = 'X'.
IF is_dd03p-rollname = 'ERDAT'.
ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
TO <fs>.
<fs> = sy-datum.
ENDIF.
IF is_dd03p-rollname = 'ERZET'.
ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
TO <fs>.
<fs> = sy-uzeit.
ENDIF.
IF is_dd03p-rollname = 'ERNAM'.
ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
TO <fs>.
<fs> = sy-uname.
ENDIF.
ENDIF.
IF is_dd03p-rollname = 'AEDAT'.
ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
TO <fs>.
<fs> = sy-datum.
ENDIF.
IF is_dd03p-rollname = 'AETIM'.
ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
TO <fs>.
<fs> = sy-uzeit.
ENDIF.
IF is_dd03p-rollname = 'AENAM'.
ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data>
TO <fs>.
<fs> = sy-uname.
ENDIF.
APPEND <data> TO <table>.
ENDIF.
ENDLOOP.
ENDFORM.
FORM f_modify_table *
FORM f_modify_table.
SKIP.
IF p_save = 'X'.
MODIFY (p_table) FROM TABLE <table>.
ELSEIF p_dele = 'X'.
DELETE (p_table) FROM TABLE <table>.
ELSE.
EXIT.
ENDIF.
IF sy-subrc EQ 0.
FORMAT COLOR COL_POSITIVE.
IF p_save = 'X'.
WRITE: /3 'Modify table OK'.
ELSE.
WRITE: /3 'Delete table OK'.
ENDIF.
FORMAT RESET.
IF p_test IS INITIAL.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
WRITE: '- test only, no update'.
ENDIF.
ELSE.
FORMAT COLOR COL_NEGATIVE.
WRITE: /3 'Error while modifying table'.
FORMAT RESET.
ENDIF.
ENDFORM.
FORM f_list_records *
FORM f_list_records.
DATA: l_tleng TYPE i,
l_lasti TYPE i,
l_offst TYPE i.
Output width
l_tleng = 1.
LOOP AT it_dd03p INTO is_dd03p.
l_tleng = l_tleng + is_dd03p-outputlen.
IF l_tleng LT sy-linsz.
l_lasti = sy-tabix.
l_tleng = l_tleng + 1.
ELSE.
l_tleng = l_tleng - is_dd03p-outputlen.
EXIT.
ENDIF.
ENDLOOP.
Output header
SKIP.
FORMAT COLOR COL_HEADING.
WRITE: /3 'Contents'.
FORMAT RESET.
ULINE AT /3(l_tleng).
Output records
LOOP AT <table> ASSIGNING <data>.
LOOP AT it_dd03p INTO is_dd03p FROM 1 TO l_lasti.
IF is_dd03p-position = 1.
WRITE: /3 sy-vline.
l_offst = 3.
ENDIF.
ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>.
l_offst = l_offst + 1.
IF is_dd03p-decimals LE 2.
WRITE: AT l_offst <fs>.
ELSE.
WRITE: AT l_offst <fs> DECIMALS 3.
ENDIF.
l_offst = l_offst + is_dd03p-outputlen.
WRITE: AT l_offst sy-vline.
ENDLOOP.
ENDLOOP.
Ouptut end
ULINE AT /3(l_tleng).
ENDFORM.
Regards,
Joy.
Maybe you are looking for
-
Error while saving the excel file
hai all, i had an requirement to upload customer master data through lsmw while saving the data in excel file with extension as) text( tab delimeted)(.txt) it is not saving and displaying the message as " the selected file type doesnot support workbo
-
Logical Column for calculation
Hi guru, My requirement is we have to display report with Total count of Opportunities , Count new Oppty ( which are created with in 30days from today ) Count Old Opptys ( which are created more than 30days ago and Overdue ( which closed date is > cu
-
Can I replace my HDD with a 'Ext. 250gb - Smartdisk Crossfire' HDD?
cause I think the ext. AC power is shot, only the green light is blinking rapid very faint. So, I was wondering if its was possible and wise to replace my powerbooks 80gb HDD with the 250gb HDD in the external? could it hurt to see if it works or....
-
15 inch Retina Macbook Pro making an annoying whining sound
My 15 inch Retina Macbook Pro suddenly began making a loud whining sound. I have been working her hard recently, but even when I let her rest the sound continues. It seems to be coming from the upper left conner of the machine near the W key. Any sug
-
Importing .emlx files back into mail....please help
Hi, I am running the most current version of Tiger and Mail. A few months ago, I accidentally deleted an account on mail. This deleted all my emails from the inbox having to do with that account. The other day, I bought File Salvage and salvaged a bu