JTable woes (JDK 1.5): Sorting and updating data
So I've been working on this project for a while here that is essentially the front-end to a database system. The data itself is displayed in a JTable derivative. Column 1 is a JComboBox containing a list of companies, Column 2 is a JComboBox containing a list of employees, and the rest of the columns contain information specific to that employee.
The data for each row is actually contained within a custom TableRowData object, which is used to assign listeners and such:
private void initComponents() {
this.organizations.setSelectedEnum(this.data.getOrganizationNumber());
organizations.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if("comboBoxChanged".equals(e.getActionCommand())) {
clearData();
try {
updateEmployees();
fireRowDataChanged();
} catch (SQLException ex) {
Logger.getLogger(VenosTeammateRow.class.getName()).log(Level.SEVERE, null, ex);
pocs.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if("comboBoxChanged".equals(e.getActionCommand())) {
try {
data = getEmployeeInformation();
fireRowDataChanged();
} catch (SQLException ex) {
Logger.getLogger(VenosTeammateRow.class.getName()).log(Level.SEVERE, null, ex);
}Ideally, I would like a change in Column 1 to load the employees for the selected company into Column 2. This is working as expected.
I would also like a change in Column 2 to load the information specific to the selected employee into the rest of the columns. This is also working as expected.
The problem I am having arises when the data is sorted and THEN a change is made to either column.
To sort, I am using a custom comparator that keeps track of the sort direction and current sort column.
In the JTable derivative class, I have a method, sortByColumn(int col):
public void sortByColumn(int col) {
this.getColumnModel().getColumn(col).getCellEditor().cancelCellEditing();
if(this.getSelectedRow() > 0 && this.getSelectedRow() < this.getRowCount())
this.removeRowSelectionInterval(this.getSelectedRow(), this.getSelectedRow());
DefaultTableModel mdl = (DefaultTableModel)this.getModel();
comp.setSortColumn(col);
Collections.sort(mdl.getDataVector(), comp);
// Declare and initialize the header
JTableHeader header = this.getTableHeader();
// Reset all headers to their identifier values
for(int i = 0; i < mdl.getColumnCount(); i++) {
String identifier = header.getColumnModel().getColumn(i).getIdentifier().toString();
header.getColumnModel().getColumn(i).setHeaderValue(identifier);
// Find the sort order (for the sorting indicator)
int sortOrder = comp.getSortOrder(col);
// Store the identifier text temporarily
String headerText = header.getColumnModel().getColumn(col).getIdentifier().toString();
// Declare and initialize the sort indicator based on the sort order
String sortIndicator;
switch(sortOrder) {
case TableRowComparator.ASCENDING:
sortIndicator = " \u2191";
break;
case TableRowComparator.DECENDING:
sortIndicator = " \u2193";
break;
case TableRowComparator.UNSORTED:
sortIndicator = "";
break;
default:
sortIndicator = " \u2193";
break;
/* Set the Header to display the text with the indicator. Since
* this will automatically set the Identifier to the same value,
* reset it to the value we stored previously.
header.getColumnModel().getColumn(col).setHeaderValue(headerText+sortIndicator);
header.getColumnModel().getColumn(col).setIdentifier(headerText);
// Make sure all the changes are painted
header.repaint();
this.repaint();
}After the sort, the rows are updated and displayed correctly. However, for example with three rows, if by sorting row 1 and row 3 swap, changing the JComboBox in row 3 also updates the data in row 1.
I'll be converting my code into a short self-contained program momentarily to post on here for a better understanding of what's going on. However, I decided I would post this just in case there were something painfully obvious I missed.
Thanks.
Thanks, you've been really helpful :) However, I realized while trying to copy my code to a smaller, self-contained form to illustrate my problems... I never changed the row number in my TableDataRow! So of course the update information, which was relying on the row number stored in the TableDataRow object (and not the actual row number in the model's data vector) updated according to the old row numbers.
Basically, I coded myself into a corner :P
Fixed it by making a new comparator to compare TableDataRow objects, and I stored an array of those objects in my custom table model. So the hard work is done on the TableDataRow objects, the data vector is cleared, and then each TableDataRow is added back as a vector.
Not sure if this is the most elegant solution, but... it works.
Edited by: GranoblasticMan on Oct 21, 2008 1:11 PM
Similar Messages
-
Process Chain : Read PSA and Update Data Target in BI 7.0
Hello Experts,
In my Process Chain I have a variant Execute Infopackage to load the data only into PSA. then I have next variant as *Read PSA and Update Data Target*. my data target was a Master Data table Hierarchy
In the variant " Read PSA and Update Data Target". the selection Parameters were
PSA.Table : 0GLACCEXT_T011_HIER_BA1
Selection Object Type : same Infopackage in Varaint Execute Infopackage
the Error message was Variant doesnot contain a valid combination request/data target
I checked the PSA-Table using RSA1OLD Transaction then I find four PSA Tables:
0GLACCEXT_T011_HIER_BA1
0GLACCEXT_T011_HIER_BA2
0GLACCEXT_T011_HIER_BA3
0GLACCEXT_T011_HIER_BA4
All the requests are linked to PSA Table *0GLACCEXT_T011_HIER_BA4*.
I can't understand why there exists four PSA Tables?
I try to link the PSA-table 0GLACCEXT_T011_HIER_BA4 in the variant *Read PSA and Update Data Target and try to save it it raises short dump.
If I select 0GLACCEXT_T011_HIER_BA1 in the varaint I shouldn't face any problems.?
but the process chain raises an Error message Variant doesnot contain a valid combination request/data target with this variant.
How shall I handle this issue?
Please carify me the issues as soon as possible.
thanks in advance
Regards
sailekhaHello,
In the Variant Read PSA and Update Data Target I have to select the PSA Tabelle Name from the preselection list in the System it shows me all the four PSA Tables that I mentioned.
I can select any one of them. So I trieed with all the four PSA Tables in the list but I can selct only the XXXX......BA1 table then only I can save and include it in the PC. If I select the remaining tables BA2, BA3, BA4.........while I try to save the Variant it raises short dump.
I checked the PSA using the Transaction RSA1OLD under PSA...... I find 4 PSA Tables( I don't know whether they are PSA Tables or not but in the Variant it states that they are PSA Tables) in which all the requests are attached to BA4. only.
I observed that ony for Hierarchies I find four PSA tables for remaining one only one PSA table was available.
I totally confused how to handle this situation. any suggestions......... please help me to resolve this problem.
Thanks & Regards -
How to get new and updated data into LO Excel in Xcelsius
Dear Experts,
I have created dashboard on top of webi report by using Live-Office connection. Latest data of webi report is imported into excel and mapped data with components and generated SWF file and exported into server.
To day my webi report has latest instance with new and updated data. But until unless by clicking "Refresh All Objects" i am not getting updated data into excel.
When i am trying to open dashboard in BI Launch Pad/CMC it is showing data whatever exist in excel(i.e yesterday data). But here we need to show data of latest instance of webi report.(i.e New and updated data as of now).
I have selected option "Latest instance: From latest instance scheduled by" in "refresh options".
My Question & Doubts:
1) Is it mandatory to open dashboard every day and need to click on "Refresh All Objects" to get updated data into excel or dashboard.
2) Is there any option to automate this process.
Regards,
PRK.Hi,
Schedule the webi report to get the latest data from the source. To answer your query no is doesn't require to open the dashboard every time to refresh the excel to get the latest data.
Please use the Refresh Before Components are Loaded: Select this option to refresh the data each time the model loads and to use that data as the initial data for the model (using a Reset Button component, it will reset the data to the values from the last time the model was loaded).
You are using the Live Office so here automatic refresh is not possible without touch the swf file, you need to use the refresh but to get the latest data. If you are using QAAWS, Web Service & XML then automatic refresh is possible.
For more information please check the below document for in-depth idea on the design pattern.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b02e31fb-3568-2e10-e78f-92412c3c0a96?overridelayout=t…
Kindly revert for more clarification!!!
--SumanT -
Hi
how to create a external content type for Read and Update data from two tables in sqlserver using sharepoint designer 2010
i created a bcs service using centraladministration site
i have two tables in sqlserver
1)Employee
-empno
-firstname
-lastname
2)EmpDepartment
-empno
-deptno
-location
i want to just create a list to display employee details from two tables
empid firstname deptno location
and same time update in two tables
adilWhen I try to create an external content type based on a view (AdventureWorks2012.vSalesPerson) - I can display the data in an external list. When I attempt to edit it, I get an error:
External List fails when attached to a SQL view
Sorry, something went wrong
Failed to update a list item for this external list based on the Entity (External Content Type) 'SalesForce' in EntityNamespace 'http://xxxxxxxx'. Details: The query against the database caused an error.
I can edit the view in SQL Manager, so it seems strange that it fails.
Any advice would be greatly GREATLY appreciated.
Thanks,
Randy -
Connecting to datasource and retrieve, insert and update data in SQL Server
hi,
i am trying to retrieve, insert and update data from SQL Server 2000 and display in JSPDynPage and is for Portal Application. I have already created datasource in visual composer. Is there any sample codes for mi to use it as reference???
Thanks
Regards,
shixuanHi,
See this link
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6209b52e-0401-0010-6a9f-d40ec3a09424
Regards,
Senthil kumar K. -
Connecting to datasource and retrieve, insert and update data
hi,
i am doing a JSP page that need to retrieve data and display on textView, insert data and update data. I have already create a datasource in Visual Composer. Does anyone have a sample codes for mi to use it as reference. So that i can connect to the datasource tat i created in Visual composer and retrieve, insert and update data. thanz
Regards,
shixuanHi,
After creating a data source in Visual composer .
you have to create a BI system that Visual Composer can use in
the SAP NetWeaver Portal.
refer this pdf file for further Info
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6209b52e-0401-0010-6a9f-d40ec3a09424
Regards,
Beevin -
Finding Plant Creation and Updation Date
Hi all,
I just want to find out if it is possible to find out Plant Creation and Updation Date using ABAP statements. Does it get stored in CHDHR or CDPOS and if yes, then what is the object Key.
ThanksCheck Report RSVTPROT with table name T001W for Plant changes. I do not think it updated CDHDR.
You can SUBMIT this report and get back the list in your custom program.
How to get list back in your custom program refer
http://scn.sap.com/thread/3147016 -
BW 3.5 - Update to PSA only / Read PSA and Update Data Target
Hi Folks,
I am planning to use on a BW 3.5 data source and infopackage that loads to PSA only (as the source system job runs quite long and we would run other prepration loads in parallel before pushed to final cube). And then later in the process chain the process Read PSA and Update Data Target to load the data to final cube.
As we plan to run the process chain 3 times a day I was wondering if the Read PSA and Update Data Target always takes only the latest request loaded to the PSA (as it is always the same infopackage) or do we have to delete the PSA request at the end of each process chain run so that not the next run will load the PSA request again as it is still in the PSA?
Thanks for all replies in advance,
AxelYou are loading the Delta till the PSA, multiple times a day, and after each update to the PSA you will send the data to the Cube.
Once its there in the PSA, you are performing further tasks & then updating the cube multiple times (once after each delta)
Well, the 1st load to the cube should be OK.
But, from the next load onwards, it would pick up all the requests from the PSA & you will have wrong values in the Cube.
Because, i think, while using 'Read PSA & Update the Target', you can't set it for a FULL or a DELTA load.
It will bring in everything that exists in the PSA.
I would advice you to clean the PSA before the starting next Delta.
But, there is a counter argument.
If the data mart sign is reflected in the PSA for the request that has been loaded into the cube, then the next time the system will pick up the request which does not have a data mart symbol.
You can always give this a try in your Dev system.
Edited by: Vishal Sanghvi on Apr 1, 2011 1:58 PM -
How to trigger pop-up window in report and update data base from report
Hi All,
I have a requirement, in a report output list to trigger a pop up window with some rejection codes corresponding to each sales order when i select from the output list. Also i need to update data base by selecting one of the rejection code in the pop-up window list for that sales order. Can any one please let me know how to achive this.
Also, i have check boxes for each record in the output list. Also, i have added one more check box as "Select All'. When select 'Sleect All' check box , all check boxes need to be checked, how to achieve this. PLease let me know.
Thanks in advance.
Regards,
RajeshHi check this code of editable ALV report... I updated the data base with the changes made..in the editable ALV
*& Report ZJAY_EDIT_ALV
REPORT zjay_edit_alv.
* TYPE-POOLS *
TYPE-POOLS: slis.
* INTERNAL TABLES/WORK AREAS/VARIABLES
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
w_field TYPE slis_fieldcat_alv,
p_table LIKE dd02l-tabname,
dy_table TYPE REF TO data,
dy_tab TYPE REF TO data,
dy_line TYPE REF TO data.
* FIELD-SYMBOLS *
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa> TYPE ANY,
<dyn_field> TYPE ANY,
<dyn_tab_temp> TYPE STANDARD TABLE.
* SELECTION SCREEN *
PARAMETERS: tabname(30) TYPE c DEFAULT 'MARA',
lines(5) TYPE n DEFAULT 7.
* START-OF-SELECTION *
START-OF-SELECTION.
* Storing table name
p_table = tabname.
* Create internal table dynamically with the stucture of table name
* entered in the selection screen
CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_table->* TO <dyn_table>.
IF sy-subrc <> 0.
MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.
LEAVE TO LIST-PROCESSING.
ENDIF.
* Create workarea for the table
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
* Create another temp. table
CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_tab->* TO <dyn_tab_temp>.
SORT i_fieldcat BY col_pos.
* Select data from table
SELECT * FROM (p_table)
INTO TABLE <dyn_table>
UP TO lines ROWS.
REFRESH <dyn_tab_temp>.
* Display report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*& Form SET_PF_STATUS
* Setting custom PF-Status
* -->RT_EXTAB Excluding table
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTANDARD'. "copy it from SALV func group standard
ENDFORM. "SET_PF_STATUS
*& Form user_command
* Handling custom function codes
* -->R_UCOMM Function code value
* -->RS_SELFIELD Info. of cursor position in ALV
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Local data declaration
DATA: li_tab TYPE REF TO data,
l_line TYPE REF TO data.
* Local field-symbols
FIELD-SYMBOLS:<l_tab> TYPE table,
<l_wa> TYPE ANY.
* Create table
CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN li_tab->* TO <l_tab>.
* Create workarea
CREATE DATA l_line LIKE LINE OF <l_tab>.
ASSIGN l_line->* TO <l_wa>.
CASE r_ucomm.
* When a record is selected
WHEN '&IC1'.
* Read the selected record
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
rs_selfield-tabindex.
IF sy-subrc = 0.
* Store the record in an internal table
APPEND <dyn_wa> TO <l_tab>.
* Fetch the field catalog info
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = p_table
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.
* Make all the fields input enabled except key fields
w_field-input = 'X'.
MODIFY i_fieldcat FROM w_field TRANSPORTING input
WHERE key IS INITIAL.
ENDIF.
* Display the record for editing purpose
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
it_fieldcat = i_fieldcat
i_screen_start_column = 10
i_screen_start_line = 15
i_screen_end_column = 200
i_screen_end_line = 20
TABLES
t_outtab = <l_tab>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc = 0.
* Read the modified data
READ TABLE <l_tab> INDEX 1 INTO <l_wa>.
* If the record is changed then track its index no.
* and populate it in an internal table for future
* action
IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
<dyn_wa> = <l_wa>.
i_index = rs_selfield-tabindex.
APPEND i_index.
ENDIF.
ENDIF.
ENDIF.
* When save button is pressed
WHEN 'SAVE'.
* Sort the index table
SORT i_index.
* Delete all duplicate records
DELETE ADJACENT DUPLICATES FROM i_index.
LOOP AT i_index.
* Find out the changes in the internal table
* and populate these changes in another internal table
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
IF sy-subrc = 0.
APPEND <dyn_wa> TO <dyn_tab_temp>.
ENDIF.
ENDLOOP.
* Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc = 0.
* Modify the database table with these changes
MODIFY (p_table) FROM TABLE <dyn_tab_temp>.
REFRESH <dyn_tab_temp>.
* Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table.
ENDIF.
ENDCASE.
rs_selfield-refresh = 'X'.
ENDFORM. "user_command -
Urgent please: Master-Deatils OAF Page for enter and Update data
Hi all,
i need your help to build master-details oaf page for Enter / Update data
for example: We have Locations , Department , Employees tables
all these tables on one oaf page (OAAdvancedTable)
when user enter New Location and go to Enter it's Departments and for each department, he can Enter they employees.
and Regarding to Update date:
- when user select Location , Department table fetch all departments and user can update
waiting your support for urgent please
Regards
Hanyi do these Steps :
1- Create LocationEO,DepartmentEO and EmployeesEO
2- Create Association between LocationEO and DepartmentEO with one-to-Many relation (LocToDeptAO)
3- Create Association between DepartmentEO and EmployeesEO with one-to-Many relation (DeptToEmpAO)
4- Create View Object (LocationVO)
5- Create DepartmentVO (and add LocationEO due to LocToDeptAO)
6- Create EmployeesVO (and add DepartmentEO due to DeptToEmpAO)
7- Creare View Link between LocationVO and DepartmentVO (Based On LocToDeptAO) --> LocToDeptVL
8- Creare View Link between DepartmentVO and EmployeesVO (Based On DeptToEmpAO)---> DeptToEmpVL
9- Add LocaionVO to Application Module, then add DepartmentVO Via (LocToDeptVL)
10-Add EmployeesVO to Application Module Via (DeptToEmpVL)
and Then Run Test AM, all data fetch sucessfully, and i can insert data with proper relations
NOw, i want to implement this Business Logic in single oaf Page using 3 OAAdvancedTable (Master - Details -Details )
Regards -
Using eclipse Web services to retrieve and update data to Oracle DB
Hi,
Can I have a sample about to use eclipse to retrieve/update data from Oracle DB by using axis web services?
thank youHi,
If you have a sheet in Excel with data from a SharePoint Online list you can switch to the PowerPivot ribbon and ask to add it to the model. This will allow you to reference this table when you create a PowerView report.
This workbook, with the Odata feed can then be refreshed via the scheduled refresh feature of Power BI Site.
Insert the data using the Odata feed
The Odata URL will be something like:
https://MyCompany.sharepoint.com/MySite/MySubSite/_vti_bin/listdata.svc/MyList
If you are not sure what is the list name, you can drop just browse to
https://MyCompany.sharepoint.com/MySite/MySubSite/_vti_bin/listdata.svc and this will provide a list of all the lists in that site/sub-site.
Once you have those in the model and you setup scheduled refresh, it will refresh the lists directly from SPO (using the owner identity)
Hope this helps.
Guy
GALROY -
Sorting and Updating my own music
I organize my own music on my hard drive by Genre, and make playlists from the folders.
However, I sometimes download mp3s onto my hard drive from places like NRK Urørt. But I'm constantly having to re-import my folders to get them recognized by iTunes.
Is there way to get iTunes to automatically update every time I put new music in a folder, or just update every so often?It doesn't break apart (into folders) CDs that have multiple artists on them, doesn't recognize some artists, and breaks up CDs that shouldn't be broken up
You can do most anything in iTunes. What are you doing "special" that you need to access the folders directly instead of thru iTunes? I'm not saying you can't or shouldn't but what's the benefit?
#2, it makes it hard to export music. If I want to bring all of my Classical music to work with me on my external drive, iTunes is no help for me.
Select the music and drag it to external drive, new folder, pen drive, whatever.
#3, it makes it a pain to delete stuff. If I want to delete a song I don't like, I then have to go and delete the folder that iTunes made for it too.
Select the song or artist or album and press Delete. This deletes it from the library and then iTunes asks if you want to delete from the hard drive. -
JTable problem when deleting all rows and reinserting data,
Hi,
I have a JTable with an AbstractModelTable.
Some cells in the JTable have a custom cell editor. I am using
the cell editor that accepts only numeric values as explained in
the JTable tutorial (WholeNumberField).
- The JTable gets filled by choosing a value from a JList
for example:
1- choose a customer name from the customer JList
2- gets the customer order (database)
3- fills the Jtable with the customer data.
- When a customer is chosen from the Jlist I call a function
inside my table model. (This function removes all rows, clears the vector holding the data and calls fireTableRowsDeleted (firstRow, lastRow));
- Then I fill up the new data for this customer.
All of this works fine, except if I have entered a new value inside
one of the cell that has a customed cellEditor (ex: the Ordered column).
for example : user enters number 20 in the "ordered" column for customer A. Then changes his mind and chooses customer B from the JList. So the JTable gets cleared and refilled with the data of Customer B but the column "ordered" still has the value '20'
I would really appreciate any help...
ThanksDon't know is this will work, but try the following before updating the table:
if (table.isEditing())
table.removeEditor();Also, why do two TableModelEvent's..one for all getting deleted, one for the new filling. You could do one fireTableDataChanged after the new data is in. -
Copying and updating Data from a table to new table using Merge command
Hi ,
Can anyone please tell me how to do this?
I have a table : EMP(empno(pk),ename,sal,dept) another table is EMP_CLASS(empno(pk),ename)
I want to insert corresponding rows from emp to emp_class table if that row does'nt exist in emp_class
otherwise it will update corrsponding info in emp_class table as well as delete from emp_class according to emp delete operation.
Thanks ,
Deekay.
Edited by: Deekay on Aug 12, 2010 10:59 PMHi Vishu,
This is really helpful, but I want little modification like it will check for deptno in emp and insert in class field if dept is 10 then 1 ,20 ,2 like wise. I have changed emp_class structure .Please find my updated code eaccording to that ,but I am getting error.
MERGE
INTO emp_class
USING emp
ON (emp.empno = emp_class.empno)
WHEN MATCHED
THEN
UPDATE
SET emp_class.ename = emp.calss_name,
emp_class.deptno = emp.deptno,
emp_class.class=select decode(deptno,10,1,20,2,30,3,40,4)from emp
DELETE
WHERE emp_class.empno = emp.empno
WHEN NOT MATCHED
THEN
INSERT (emp_class.empno,emp_class.name,emp_class.deptno,emp_class.class)
VALUES (emp.empno,emp.name,emp.sal,emp.deptno,decode(deptno,10,1,20,2,30,3,40,4)emp.class);
Please help me to fix this.
this is the error:
MERGE
INTO emp_class
USING emp
ON (emp.empno = emp_class.empno)
WHEN MATCHED
THEN
UPDATE
SET emp_class.ename = emp.calss_name,
emp_class.deptno = emp.deptno,
emp_class.class=select decode(deptno,10,1,20,2,30,3,40,4)from emp
DELETE
WHERE emp_class.empno = emp.empno
WHEN NOT MATCHED
THEN
INSERT (emp_class.empno,emp_class.name,emp_class.deptno,emp_class.class)
VALUES (emp.empno,emp.name,emp.sal,emp.deptno,decode(deptno,10,1,20,2,30,3,40,4)emp.class); -
Issue while insert and update data to DB tables
Hello all,
i am having an issue while insert the data to DB table.
my scenario is DB1 to DB2. i had a sender channel with select query which fetches data from DB1 and inserts to DB2.
so the select query will fetch the records that were INSERTED to DB1 and records that were UPDATED to DB1 and needs to insert/update to DB2 table.
Now the issue is i am able to insert the records but not able toupdate the records to DB2 table due to primary key issue.
im message mapping
sender message type is as follows:
<src_message1>
----<row>
-------<fieldA>
-------<filedB>
-------<filedC>
Receiver message type as follows:
<trgt_message1>
----<STATEMENT_1>
----<TABLE_NAME>
----<ACTION> INSERT
----<TABLE>
----<ACCESS>
----<field1> primary key
----<field2>
----<field3>
----<field4>
----<KEY>
----<field1>
----<field2>
----<field3>
----<field4>
my query in sender channel is : select filedA, filedB, filedC from test_table where createdate=sysdate or updatedate=sysdate
so it feteches the data from DB1 and inserting to DB2 but not updating the records to DB2 due to primarykey issue.
please suggest how to solve ....will it solve by using UPDATE_INSERT for action?
Best Regards,SARANHi Nagarjuna,
i have done the following changes to target mapping structure;
1. action as UPDATE_INSERT
2. in access tab, i had mapped fieldDate to field4.
3. in Key tab, i assigned the sysdate to field4.
but issue still exist. could you please check my above changes are correct or not. if wrong please provide me the details that needs to be done.
thanks in advance.
i'm providing the error details again:
my query in sender channel is : select filedA, filedB, filedC, FiledDate from TEST_TABLE where fieldDate=sysdate or updatedate=sysdate
it returns 4 records as follows:
fieldA--fieldB-fieldC---fieldDate
1001----EU---- 1----
2011-11-10
1002----CN---- 0----
2011-11-10
1003----AP---- 1----
2008-03-15 (already exist in DB2)
1004----JP---- 1----
2007-04-12 (already exist in DB2)
the first two records are created today and remaining 2 records are updated the fieldC from 0 to 1 ( in DB1 )
while inserting these 4 records to DB2, we get the following error "java.sql.SQLException: ORA-00001: unique constraint (data.TEST_TABLE_PK) violated" .
Best Regards,SARAN
Maybe you are looking for
-
I'm working through my CCIE Voice/Collaboration training materials and am just about finished with the physical construction of the lab. At this time I'm just going to install a new T1 card into my BR1 router and I'm trying to get my T1 to HQ (HQ ro
-
[solved] firefox crashing
Can someone try "ispreview" from firefox please? As soon as I get to this page it terminates instantly - no attempt to display [paul@night ~]$ firefox http://www.ispreview.co.uk The program 'Gecko' received an X Window System error. This probably ref
-
Open a pdf file with Acrobat Reader/Pro from a https site using ie
Hi! I somehow don't manage to open a pdf file directly with Acrobat Reader/Pro when trying to open it from a https site and using ie8. With http sites everything works just fine. Are there any settings to enable this with https sites? Greetings Laura
-
How can I direct audio out from quicktime to my receiver instead of the speakerphone?
I get voicemails from my office phone through email via active sync. I want to listen to them privately. Thanks
-
Formula for Balance...
Hello, In my Query last colum calculation follows- Example: Debit amt ** Credit amt ** Balance amt. 100 ** 200 ** 200 = -100 200 ** 300 ** 100-300=-200