Update Thousands of Rows in Database??
I am new to EJB. I wish to use entity bean for records in a table. But sometimes, I would update all or many records in the table in a manner like "UPDATE EMPLOYEE SET SALARY = SALARY * 1.1" in such case the SQL can be executed in the database tier. The records even does not need to load into the EJB server. So, I think entity bean approach would be much slower.
Is it a good case to apply entity bean?
i think you should worry about what kind of entity bean you need, not if you need it. Obviously you have to choose, if is a transactional multiuser system with a lot of update, insert, delete, then EJB can be a good approach, otherwise you can manage with a connection pooling directly with JDBC. In EJB case my suggestion is to use stateless SessionBean (remote or local interface depends on your requirements) then instantiate the EntityBean inside the session bean method (alias Facade Pattern) with BMP (bean managed persistence), here you'll write your query but still the container will take care of the transaction (commit or rollback). I believe can be done with CMP and EJB-QL but i am not sure, i never did before.
Ciao
Similar Messages
-
Updating Row in Database thru BMP
Hi,
I am writing session beans and BMP Entity bean to insert, Update, Delete rows into database tables.
Insert seems simple to me as I have to just call create() in Session Bean which will call ejbCreate() in BMP entity bean and a row will be inserted.
What should I do to update a row?
Or delete a row.
Thanks in advance.
RajeevHi,
Strange question... :)
Somewhere nearby ejbCraete must be ejbRemove and findByPrimayKey(...).
If seriously, every Home or LocalHome has findByPrimaryKey method that returns the "row" - remote or local object. To update it you should just call setters for fields you want to update i.e. setName(...).
As about delete, there is ejbRemove for that in bean or remove(primaryKey) in Home interface.
Hope didn't miss anything
good luck -
Updating array data in sql database
HI,
Im facing problems in updating array data in SQL database.
As of now, i am able to write an "insert" query and insert array data in an image datatype field. Im using image datatype because the array size is very big(around 80,000 x and y values).
Althoug inserting data is easy im unable to write a query to update this data.
Referring to the help of SQL server and Labview database connectivity toolkit, i came across a method of accessing image datatype....using textpointers, which are 16 bit binary values and using the WRITETEXT function instead of the UPDATE function.
but the problem im facing is that ive to pass the array as a 2d string array in the query as a result the updated array is retrieved in the form of a string a
nd not as an array. how do I get over this problem?Hi Pavitra,
I'm not very clear on how you have inserted the data into your application, but I do know that when you call the UPDATETEXT or WRITETEXT function you use the TEXTPOINTERS to point to the first location of a 1d array. So, depending on how you've stored the data, you may have problems updating your data if you're looking at it as a 1d array instead of how you originally formatted it. If you are able to successfully access the data as a 1d array, you can use the database variant to data type vi and pass in a string array constant for the data type. This will convert the variant datatype into whatever you specify. You may have to index the row and column of the variant (you receive a 2d array of variant) first before you convert. If possible, can yo
u provide some more detail and maybe some example code of how you perform the insert and plan to do the update? I can probably give you a better solution if I know how you are formatting the data. Thanks!
Jeremy L.
National Instruments
Jeremy L.
National Instruments -
Update only the row in DB where the cursor are positioned using Write Back
Hello,
I need to have the possibility to create/change values (insert or update data back into the database), dynamically or by typing, in some columns of the physical DB that are mapped in a report request, and that new or changed values could be used as a filter columns in another report request.
So, I have created a new report request in a Subject Area where a certain column of the request result could be editable to make possible change the present value and then write it back in the physical DB.
I have implemented for the column name ‘MOV_VALUE’ the value interaction type format Write Back, and every time I changed any value on this column it updates all rows with this same value from the table ‘MOVEMENTS’.
See below the Template file used in the Write Back table properties:
<?xml version="1.0" encoding="utf-8" ?>
<WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1">
<WebMessageTable lang="en-us" system="WriteBack" table="Messages">
<WebMessage name= "UpdateMovementData">
<XML>
<writeBack connectionPool="Connection Pool">
<insert> </insert>
<update> UPDATE MOVEMENTS SET MOV_VALUE=@{c4} </update>
<!-- <postUpdate>COMMIT</postUpdate> -->
</writeBack>
</XML>
</WebMessage>
</WebMessageTable>
</WebMessageTables>
Is there any possibility to only update the record from where it is the cursor positioned by using the Write Back in the Answers report?
Is necessary to create any condition to the where clause for the update statement? Which conditions?
Thanks in advance.
Regards,
Pedro ResendeYou might try posting to a BPM forum. BPM is a layered product that happens to use WL JMS, but I think most of the folks on this forum aren't familiar with BPM.
Tom -
Update A Column In A Database Table.
I am unable to update a column in a database table.
For example; I have ten records in an EMP table without having any EMPNO. I want to UPDATE (insert) 10 different EMPNO in a table. How can I do it? All I know is that there are ten records in the table; this means that I cannot use a WHERE clause with different criteria for each row.
Thanks.Try something like this
SQL> select * from emp_1
2 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
SQL> insert into emp_1(empno, ename, job, mgr, hiredate, sal, comm, deptno)
2 select null, ename, job, mgr, hiredate, sal, comm, deptno
3 from emp_1
4 where rownum <= 10
5 /
10 rows created.
SQL> select * from emp_1
2 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
SMITH CLERK 7902 17-DEC-80 800 20
ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
WARD SALESMAN 7698 22-FEB-81 1250 500 30
JONES MANAGER 7839 02-APR-81 2975 20
MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
BLAKE MANAGER 7839 01-MAY-81 2850 30
CLARK MANAGER 7839 09-JUN-81 2450 10
SCOTT ANALYST 7566 19-APR-87 3000 20
KING PRESIDENT 17-NOV-81 5000 10
TURNER SALESMAN 7698 08-SEP-81 1500 0 30
24 rows selected.
SQL> select max(empno) from emp_1
2 /
MAX(EMPNO)
7934
SQL> create sequence emp_seq start with 7935
2 /
Sequence created.
SQL> update emp_1 set empno = emp_seq.nextval where empno is null
2 /
10 rows updated.
SQL> select * from emp_1
2 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
7935 SMITH CLERK 7902 17-DEC-80 800 20
7936 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7937 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7938 JONES MANAGER 7839 02-APR-81 2975 20
7939 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7940 BLAKE MANAGER 7839 01-MAY-81 2850 30
7941 CLARK MANAGER 7839 09-JUN-81 2450 10
7942 SCOTT ANALYST 7566 19-APR-87 3000 20
7943 KING PRESIDENT 17-NOV-81 5000 10
7944 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
24 rows selected. -
Use Preparedstatement to delete several rows from database
Hello everyone,
I am trying to delete multiple rows from database at one time using Preparedstatement.
It works well when I tried in SQL directly,the sql query is as follows:
delete from planners_offices where planner ='somename' and office in ( 'officeone', 'officetwo', 'officethree')
I want to delete those 3 rows at one time.
But when I am using preparedstatement to implement this function, it does not work. It did not throw any exception, but just does not work for me, the updated rows value always returns "0".
Here is my simplified code:
PreparedStatement ps = null;
sqlStr = " delete from PLANNERS_OFFICES where planner = ? and office in (?) "
Connection con = this.getConnection(dbname);
try
//set the sql statement into the preparedstatement
ps = con.prepareStatement(sqlStr);
ps.setString(1,"somename");
ps.setString(2,"'officeone','officetwo','officethree'");
int rowsUpdated =ps.executeUpdate();
System.out.println(rowsUpdated);
//catch exception
catch (SQLException e)
System.out.println("SQL Error: " + sqlStr);
e.printStackTrace();
catch (Exception e) {
e.printStackTrace();
} finally {
this.releaseConnection(dbname, con);
try{
ps.close();
}catch (SQLException e){
e.printStackTrace();
rowsUpdated always give me "0".
I tried only delete one record at one time, "ps.setString(2, "officeone");", it works fine.
I am guessing the second value I want to bind to the preparedstatement is not right, I tried several formats of that string, it does not work either.
Can anyone give me a clue?
Thanks in advance !
Rachelthe setString function in a preparedStatement doesn't just do a replace with the question mark. It is doing some internal mumbojumbo(technical term) to assign your variable to the ?.
If you are looking to do your statement, then you will need to put in the correct of # of question marks as you need for the in clause.
delete from PLANNERS_OFFICES WHERE PLANNER = ? and office in (?,?,?)
If you need to allow for one or more parameters in your in clause, then you will need to build your SQL dynamically before creating your prepared statement.
ArrayList listOfOfficesToDelete ;
StringBuffer buffer = new StringBuffer("DELETE FROM PLANNERS_OFFICES WHERE PLANNER = ? AND OFFICE IN (");
for(int i = 0; i < listOfOfficesToDelete.size(); i++ )
if( i != 0 )
buffer.append(",");
buffer.append("?");
buffer.append(")");
cursor = conn.prepareStatement( buffer.toString() );
cursor.setString(1, plannerObj);
for(int i = 0; i < listOfOfficesToDelete().size(); i++ )
cursor.setString(i+1, listOfOfficesToDelete.get(i) );
cursor.executeUpdate() ; -
Hi all,
I'm working with an 10.2.0.3 Oracle Enterprise version.
I need to create a new user on my database with permission to update only one row on table.
Have you notice if this is possible? In case, how is the grant to do this?
Regards,
dbajugTry this:
SQL> create user usr1 identified by usr1;
User created.
SQL> create user usr2 identified by usr2;
User created.
SQL> grant connect, resource to usr1,usr2;
Grant succeeded.
SQL> conn usr1/usr1
Connected.
SQL> create table t (id number);
Table created.
SQL> insert into t values(1);
1 row created.
SQL> insert into t values(2);
1 row created.
SQL> commit;
Commit complete.
SQL> grant update on t to usr2;
Grant succeeded.
SQL> create or replace trigger trg_t
2 before update on t
3 for each row
4 begin
5 if :old.id>1 then
6 raise_application_error(-22299,'You cant change the specific value ');
7 end if;
8 end;
9 /
Trigger created.
SQL> update usr1.t set id=2 where id=1;
1 row updated.
SQL> update usr1.t set id=2 where id=2;
update usr1.t set id=2 where id=2
ERROR at line 1:
ORA-21000: error number argument to raise_application_error of -22299 is out of
range
ORA-06512: at "USR1.TRG_T", line 3
ORA-04088: error during execution of trigger 'USR1.TRG_T'
SQL> -
Results not updating for every row in BIpublisher
Hi all I have a Bi publisher report that is updating the results for the first row and in the second row to update the results it is picking the values from the first column itself and using the same values for all the other rows.
Here is my report format
Month saves Total, for 30,60,90,120
Jan
feb
Mar
Total are the enrolls by each month and days shows after 30,60,90,120 how many are still active. Following eg should give an idea of exactly whats happening
Eg:
Total 30days 60days 90days 120days 150days 180days 210days
------------------------------------------------------------------------------------------------------------------------------------------------------------ Jan saves 330 287 274 270 263 262 259 257
Feb saves 298 255 242 238 231 230 227 225
Mar saves 291 248 235 231 224 223 220 218
So what is happening is lets say for example there are a total of 330 enrolls in january and after 30days 287 are still active and after 60days 274 are still active after 90 270...... etc
Am getting the January active values correctly.
BUt going forward when I see the values for february The total enrolls for february is 298 and after 30 days which are active is not giving me the correct.
It is substracting the same amount as jan. looking at the numbers it is substracting
-43, -13,-4,-7,-1,-3,-2 for Jan which are the cancels after the consecutive days
It is substracting the same amount for feb also but my actual cancels for feb are different it should be 45,12,8,9,2,2,
It is doing the same for all the months.
There should be a change in the code. Following is the XSL code am using in
<?xdoxslt:set_variable($_XDOCTX, 'v_SavesCanceled', SAVES_CANCELED_COUNT)?>
<?xdoxslt:set_variable($_XDOCTX, 'v_RtSaves', xdoxslt:get_variable($_XDOCTX, 'v_RtSaves') - xdoxslt:get_variable($_XDOCTX, 'v_SavesCanceled'))?>
<?xdoxslt:get_variable($_XDOCTX, 'v_RtSaves')?>
Actually the cancels should be updated for each row but its picking the same cancels for every month.
Hope it is clear let me know if you need any further info
Any help is appreciated.
ThanksThank you very much for your help. The rtf file sent worked and updating results as required.Thank you
Thanks -
HOW TO DELETE THE ROW FROM DATABASE
hI,
Iam pasting my code below.My problem isi retrieve rows from database and display them in jsp page in rows.For each row there is delete hyperlink.Now when i click that link i should only delete the row corresponding to that delete link temporarily but it should not delete the row from database now.It should only delete the row from database when i click the save button.How can i do this can any one give some code.
thanks
naveen
[email protected]
<%@ page language="java" import="Utils.*,java.sql.*,SQLCon.ConnectionPool,java.util.Vector,java.util.StringTokenizer" %>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Item Details</title>
<script>
function submitPage()
document.details.action = "itemdetails.jsp" ;
document.details.submit();
</script>
</head>
<body>
<form name="details" action="itemdetails.jsp" method="post">
<%
ConnectionPool pool;
Connection con = null;
Statement st;
ResultSet rs =null;
%>
<table border="0" cellpadding="0" cellspacing="0" width="328">
<tr>
<td width="323" colspan="4"><b>Reference No :</b> <input type="text" name="txt_refno" size="14">
<input type="submit" value="search" name="search" ></td>
</tr>
<tr>
<td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Item Code</b></font></td>
<td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Item No</b></font></td>
<td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Amount </b></font></td>
<td width="80" bgcolor="#000099"> </td>
</tr>
<%
pool= new ConnectionPool();
Utils utils = new Utils();
double total =0.00;
String search =utils.returnString(request.getParameter("search"));
if(search.equals("search"))
try
String ref_no =utils.returnString(request.getParameter("txt_refno"));
String strSQL="select * from ref_table where refno='" + ref_no + "' ";
con = pool.getConnection();
st=con.createStatement();
rs = st.executeQuery(strSQL);
while(rs.next())
String itemcode=rs.getString(2);
int item_no=rs.getInt(3);
double amount= rs.getDouble(4);
total= total + amount;
%>
<tr>
<td width="81"><input type=hidden name=hitem value=<%=itemcode%>><%=itemcode%></td>
<td width="81"><input type=hidden name=hitemno value=<%=item_no%>><%=item_no%></td>
<td width="81"><input type=hidden name=hamount value=<%=amount%>><%=amount%></td>
<td width="80"><a href="delete</td>
</tr>
<%
}catch(Exception e){}
finally {
if (con != null) pool.returnConnection(con);
%>
<tr>
<td width="323" colspan="4">
<p align="right"><b>Total:</b><input type="text" name="txt_total" size="10" value="<%=total%>"></td>
</tr>
<tr>
<td width="323" colspan="4">
<input type="button" value="save" name="save"></td>
</tr>
</table>
</form>
</body>
</html>You mean when you click on the hyperlink you want that row to disappear from the page, but not delete the row from the database until a commit/submit button is pressed?
Personally, I think I'd prefer that you have a delete checkbox next to every row and NOT remove them from the display if I was a user. You give your users a chance to change their mind about their choice, and when they're done they can see exactly which rows will be deleted before they commit.
You know your problem, of course, so you might have a good reason for designing it this way. But I'd prefer not removing them from the display. JMO - MOD -
Flex updates at a row level in a grid
I needs to updates row level in a grid for frequent basis, Also i don't want to Refresh the Grid.
Is there any method i can use ?
Using flex Grid -> updates at a row level in a gridI mean DataGrid. I am trying to change the data rows based on realtime data feed.
First time i'll add all the Employees in the Grid. Later i'll get indivual request will change only Status column.
Is there is any other way i can update with out refresh in datagrid.
<mx:DataGrid
id="dg" height="260" width="900" x="0" y="20">
<mx:columns>
<mx:DataGridColumn headerText="EmpID" dataField="EmpID" width="10" visible="false"/>
<mx:DataGridColumn headerText="Emp Name" dataField="Emp Name" width="110"/>
<mx:DataGridColumn headerText="Status" dataField="Status" width="80"/>
</mx:columns>
</mx:DataGrid> -
How to update a single row of data table
How we can update a single row of the data table by clicking the button in the same row.
Thanks in Advance.Hi!
What do You mean 'update'? Get fresh data from DB or change data and commit it in DB?
If commit, try to read here:
http://developers.sun.com/jscreator/learning/tutorials/2/inserts_updates_deletes.html
Thanks,
Roman. -
Hi experts,
I still cant figure out how oracle handles multiple updates to the same row. For instance I have 3 update statements:
update supplier set supp_type = 'k' where supp_code = '1';
update supplier set supp_type = 'j' where supp_code = '1';
update supplier set supp_type = 'm' where supp_code = '1';
I keep getting the final result to be supp_type = 'k' where it should actually be 'm', but when i execute the mapping it shows 3 update operations, which baffled me as to how oracle handles simultaneous updates to same row. I even tried disabling parallel dml on the table object, but am unsure whether this actually helps. I try putting a sorter operator and then a key lookup operator after the sorter operator in my mapping to compare the supp_code field in the sorter with the target table's supp_code field to retrieve the relevant row to update, but instead of 3 update operations, it now updates all supp_type in all my records to NULL. Can anyone explain to me how i should go about dealing with this?Hi experts,
I just took a look at the code section generated for the key lookup operator named SUPPLIER_WH_SURRKEY01 and I feel something is wrong with the generated code. I have pasted the code section on the key lookup operator below.
ORDER BY
"SUPPLIER_CV"."RSID$" ASC ) *"SORTER" ON ( ( ( "SUPPLIER_WH_SURRKEY01"."EXPIRATION_DATE" = "SPIDERWEB2"."GET_EXPIRATI_0_EXPIRATI" ) ) AND ( ( "SUPPLIER_WH_SURRKEY01"."SUPPCODE" = "SORTER"."SUPP_CODE$1" ) ) )*
WHERE
( ( "SUPPLIER_WH_SURRKEY01"."SUPPKEY" IS NULL ) OR ( "SUPPLIER_WH_SURRKEY01"."SUPPKEY" = "SUPPLIER_WH_SURRKEY01"."SUPPKEY" ) );
Can anyone explain to me the codes in bold? I have no clue as to what it means? Furthermore, those bold-ed codes look similar to what I have expected to find in the where clause, except that instead of SUPPLIER_WH_SURRKEY01"."EXPIRATION_DATE" = "SPIDERWEB2"."GET_EXPIRATI_0_EXPIRATI", I expected to find
SUPPLIER_WH_SURRKEY01"."EXPIRATION_DATE" = '31-dec-4000', because my key lookup operator checks upon a constant with the value '31-dec-4000'. And the constant name is CONSTANT itself, while my mapping's name is SPIDERWEB2(not too sure why the generated code refers to my mapping name instead of my constant)
Edited by: user8915380 on 17-Mar-2010 00:52 -
How to update field values in a database table using module pool prg?
hi
how to update field values in a database table using module pool prg?
we created a customized table, and we put 2 push buttons in screen painter update and display.
but update is not working?
data is enter into screen fields and to internal table, but it is not updated in database table.
thanks in adv
vidyaHI,
we already used the update statement. but its not working.
plz check this.
*& Module Pool ZCUST_CALL_REC
PROGRAM ZCUST_CALL_REC.
TABLES: ZCUST_CALL_REC,ZREMARKS.
data: v_kun_low like ZCUST_CALL_REC-kunnr ,
v_kun_high like ZCUST_CALL_REC-kunnr,
v_bud_low like ZCUST_CALL_REC-budat,
v_bud_high like ZCUST_CALL_REC-budat.
ranges r_kunnr for ZCUST_CALL_REC-kunnr .
ranges r_budat for zcust_call_rec-budat.
DATA: ITAB TYPE STANDARD TABLE OF ZCUST_CALL_REC WITH HEADER LINE,
JTAB TYPE STANDARD TABLE OF ZREMARKS WITH HEADER LINE.
*data:begin of itab occurs 0,
MANDT LIKE ZCUST_CALL_REC-MANDT,
kunnr like ZCUST_CALL_REC-kunnr,
budat like ZCUST_CALL_REC-budat,
code like ZCUST_CALL_REC-code,
remarks like ZCUST_CALL_REC-remarks,
end of itab.
*data:begin of Jtab occurs 0,
MANDT LIKE ZCUST_CALL_REC-MANDT,
kunnr like ZCUST_CALL_REC-kunnr,
budat like ZCUST_CALL_REC-budat,
code like ZCUST_CALL_REC-code,
remarks like ZCUST_CALL_REC-remarks,
end of Jtab.
CONTROLS:vcontrol TYPE TABLEVIEW USING SCREEN '9001'.
CONTROLS:vcontrol1 TYPE TABLEVIEW USING SCREEN '9002'.
*start-of-selection.
*& Module USER_COMMAND_9000 INPUT
text
MODULE USER_COMMAND_9000 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
WHEN 'ENQUIRY'.
perform multiple_selection.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9001'.
WHEN 'UPDATE'.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9002'.
perform update on commit.
WHEN 'DELETE'.
perform append_CUSTOMER_code.
PERFORM SELECT_DATA.
call screen '9002'.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
*& Module STATUS_9000 OUTPUT
text
MODULE STATUS_9000 OUTPUT.
SET PF-STATUS 'ZCUSTOMER'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_9000 OUTPUT
*& Module USER_COMMAND_9001 INPUT
text
MODULE USER_COMMAND_9001 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
endcase.
ENDMODULE. " USER_COMMAND_9001 INPUT
*& Module STATUS_9001 OUTPUT
text
MODULE STATUS_9001 OUTPUT.
SET PF-STATUS 'ZCUSTOMER'.
SET TITLEBAR 'xxx'.
move itab-MANDT to zcust_call_rec-MANDT.
move itab-kunnr to zcust_call_rec-kunnr.
move itab-budat to zcust_call_rec-budat.
move itab-code to zcust_call_rec-code.
move itab-remarks to zcust_call_rec-remarks.
vcontrol-lines = sy-dbcnt.
ENDMODULE. " STATUS_9001 OUTPUT
*& Module USER_COMMAND_9002 INPUT
text
module USER_COMMAND_9002 input.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR sy-ucomm.
WHEN 'UPDATE'.
perform move_data.
UPDATE ZCUST_CALL_REC FROM TABLE ITAB.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'RECORDS ARE UPDATED'.
ELSE.
MESSAGE E001(0) WITH 'RECORDS ARE NOT UPDATED'.
ENDIF.
WHEN 'DELETE'.
perform move_data.
DELETE ZCUST_CALL_REC FROM TABLE ITAB.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'RECORDS ARE DELETED'.
ELSE.
MESSAGE E001(0) WITH 'RECORDS ARE NOT DELETED'.
ENDIF.
endcase.
endmodule. " USER_COMMAND_9002 INPUT
*& Module STATUS_9002 OUTPUT
text
module STATUS_9002 output.
SET PF-STATUS 'ZCUSTOMER1'.
SET TITLEBAR 'xxx'.
endmodule. " STATUS_9002 OUTPUT
*& Module update_table OUTPUT
text
module update_table output.
move itab-MANDT to zcust_call_rec-MANDT.
move itab-kunnr to zcust_call_rec-kunnr.
move itab-budat to zcust_call_rec-budat.
move itab-code to zcust_call_rec-code.
move itab-remarks to zcust_call_rec-remarks.
vcontrol-lines = sy-dbcnt.
endmodule. " update_table OUTPUT
***Selection Data
FORM SELECT_DATA.
SELECT mandt kunnr budat code remarks FROM zcust_call_rec INTO
table itab
WHERE kunnr IN r_kunnr AND BUDAT IN R_BUDAT.
ENDFORM.
****append vendor code
FORM APPEND_CUSTOMER_CODE.
clear r_kunnr.
clear itab.
clear r_budat.
refresh r_kunnr.
refresh itab.
refresh r_kunnr.
IF r_kunnr IS INITIAL
AND NOT v_kun_low IS INITIAL
AND NOT v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_high
IMPORTING
OUTPUT = r_kunnr-high.
r_kunnr-option = 'BT'.
r_kunnr-sign = 'I'.
append r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND NOT v_kun_low IS INITIAL
AND v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
r_kunnr-SIGN = 'I'.
r_kunnr-OPTION = 'EQ'.
APPEND r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND v_kun_low IS INITIAL
AND NOT v_kun_high IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_kun_low
IMPORTING
OUTPUT = r_kunnr-low.
r_kunnr-SIGN = 'I'.
r_kunnr-OPTION = 'EQ'.
APPEND r_kunnr.
PERFORM V_BUDAT.
ELSEIF r_kunnr IS INITIAL
AND v_kun_low IS INITIAL
AND v_kun_high IS INITIAL.
IF SY-SUBRC = 0.
MESSAGE I003(0) WITH 'ENTER CUSTOMER NUMBER'.
CALL SCREEN '9000'.
ENDIF.
PERFORM V_BUDAT.
ENDIF.
ENDFORM.
FORM V_BUDAT.
IF R_BUDAT IS INITIAL
AND NOT v_BUD_low IS INITIAL
AND NOT v_BUD_high IS INITIAL.
r_budat-low = v_bud_low.
r_budat-high = v_bud_high.
r_budat-option = 'BT'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND NOT v_BUD_low IS INITIAL
AND v_BUD_high IS INITIAL.
r_budat-low = v_bud_low.
r_budat-high = v_bud_high.
r_budat-option = 'EQ'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND v_BUD_low IS INITIAL
AND NOT v_BUD_high IS INITIAL.
r_budat-HIGH = v_bud_HIGH.
r_budat-option = 'EQ'.
r_budat-sign = 'I'.
append r_budat.
ELSEIF R_BUDAT IS INITIAL
AND v_BUD_low IS INITIAL
AND v_BUD_high IS INITIAL.
IF SY-SUBRC = 0.
MESSAGE I002(0) WITH 'ENTER POSTING DATE'.
CALL SCREEN '9000'.
r_budat-low = ''.
r_budat-option = ''.
r_budat-sign = ''.
ENDIF.
ENDIF.
ENDFORM.
*& Form update
text
--> p1 text
<-- p2 text
form update .
commit work.
endform. " update
*& Form move_data
text
--> p1 text
<-- p2 text
form move_data .
clear itab.
refresh itab.
move-corresponding zcust_call_rec to itab.
MOVE ZCUST_CALL_REC-MANDT TO ITAB-MANDT.
MOVE ZCUST_CALL_REC-KUNNR TO ITAB-KUNNR.
MOVE ZCUST_CALL_REC-BUDAT TO ITAB-BUDAT.
MOVE ZCUST_CALL_REC-CODE TO ITAB-CODE.
MOVE ZCUST_CALL_REC-REMARKS TO ITAB-REMARKS.
APPEND ITAB.
delete itab where kunnr is initial.
endform. " move_data
thanks in adv
vidya -
What's the best way to insert/update thousands records in multiple tables
Can anyone give an example of how to insert/update thousands records in multiple tables on performance wise? or what should I do to improve the performance?
Thanks
jimYou can see a set of sample applications in various scenarious available at
http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/content.html -
Problem: trying to update all detail rows on pre-commit (MASTER DETAIL FORM
Hi:
I got a MASTER DETAIL form... and I need to update every detail row of this form (if the master was updated) before commiting the changes. the problem is that i cannot do that for instance in PRE-COMMIT or ON-COMMIT... it's an "illegal operation". I achieved part of it by coding KEY-COMMIT... but that did not solve the all problem. first take a look of the kind of code i want execute before commiting.
form trigger key-commit code is is somehow like this:
DECLARE
tot_line NUMBER (3);
line NUMBER (3);
begin
IF NAME_IN ('system.form_status') = 'CHANGED'
THEN
GO_BLOCK ('DETAIL');
LAST_RECORD;
tot_line := GET_BLOCK_PROPERTY ('DETAIL', current_record);
FIRST_RECORD;
line:= 1;
LOOP
:detail.quant := :detail.quant + 1;
EXIT WHEN line= tot_line;
next_record;
line:= line+ 1;
END LOOP;
FIRST_RECORD;
GO_BLOCK ('MASTER');
END IF;
COMMIT;
end;
The problem is for instance when the users close form in the "X" button (right top, near minimize form) ... If they do that Forms ask "Do you want to save changes?" ... and with this i do not execute the update of the detail rows...
But there are other situations when this happens... for instance if EXECUTE_QUERY when i change a record...
Anyone help?
Joao OliveiraUse PRE-UPDATE trigger (Master block).
begin
update <detail_table>
set quant + 1
where <detail_table>.<relaition_column1> = :<Master_block>.<relaition_item1>
and <detail_table>.<relaition_columnN> = :<Master_block>.<relaition_itemN>
and <detail_block_WHERE>;
EXCEPTION WHEN OTHERS THEN NULL;
end;
Maybe you are looking for
-
Blue screen on restart after 10.4 install
i have an ibook and tried to upgrade to 10.4 from 10.2.8. after having to try twice to install 10.4 (i kept getting the "try again" error message), it worked. but on restart, after the grey "OS X" screen, it goes to a blue screen and just sits there
-
Error 0xc000007b when starting After Effects or Indesign
On my Samsung Laptop (Windows Home Premium 64 bit) I get error 0xc000007b when I try to start After Effects or Indesign. Please advise me.
-
Report Standard for Compensation Management in MSS
Good night, There are is a report standard for Compensation Management in MSS? Kind Regards, sanew2
-
Downloaded ios8 to ipad mini and know I do not see my camera icon
DDownloaded ios8 to iPad mini and now i do not see my camera icon
-
i have installed Remove Duplicate Contacts, events and Reminders v6.4 trying to remove the 14,000 contacts duplicates. i did not do a back up and i would like to know if it is possible to retrieve my contacts in icloud before i removed/the duplicate