Updating JDBC By Row Number
Hi
I’m new to the sun forums and fairly new to java.
I understand how to update tables in a database when specifying a value for one of the fields
stmt.executeUpdate("update Table set Status=’x’ where Name='y'");
Instead of specifying the ‘Name’ as ‘y’ I want to specify a row number from a table the fields are being loaded into.
Can anyone help me?
Thank you.
T_J_M wrote:
Hi
I’m new to the sun forums and fairly new to java.
I understand how to update tables in a database when specifying a value for one of the fields
stmt.executeUpdate("update Table set Status=’x’ where Name='y'");Instead of specifying the ‘Name’ as ‘y’ I want to specify a row number from a table the fields are being loaded into.
Can anyone help me?
Thank you.Generally speaking you cannot do this but even if you could you still shouldn't. Because the order is not guaranteed. That's why we have ORDER BY clauses because there is no guarantee in SQL that if you query a table with a,b,c SELECT that it will come back as a,b,c both times. It is acceptable to come back a,b,c and then c,a,b
What are you trying to accomplish exactly?
Similar Messages
-
Word Links not updating when row number changes in excel
Hi,
I have a huge excel file with employee name,code,dob etc as fields.I linked it to word documents using paste special and macros.Everything works fine and word also updates with changes in excel file, but problem arises when in excel , data is added in the
middle rather than at the end of the file. This changes the row numbers of all the employees.Hence when I open corresponding word document, some one else's details open. So now i have to edit links in word...office->prepare->edit links, Here i
have an option called ITEM IN FILES... this is where the problem occurs...It requires mentioning the row no of the corresponding pasted link...but when i change data in excel and row no changes...this should be automatically detected by Word and row number
should be updated there.Please help me find a way to resolve this.This is what it looks like....
Data for VC!R1C2:R2C13
I want R1 and R2 to change automatically if I change rows in excel file.
Thank youInstead of specifying a cell range in the LINK field, name the range in Excel, then use the range name in the LINK field.
For example, instead of:
VC!R1C2:R2C13
you might have:
VC!MyRange
in Word.
That way, the LINK will point to the named range, regardless of how many rows and/or columns are added/deleted before it. Furthermore, if you expand or contract the range (e.g. by adding/deleting columns between the first & last column), the
named range and, hence the linked range, will likewise expand/contract.
Cheers
Paul Edstein
[MS MVP - Word] -
Updating the particular row and column in a JTable
Hi,
I have a JTable which is having fixed number of columns. When i am trying to update a particular cell in the table
during programm execution i am not able to do it.
I am getting the row number and column number correctly. But when i am going to set the data it is not setting at the same row. It is setting some other row according to the m_index (according to the sorting).
i am doing :
JTableModel model = (JTableModel) m_TablePan.getTableModel();
model.setValueAt(savedData, row, column);See the convertXxxIndexToView and convertXxxIndexToModel methods.
db
Edited by: Darryl.Burke -- wrong methods suggested
Edit2: Evidently lipumama doesn't follow up on many questions posted.
One for the blacklist. -
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; -
How can I get the row number of display automatically on a table?
I have a table of measurements, and I would like the row number to be displayed on each row. The challenge is that each time I run the program, the total number of rows will be different, so I would like the numbers to update every time I run the program based on the current number of rows.
I have attached a picture to illustrate what I am trying to do.
Solved!
Go to Solution.
Attachments:
picture of table.JPG 70 KBFind the attached example (saved in version 2009), and you can extract what you need for your code...!!
I am not allergic to Kudos, in fact I love Kudos.
Make your LabVIEW experience more CONVENIENT.
Attachments:
Example (Enter Row Header).vi 12 KB -
Hi list,
does any one know how I can get the row number the same as what I have in column rowno?
thanks
Arvin
REATE TABLE dbo.temptable
( y int NOT NULL,
e int not null,
c int not null,
rowno int not null)
/* insert values */
INSERT INTO dbo.temptable(y,e,c,rowno ) VALUES
(1,1,1,1),
(1,1,2,1),
(1,1,3,1),
(1,20,1,2),
(1,20,2,2),
(1,20,3,2),
(1,3,1,3),
(1,3,1,3),
(2,1,1,1),
(2,1,1,1),
(2,2,1,2),
(2,2,1,2);You may update your rownumber column with Column "e".
But why do you duplicate your data? May be there is no particular reason, you may be wasting space for it
Try the below:
CREATE TABLE dbo.temptable
( y int NOT NULL,
e int not null,
c int not null,
ronum int null)
INSERT INTO dbo.temptable(y,e,c ) VALUES
(1,1,1),
(1,1,2),
(1,1,3),
(1,20,1),
(1,20,2)
select * from temptable
update dbo.temptable Set ronum=e
Select * From dbo.temptable
DRop table dbo.temptable -
How to update the restricted rows that were selcted using fetch
Hi
I have to fetch one row at a time from my staging table using JDBC Sender Adapter, which is configured against AS400 DB2 and push it to R/3.
The select SQL looks like this in JDBC Sender Adapter
<b>select jedata, oxruns from fxjrnep2 where oxsts=' ' fetch first 1 rows only</b>
and
update sql is
<b>update suplib.FXJRNEP2 set OXSTS='SUC' where OXSTS=' ' </b>
The problem here is my select gets one row, which is what i want, but my update actually updates all the rows that satisfied the where condition oxsts=' ' instead of one.
I couldn't use <b>fetch first 1 rows only</b> at the end of the update sql to update the selected row. DB2 does not allow fetch in update sql.
Can anyone suggest solution here or recommend alternative?
Best Regards
Venkatcheck for update query where u can club the select stmt u had used with udpate like:
update suplib.FXJRNEP2 set OXSTS='SUC' where OXSTS = (select jedata, oxruns from fxjrnep2 where oxsts=' ' fetch first 1 rows only
just need to try combinations of this type.
if still this is not working use a bpm and get all the records where OXSTS is null and process record one by one within a block -
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> -
Show APEX Row Number in Report Region
I would like to display the row number in the report region at the beginning of each row for each page (based on the number of rows to display per page).
So if the number of rows per page is 15, I would want to show each row from 1 to 15. When going to the next page (16 - 31) I would like to show row 1 to 15 again next to each row.
And if the number of rows per page is 20, I want to see row numbers 1 to 20 on each page.
Since I believe an Update button only processes the current page, I would like to then use this row numbers (1 - 15) to get the values of the displayed column for each row to perform an insert to another table.You can use something like this:
SELECT apex_item.text (1, '#ROWNUM#') row_num, empno, ename,
deptno, comm, sal, mgr
FROM empExample is here:
http://apex.oracle.com/pls/apex/f?p=31517:284
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.apress.com/9781430235125
http://apex.oracle.com/pls/apex/f?p=31517:1
http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
------------------------------------------------------------------- -
Cursor only updates every second row
Hello Helpful Peoples
I have a table with a set of delivery dates, and am wanting to add a date on which a reminder flag should be raised by the system. The delivery dates are already populated and I'm wanting to add functionality where the end user can set how many days prior they are reminded.
I've opened a cursor to retrieve all the current due dates from my source table. When I loop through this cursor and update the reminder date and reminder text, my code is only updating every second row.
I can't work out why this code seems to skip a row every time it updates a record. Is anyone able to assist?
declare
v_date rep_delivery.reminderdate%type;
v_rownum number;
CURSOR reminder_cur
IS
SELECT DEL.DUEDATE
FROM REP_DELIVERY DEL
WHERE DEL.REP_ID = :P212_REP_ID:
FOR UPDATE OF DEL.REMINDERDATE;
begin
FOR x IN reminder_cur LOOP
FETCH reminder_cur INTO v_date;
EXIT WHEN reminder_cur%NOTFOUND;
v_date := v_date - to_number(:P212_REMDAYS);
UPDATE REP_DELIVERY DEL2
SET DEL2.REMINDERDATE = v_date
WHERE CURRENT OF reminder_cur;
UPDATE REP_DELIVERY DEL3
SET DEL3.REMINDERTEXT = :P212_DESCRIPTION
WHERE CURRENT OF reminder_cur;
END LOOP;
commit;
end;Oolite,
Use this code:
DECLARE
v_date rep_delivery.reminderdate%TYPE;
CURSOR reminder_cur
IS
SELECT ROWID, duedate
FROM rep_delivery
WHERE rep_id = :p212_rep_id
FOR UPDATE OF reminderdate;
BEGIN
FOR x IN reminder_cur
LOOP
v_date := x.duedate;
v_date := v_date - TO_NUMBER (:p212_remdays);
UPDATE rep_delivery del2
SET del2.reminderdate = v_date,
del2.remindertext = :p212_description
WHERE ROWID = x.ROWID;
END LOOP;
COMMIT;
END;and it will work for you.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://htmldb.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
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 get row number in the fetch row itself in Sql Query ?
Hi,
i am fetching some rows from a sql query . Is there any way to get row number as well in each row while all rows are fetched ?
like this :
RowNum data1 data2
1 abc ere
2 bnh ioiHello
Ofcourse you can get the rownum inside a query, just keep in mind that the rownum is the number of order in which the records were fetched from the table, so if you do an order by, the rownum will not be sequential, unless you query the information in a subquery first.
SELECT rown, col1, col1
FROM table
Or
SELECT rownum, col1, col2
FROM (SELECT col_1, col_2 FROM table ORDER BY col1)
Regards
Johan -
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> -
Find row number of first cell in a relative range that is less than $B$3
Thanks for any help. I've spent hours searching, trying, and reading iWork Help
Example: $B$3 = 3
Column C
1: 9
2: 2
3: 9
4: 2
5: 3
6: 9
7: 9
Find the first occurrence that is less than $B$3 (=3) in the range C3:C6. Return the row # (relative to the range, or actual row number, I don't care)
Fill Down the formula, so the next cell looks at the range C4:C7
In this case, I want it to return Row 4 (not 5 or 2)
Tried this with MATCH (last argument -1 or 1) which almost works, but if it finds an exact match, it returns that row (5) instead of the first one (4)The single formula in D2, filled down that column, returns the row number of every row where the value in column C is less than or equal to the value in $B$3.
The second formula, which I placed in B4, but which can go wherever it's needed, searches a limited range of column D for the minimum value in that range.
In the example, based on your initial question, the range is three cells. In B4, it's D2:D4; in B5 it's D3:D5, etc., with Numbers automatically adjusting the cell references as the formula is filled down the column. In each case, the formula returns the minimum value it finds in the three cell range, which is the row number on which the value in column C first meets the condition (less than or equal to $B$3) within that three cell range.
In the second example, the formula retrieves the same value (the row number) as above, but instead of displaying it, uses it as the row-offset value in an OFFSET statement to return the Date from the row where the row number was collected.
NOTE: Looking back at it, I see that in my rush to other duties I made an error in this formula, setting the row offset too high. Revise the formula as shown below to get the date from the correct row:
Existing: =IF(MAX(D2:D4)=0,"",OFFSET($A$1,MIN(D2:D4),0))
Revised: =IF(MAX(D2:D4)=0,"",OFFSET($A$1,MIN(D2:D4)-1,0))
You wrote:
If I'm following the logic, it would require one column (like D in this example) for every set of rows searched (in my example, B5:B15 filled down, so the next search is B6:B16 and so on).
No. Provided the values of X and Y are constant for each set of searches, you'll need an auxiliary column for each column of values to be searched. One auxiliary column is used to mark the rows in which the value in B meets the condition ">x", the second to mark the rows where the value in C meets the condition "<y".
The search formula (above) searches a subset of its column and returns the lowest row number where the condition for that column is met,and either displays that number or uses it to return and display a date.
Regards,
Barry -
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.
Maybe you are looking for
-
Problem with the FOR statement.....again!
Hi everyone, Well I'm still trying to do a car slideshow using external files and can't seem to see the end. The current movie is here: http://www.virtuallglab.com/projects.html I also attach the code. My problem is I had originally set up an animati
-
How do You Transfer iTunes from One Log-in to another Log-in on the SAME computer with SAME account?
-
Hi My printer is complaining that my justified text makes it look like there is no space after a full stop. In some cases, it does appear this way. Is there any way to set a minimum or uniform amount of space after each full stop, within justified te
-
Idoc type used for an output type
Hi experts, How do I find the Idoc structure used by an output type. When i look in nace it only shows the program name as RSNASTED and form routine as EDI_PROCESSING. Thanks, Raghu.
-
HT4009 Didn't receive my in app purchase. How do I get it.
Paid for an in app purchase but I didn't get it. Any ideas.