Helps with the UPDATE statement
HelloI have a table like this:
create table test
(id number,
stat number,
id_num number);
data in the table:insert into table test (id,stat,id_num) values (1,112,'');
insert into table test (id,stat,id_num) values (1,123,'');
insert into table test (id,stat,id_num) values (2,134,'');
insert into table test (id,stat,id_num) values (2,111,'');
insert into table test (id,stat,id_num) values (3,112,'');
insert into table test (id,stat,id_num) values (4,111,'');
insert into table test (id,stat,id_num) values (4,12,'');
insert into table test (id,stat,id_num) values (4,11,'');
I want to update the column id_num with serial number under the same ID.Below is the table with coloumn successfully updated.
insert into table test (id,stat,id_num) values (1,112,1);
insert into table test (id,stat,id_num) values (1,123,2);
insert into table test (id,stat,id_num) values (2,134,1);
insert into table test (id,stat,id_num) values (2,111,2);
insert into table test (id,stat,id_num) values (3,112,1);
insert into table test (id,stat,id_num) values (4,111,1);
insert into table test (id,stat,id_num) values (4,12,2);
insert into table test (id,stat,id_num) values (4,11,3);
Can someone give me a hint how to remove this?Thank you very much for your help!
user13071990 wrote:
Manik which is not a good solution because dat_document can also be duplicated.Alberto is no uniq key in the table, which is the main problem.
It is not a good way to get the table without unique keys.
To work around the problem, I suggest that, despite the fact that I do not use virtual ROWID.
I did a test by inserting a date twice for the same id
insert into test (id,dat_document,id_num) values (4,to_date('01.07.2012','dd.mm.yyyy'),'');
Now, I used:
MERGE INTO test a
USING (SELECT rowid
, ROW_NUMBER () OVER (PARTITION BY id ORDER BY dat_document) AS val
FROM test) b
ON (a.rowid = b.rowid)
WHEN MATCHED
THEN
UPDATE SET id_num = val;
SELECT *
FROM test
ORDER BY id, dat_document;
ID DAT_DOCUMENT ID_NUM
---------- --------------------- ----------
1 01-01-2012 00:00:00 1
1 01-02-2012 00:00:00 2
2 01-03-2012 00:00:00 1
2 01-04-2012 00:00:00 2
3 01-05-2012 00:00:00 1
4 01-06-2012 00:00:00 1
4 01-07-2012 00:00:00 2
4 01-07-2012 00:00:00 3
4 01-08-2012 00:00:00 4
Kind regards.
Al
Tags: Database
Similar Questions
-
need help with the Update statement
Hello
I received a question in a course and I tried my best to respond, and now my brain is giving. I would really appreciate help with the update statement. I don't mind if you do not validate a solution, a little nudge in the right direction would be really useful. I'll post that I got.
THE QUESTION
/ * For these agents disabled on more than seven missions, change their date of deactivation of the first date of deactivation of all the agents that have been activated in the same year as the agent that you update currently.
*/
I have it divided into parts, here is my select statement to agents disabled on more than 7 missions, which produces the deactivation_dates in the agents table that I want to update...
.. .and the code for the first date of deactivation for each year of activation agentSELECT s.deactivation_date FROM ( SELECT a.deactivation_date, count(m.mission_id) as nomissions FROM agents a INNER JOIN missions_agents m on a.agent_id=m.agent_id GROUP BY a.deactivation_date ) s WHERE s.nomissions>7 AND s.deactivation_date IS NOT NULL
..... I am not real to marry these two statements together in the Update statement. I can't extract each date of deactivation produced in the first select statement and their match against the first date of deactivation in the year they have been activated for the second select statement.select a2.deactivation_date from agents a2 where a2.deactivation_date= ( select min(a.deactivation_date) from agents a where to_number(to_char(a.activation_date,'YYYY'))=to_number(to_char(a2.activation_date,'YYYY')) )
Any help greatly appreciated... :))I began to wonder how things would :)
user8695469 wrote:
First of all why he chooses the date the earliest of all agentsUPDATE AGENTS_COPY AC /* (1) */ SET DEACTIVATION_DATE = ( SELECT MIN(AGS.DEACTIVATION_DATE) FROM AGENTS_COPY AGS , AGENTS_COPY AC /* (2) */ WHERE TRUNC(AGS.ACTIVATION_DATE,'YEAR') = TRUNC(AC.ACTIVATION_DATE,'YEAR') /* (3) */ )
He recovers as soon as the subquery has not been correctly set in the SET clause. It seems you are trying to update a correlated, but we are still having a conceptual shift. I have added a few comments to your code above and below will explain.
(1): when you do a correlated update it is useful to the table alias that you did right here.
(2): this table statement is not necessary and is the reason why the FIRST deactivation date is selected. The alias that you use (3) refers to THIS table, not the one defined in the update statement. Remove the line indicated by (2) in the FROM clause and a correlated update will happen.
and secondly why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)
user8695469 wrote: then why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)
WHERE EXISTS ( SELECT a.agent_id, count(m.mission_id) FROM agents a /* INNER JOIN AC ON AC.AGENT_ID = A.AGENT_ID */ INNER JOIN missions_agents m ON a.agent_id=m.agent_id GROUP BY a.agent_id, a.deactivation_date HAVING count(m.mission_id)>7 AND a.deactivation_date IS NOT NULL )
Once again this problem is similar to the question above that a correlation update doesn't work. Test existence of lines in an EXISTS subquery. Since your subquery is not related to the table that you are trying to update, it will be always return a line and, therefore, it returns true for EACH LINE in the AGENTS table. To limit the game to only agents > 7 missions results, you need to add a join condition that references the table in your update statement. I added one above (with comments) as a sample.
I recommend you look over all material that you have associated with correlated subqueries, including documents that I posted above. This seems to be what you're having the problem more with. If you need me to explain the concept of correlated queries any better please let me know.
Thank you!
-
Help with the insert statement
Hello
I was wondering if someone could help write me a sql statement.
Here is my table:
Here are the instructions for correct insertion. This time, I posted 2 examples with 2 numbers different otherwise.CREATE TABLE "TEMP_INVOICE" ("INVOICE" VARCHAR2(100 BYTE), "DATE_OF_DOCUMENT" DATE, "DATE_OF_PAY_DAY" DATE, "D" NUMBER, "K" NUMBER );
I want to do is make an insert allows you to table another call is MADE:insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.02.2012','dd.mm.yyyy'),to_date('01.03.2012','dd.mm.yyyy'),5000,0); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.04.2012','dd.mm.yyyy'),'','',1000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.05.2012','dd.mm.yyyy'),'','',3000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.06.2012','dd.mm.yyyy'),'','',1000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.07.2012','dd.mm.yyyy'),to_date('01.09.2012','dd.mm.yyyy'),8000,0); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.10.2012','dd.mm.yyyy'),'','',5000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.11.2012','dd.mm.yyyy'),'','',2000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.12.2012','dd.mm.yyyy'),'','',1000);
Statements in the INVOICE table should be like this:CREATE TABLE "INVOICE" ("INVOICE" VARCHAR2(100 BYTE), "DATE_OF_DOCUMENT" DATE, "DATE_OF_PAY_DAY" DATE, "DATE_OF_PAYMENT_REC" DATE, "VALUE" NUMBER, "VALUE_DEDUCT" NUMBER, "DATE_FROM" DATE, "DATE_TO" DATE );
........ The Bill... date_of_document... date_of_pay_day... date_of_payment_rec... value... value_deduct... Date_from... Date_to
1...... 1000...............1.1.2012.................1.3.2012................NULL............................ 5000... NULL... 1.3.2012...1.4.2012
2...... 1000...............1.4.2012.................NULL..................... 1.4.2012...1000... 4000... 2.4.2012... 1.5.2012
3...... 1000...............1.5.2012.................NULL..................... 1.5.2012...3000... 1000... 2.5.2012... 1.6.2012
4...... 1000...............1.6.2012.................NULL..................... 1.6.2012...1000
Can someone help me with the sql statement that would insert data from table to table Bill temp_invoice as in the example?
Thank you!
PS
I would try to explain.
(1) the first statement that is to be inserted is original imply that at which is different DATE_OF_PAY_DAY to NULL.
To this inserted negative of the original imply, we must add date_from that is exatly the same date_of_pay_day and date_to which is exactly the same as the date of the first payment. Payment which came first!
(2) we have now in the second insert statement. It will be the first payment of lease with date_of_document and date_pf_payment_rec, which is the same as date_fo_document. Value field will be populated with the amount of payment received and value_deduct field will be the value of the original imply - value of the first payment. Date is date_of_document + 1 and date_to is the date of the next payment.
(3) Insert us the next installment. Date_od_payment_rec is the same as date_of_document... value is the amount of the second payment and value_deduct's previous value_deduct which was of 4000 - value of this second payment. date_from date_of_payment_rec + 1 and date_to is the date of the next payment
So we continue this same pattern until we reached the final payment when we finish insert with the statement:
Date of the document (date of the last payment received) and even for date_of_payment_rec and field value with the amount of the payment receieved. The rest (value_deduct, date_from, date_to) is null.
I really hope you understand what I'm trying to do here.
If you have any other questions please.
Published by: user13071990 on November 22, 2012 04:16
Published by: user13071990 on November 22, 2012 04:16Hello
user13071990 wrote:
... Here are the instructions for correct insertion. This time, I posted 2 examples with 2 numbers different otherwise.Ok!
Be sure to post the results you want new data.You probably need to add "PARTITION BY the Bill" to all analytical clauses in my solution:
INSERT INTO invoice ( invoice, date_of_document, date_of_pay_day, date_of_payment_rec , value, value_deduct, date_from, date_to ) SELECT invoice , date_of_document , date_of_pay_day , CASE WHEN k > 0 THEN date_of_document END AS date_of_payment_rec , NVL (d, k) AS value , NVL2 ( date_of_pay_day , NULL , SUM (d) OVER ( PARTITION BY invoice ORDER BY date_of_document ) - SUM (k) OVER ( PARTITION BY invoice ORDER BY date_of_document ) ) AS value_deduct , NVL ( date_of_pay_day , date_of_document + 1 ) AS date_from , LEAD (date_of_document) OVER ( PARTITION BY invoice ORDER BY date_of_document ) AS date_to FROM temp_invoice ;
Because I'm not an English speaker nativ, that I just posted what it should look like after the insert is successful.
OK, so you can't explain as you want, but you still need to explain.
... @Frank Kulash: you are very close, but still not quite what I'm looking for.
Point out where my solution is the production of incorrect results, and explain (as you can) how to get good results in these places.
-
Need help with the update with several joins statement
I have the following select statement, which takes 29 records:
SELECT
PAA. PROJECT,
PAA. SEGMENT1,
PEIA.expenditure_item_id,
PEIA.expenditure_type,
PEC.expenditure_comment
OF PA.PA_PROJECTS_ALL APP.
PEIA PA.pa_expenditure_items_all,
PEC PA.pa_expenditure_comments
where PPA.segment1 < '2008' and
PPA.project_id = 52 and - just run for project # 20077119 for the test
PEIA.expenditure_type = 'PAY' and
PEIA.project_id = ppa.project_id and
PEC. EXPENDITURE_ITEM_ID = PEIA. EXPENDITURE_ITEM_ID;
I need to update the pec.expenditure_comments to a static field for 29 records. I guess I should start with the following, but don't know how to fill in the where:
Update
PEC PA.pa_expenditure_comments
Set pec.expenditure_comment = ' REFERENCE HD #728'.
where
???
First time we have ever needed to update, so any help appreciated.Try using are:
update pa.pa_expenditure_comments pec set pec.expenditure_comment = 'REFERENCE HD#728' where exists ( select null from pa.pa_projects_all ppa , pa.pa_expenditure_items_all peia , pa.pa_expenditure_comments pec2 where ppa.segment1 < '' -- not sure what you posted here, so for next time: -- please put your examples between the code tags. and ppa.project_id = 52 -- just run for project # 20077119 for testing and peia.expenditure_type = 'PAYROLL' and peia.project_id = ppa.project_id and pec2.expenditure_item_id = peia.expenditure_item_id and pec2.expenditure_item_id = pec.expenditure_item_id );
-
Need help with the update of Windows (OS-Windows 7)
Hello world
Recently, I met a problem with Windows update on my laptop (OS-Windows 7). Everything is fine with it, but when I try to install updates (recommended or optional) window says that it downloads the updates, but the progress remains to 0KB and 0% downloaded status. I tried to restart the service of windows update with utility update of windows running, but without success. However, I was able to install updates, most of them associated with Microsoft.NET framework 3.5.1 (I'm not sure of the version of the .NET Framework is installed in my computer). But when I tried to install other updates updated security windows or .NET Framework 4. XX version update, he gave the same answer that I mentioned above.
I can give my specifications and other information required if necessary.
Please help me with this problem about the update of windows.
Thanks for your time and your help.
Try the following: set never 'Find updates' automatic updates and then restart Windows. Download and install KB3161608.
http://support.Microsoft.com/kb/3161608
Best regards, VZ
-
Need help with the update for my 11 elements
I have 11 items and just switch to the Canon 7 d Markii and shooting in RAW for the first time last night and the editor and organizer elements does not files because it does not acknowledge the BRUTE of the 'new '... device information I tried the update and he offered only a 7.4 update, where the 7 5 d Markii must at least a 8.7 update... How can I get the latest update if my program does not by itself? I DON'T like the way Canon program from the disk provided with the camera is set for RAW images, and I don't want to have to change all the RAW files to only align my items... I enjoyed how the older my camera RAW files were brought in Editor with the pop-up window which allow me to make changes to quick for photos before opening them in the editor... Yet once I don't like how the Canon window works for RAW images... Thanks for any help on this... Nicole
Camera Raw 8.7 was introduced in PSE13. If your software is too old to be compatible. Yu have two choices:
- Upgrade to the latest version PSE14
- Converting your CR2 for Adobe (DNG) Raw and DNG files will work with PSE11
The Adobe's DNG Converter is free, and you can batch process all of a file CR2 by selecting a source folder and destination folder.
-
helps with the update of tabular form using dynamic Action
Hello world
I'm trying to simplify a tabular presentation based on a collection so that it uses more dynamic actions that will be ultimately more easy for us to debug.
Our tabular presentation is based on the query:
SELECT apex_item.text(1,seq_id,'','','id="f01_'||seq_id,'','') "DeleteRow", seq_id, seq_id display_seq_id, c003, c004, c005, c006, apex_item.text_from_LOV(c004,'SPECIES')||'-'||apex_item.text_from_LOV(c005,'GRADE')||'-'||apex_item.text_from_LOV(c006,'MARKETCODE')||'-'||apex_item.text_from_LOV_query(c007,'select unit_of_measure d, unit_of_measure r from species_qc') unit, apex_item.select_list_from_LOV(8,c008,'DISPOSITIONS','onchange="getAllDisposition('||seq_id||')"','YES','0',' -- Select Favorite -- ','f08_'||seq_id,'') Disposition, apex_item.select_list_from_LOV(9,c009,'GEARS','style="background-color:#FBEC5D; "onFocus="checkGearPreviousFocus('||seq_id||');"onchange="getAllGears('||seq_id||')"','YES','3333','-- Select Favorite --','f09_'||seq_id,'') Gear, apex_item.text(10,TO_NUMBER(c010),5,null, 'onchange="setTotal('||seq_id||')"','f10_'||seq_id,'') Quantity, apex_item.text(11,TO_NUMBER(c011),5,null,'onchange="getPriceBoundaries('||seq_id||')"','f11_'||seq_id,'') Price, apex_item.text(12, TO_NUMBER(c012),5,null, 'onchange="changePrice ('||seq_id||')" onKeyDown="selectDollarsFocus('||seq_id||',event);"','f12_'||seq_id,'') Dollars, decode(c013,'Y',apex_item.text(14, c014,30,null,'style="background-color:#FBEC5D;" onClick="onFocusAreaFished('||seq_id||');"','f14_'||seq_id,''),'N','N/A') Area_Fished, c014, c015, c016, c017 additional_measure_flag, decode(c017,'Y',apex_item.text(18, c018,4,null,'style="background-color:#FBEC5D; "onBlur="setUnitQuantity('||seq_id||')"','f18_'||seq_id,''),'N','N/A') UNIT_QUANTITY, decode(c017,'Y',apex_item.text(19,'CN',3,null,'readOnly=readOnly;','f19_'||seq_id,''),'N','N/A') UNIT_COUNT, c024 fins_attached, apex_item.textarea(28,c028,3,null,'class="hms_info"','f28_'||seq_id,'') Explanation, decode(c024,'N',apex_item.select_list_from_LOV(29,c029,'HMSNATURE','class="hms_info"''onchange="saveNature('||seq_id||')"','YES','A','-- Select Nature of Sale --','f29_'||seq_id,''),'U',apex_item.select_list_from_LOV(29,c029,'HMSNATURE','onchange="saveNature('||seq_id||')"','YES','A','-- Select Nature of Sale --','f29_'||seq_id,''),'Y','N/A') Nature_Of_Sale, c030, c031, c032, c033, c034, c035, c036, c037, c038, c039, apex_item.select_list_from_LOV(40,c040,'HMS_AREA_CODE','style="background-color:#FBEC5D;" class="hms_info" ',null,null,null,'f40_'||seq_id,'') HMS_AREA_CODE, c020 hms_flag, apex_item.text(41,TO_NUMBER(c041),5,null, 'class="hms_info"','f41_'||seq_id,'') Sale_Price, c042, c043, c044, c050 shark_flag from apex_collections where collection_name = 'SPECIES_COLLECTION' order by seq_id
Note that many of the fields referenced are c0xx... and really serve as place holders so that the c0xx = fxx. It's awkward, like every time that a movement or move a column, it upsets the fxx value. So, I tried to use the CLASS if possible.
I have a dynamic action that had worked perfectly, until I moved one of the columns... and now, it seems not to work when I'm trying to update anything with the HMS_INFO or SHARK_INFO class. Grrr.
dynamic action: CHANGE COLUMN
event: CHANGE
selection type: JQUERY SELECTOR
jQuery selector: input [name = 'f10'], input [name = 'f11'], input [name = 'f12'], input [name = "f24"], textarea [name = "f28"], select [name = "f40"], input [name = "f41"]
true action1: defined value, expression javascript, set P110_ID = this.triggeringElement.id
true action2: defined value, expression javascript, set P110_VALUE = this.triggeringElement.value
true action3: run pl/sql,.
declare v_attr number; v_seq number; begin v_attr := TO_NUMBER (SUBSTR (:p110_id, 2, 2)); select ltrim(substr(:p110_ID,5,4),'0') into v_seq from dual; safis_collections.update_column(v_seq, v_attr, :p110_value); end;
the safis_collections.update_column package is:
procedure update_column(v_seq in varchar2, v_attr in number, v_value in varchar2) is begin apex_collection.update_member_attribute (p_collection_name=> 'SPECIES_COLLECTION', p_seq => v_seq, p_attr_number => v_attr, p_attr_value => v_value); apex_debug.message('updated column. seq='||v_seq||' attribute='||v_attr||' with '||v_value); end;
I wonder if there is a way to make the CLASS in my JQUERY SELECTOR, so something like reference entry [class = "HMS_INFO"], input [CLASS = "shark_info"]... and if so, what happens if a single item in the class is an option button and the other is a selection list and the other an element?
is it possible to not have to rely on the fxx. Currently, my collection columns map to the investment in the form of tables... sense, c024 = f24... because I placed c024 to be the 24th editable column, but this seems crazy. Is there a simpler way? I'm just learning class, then maybe there is something extra, or rather that I could use...
any help is appreciated. Thank you!
I think I have solved the problem.
dynamic action: CHANGE COLUMN
event: CHANGE
selection type: JQUERY SELECTOR
jQuery selector: input [name = 'f10'], input [name = 'f11'], input [name = 'f12'], .shark_info, .hms_info
true action1: defined value, expression javascript, set P110_ID = this.triggeringElement.id P110_VALUE POINT KEYS
true action2: run pl/sql code
begin null; end;
items to submit page: P110_ID
true action3: defined value, expression javascript, set P110_VALUE = this.triggeringElement.value P110_VALUE POINT KEYS
true Action4: value: PL/SQL expression, the value P110_SEQ = rtrim (substr(:P110_ID,5,4),'0 ') CONCERNED POINT: P110_SEQ
true Action5: run pl/sql code
declare v_attr number; begin v_attr := TO_NUMBER (SUBSTR (:P110_id, 2, 2)); apex_collection.update_member_attribute (p_collection_name => 'SPECIES_COLLECTION', p_seq => :P110_SEQ, p_attr_number => v_attr, p_attr_value => :P110_VALUE); end;
items to submit page: P110_ID, P110_VALUE, P110_SEQ
true action6: refreshment area
I think it is the combination of the use of pl/sql expression to calculate P110_SEQ and also your tip on TRUE ACTION2 to submit the item that did the trick.
Thanks Kofi, for your patience and help! It was great.
Ugh... on the next issue.
Karen
-
need help with the Merge statement
I'm on: Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production
I'm currently an UPDATE statement and then it works and is accurate, it takes 30 minutes. I heard that MERGE
can do the same thing and is just as accurate and much faster!
Here's the query I want to convert into a MERGE INTO statement. I tried to do it myself, but I get errors and don't know simply, since it's new for me.
Basically I want to update table your on a corresponding condition in the table tt for 2 columns (GTP and UPDATE_DT), for UPDATE_DT I want to insert the Date current system.
Thank you!UPDATE /*+ PARALLEL (16) */ OLDER_Table ta SET (ta.GTP, ta.UPDATE_DT) = (SELECT /*+ PARALLEL (16) */ tt.GTP, SYSDATE FROM NEWER_Table tt WHERE ta.cust_id = tt.cust_id AND ta.STAMP_DATE = tt.STAMP_DATE AND ROWNUM = 1) WHERE EXISTS (SELECT 1 FROM NEWER_Table tt WHERE ta.cust_id = tt.cust_id AND ta.STAMP_DATE = tt.STAMP_DATE AND (NVL(ta.GTP, 'X') != NVL(tt.GTP, 'X')));
Hello
Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
If you ask on a DML statement, such as UPDATE, CREATE TABLE and INSERT statements need to re - create the tables as they are before the DML, and results will be the content of the or the tables changed when it's all over.
See the FAQ forum {message identifier: = 9360002}MERGE peut be much faster than update; Sometimes, there is no significant difference in speed.
Tables in multiple situations like this, I've never seen a case where the MERGER has been slower than the UPDATE, even if the UPDATE is sometimes easier to code and just as fast.Maybe that's what you want:
MERGE INTO older_table dst USING ( SELECT n.cust_id , n.stamp_date , n.gtp , ROW_NUMBER () OVER ( PARTITION BY n.cust_id , n.stamp_date ORDER BY n.gtp ) AS r_num FROM newer_table n JOIN older_table o ON n.cust_id = o.cust_id AND n.stamp_date = o.stamp_date AND NVL ( n.gtp , 'X' ) != NVL ( o.gtp , 'X' ) ) src ON ( src.cust_id = dst.cust_id AND src.stamp_date = dst.stamp_date AND src.r_num = 1 ) WHEN MATCHED THEN UPDATE SET dst.gtp = src.gtp , dst.update_date = SYSDATE ;
As I can't test it, I can't be sure.
-
Need help with the update server behaviors and deleting records
I am 'trying' to use the update and delete record server behaviors and I can't get the redirection page to set up correctly. What I'm trying to do, is to have the redirection came up with the right records depending on the CompId page. It seems that it is taking the CompId and agreementId (which are my unique ID) and use them in the url of the redirection page. Also, it updates the table. Here is the url that appears after I have send the update:
http://localhost:8888/dotweb/maintenance/agreement_home.php?CompId= & agreementId = 7
Here is the code for the update page:
Pending patent, trade mark, Tradesecret and straightened to copy recordedCopyright KML designs 2009Can someone tell me why it would show the CompId and agreementId when everything I asked the CompId? Thanks for your help. Just in case, I enclose you an html version of this file. It must be a php file, but is not one of the allowed file types.
CompId is not filled in the URL because you try to use the result of the rsAgree recordset object until the result of the recordset is created. However, you pass the CompId value via array $_POST as a hidden field.
Change this line (52):
$updateGoTo = "agreement_home.php?CompId=" . $row_rsAgree['CompId'] . "";
to do this:
$updateGoTo = "agreement_home.php?CompId=" . $_POST['CompId'];
-
Performance issue with the Update statement
Oracle 10204
I have a problem related to updaing one performance table.
only 5000 lines should be updated.
Hir are some details on the tables/M.V concerned:
I tried to run the update with two options:TABLE_NAME LAST_ANALYZED NUM_ROWS SAMPLE_SIZE PS_RF_INST_PROD 1/20/2010 1:14:22 AM 7194402 7194402 BL_TMP_INTRNT 1/27/2010 9:08:54 AM 885445 885445 NAP_INTERNET 1/25/2010 11:47:02 AM 7053990 560777
1. with the plan than oracle choose.
2. with notes I added.
In both cases I he collapsed after more than an hour.
Can any one suggest how to speed it up?
Below are for the two option tkprof.
Plan 1Please note that beside the defualt statistics on those tables i also gathered statistics on two column level as followed: BEGIN SYS.DBMS_STATS.GATHER_TABLE_STATS ( OwnName => 'B' ,TabName => 'BL_TMP_INTRNT' ,Estimate_Percent => 100 ,Degree => 8 ,Cascade => TRUE ,No_Invalidate => FALSE); END; / exec dbms_stats.gather_table_stats('B' , 'BL_TMP_INTRNT', cascade=>TRUE, method_opt=>'for columns SERVICE_UID size 254'); exec dbms_stats.gather_table_stats('B' , 'BL_TMP_INTRNT', cascade=>TRUE, method_opt=>'for columns FIX_IP_USER size 254');
plan 2UPDATE BL_TMP_INTRNT A SET A.FIX_IP_USER = (SELECT C.PRODUCT_ID FROM NAP_INTERNET B, PS_RF_INST_PROD C WHERE B.INST_PROD_ID = A.SERVICE_UID AND B.SETID = 'SHARE' AND C.INST_PROD_ID = B.NAP_SURF_UID) WHERE A.TERM_DESC LIKE '%ip%' call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.03 0.02 0 0 0 0 Execute 1 1166.64 4803.78 17989002 18792167 117 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 1166.67 4803.81 17989002 18792167 117 0 Misses in library cache during parse: 1 Optimizer mode: FIRST_ROWS Parsing user id: 13 Rows Row Source Operation ------- --------------------------------------------------- 0 UPDATE BL_TMP_INTRNT (cr=0 pr=0 pw=0 time=2 us) 46 TABLE ACCESS FULL BL_TMP_INTRNT (cr=586400 pr=22228 pw=0 time=15333652 us) 15 HASH JOIN (cr=18170453 pr=17931639 pw=0 time=3991064192 us) 46 MAT_VIEW ACCESS FULL NAP_INTERNET (cr=5659886 pr=5655436 pw=0 time=988162557 us) 329499624 MAT_VIEW ACCESS FULL PS_RF_INST_PROD (cr=12545734 pr=12311281 pw=0 time=2636471644 us)
UPDATE BL_TMP_INTRNT A SET A.FIX_IP_USER = (SELECT /*+ index(b NAP_INTERNET_PK) index(c PS_RF_INST_PROD_PK)*/ C.PRODUCT_ID FROM NAP_INTERNET B, PS_RF_INST_PROD C WHERE B.INST_PROD_ID = A.SERVICE_UID AND B.SETID = 'SHARE' AND C.INST_PROD_ID = B.NAP_SURF_UID) WHERE A.TERM_DESC LIKE '%ip%' call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.02 0.02 0 0 0 0 Execute 1 4645.25 4613.70 95783 39798095 735 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 4645.27 4613.73 95783 39798095 735 0 Misses in library cache during parse: 1 Optimizer mode: FIRST_ROWS Parsing user id: 13 Rows Row Source Operation ------- --------------------------------------------------- 0 UPDATE BL_TMP_INTRNT (cr=0 pr=0 pw=0 time=1 us) 473 TABLE ACCESS FULL BL_TMP_INTRNT (cr=10461 pr=10399 pw=0 time=4629385 us) 408 MAT_VIEW ACCESS BY INDEX ROWID PS_RF_INST_PROD (cr=39776109 pr=85381 pw=0 time=4605125045 us) 1350 NESTED LOOPS (cr=39784584 pr=84974 pw=0 time=4601874262 us) 470 MAT_VIEW ACCESS BY INDEX ROWID NAP_INTERNET (cr=23569112 pr=50472 pw=0 time=2544364336 us) 470 INDEX FULL SCAN NAP_INTERNET_PK (cr=23568642 pr=50005 pw=0 time=2540300981 us)(object id 11027362) 408 INDEX FULL SCAN PS_RF_INST_PROD_PK (cr=16215472 pr=34502 pw=0 time=2057500175 us)(object id 10980137) Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file scattered read 1300 0.50 4.27 db file sequential read 85707 0.51 29.88 latch: cache buffers chains 1 0.00 0.00 log file sync 1 0.00 0.00 SQL*Net break/reset to client 1 0.00 0.00 SQL*Net message to client 1 0.00 0.00 SQL*Net message from client 1 14.73 14.73 ********************************************************************************
The problem in your update statement that is the query in your set clause is executed many times that there are lines in BL_TMP_INTRNT of 'intellectual property' in their column of term_desc. You mentioned there are about 5000, then the query joining NAP_INTERNET with PS_RF_ISNT_PROD is begun 5000 times.
The trick is to join only once, be updated using join views - provided that it is preserved - key or by using the merge statement.Here is an example:
SQL> create table bl_tmp_intrnt (fix_ip_user,service_uid,term_desc) 2 as 3 select level 4 , level 5 , 'aipa' 6 from dual 7 connect by level <= 5000 8 / Tabel is aangemaakt. SQL> create table nap_internet (inst_prod_id,setid,nap_surf_uid) 2 as 3 select level 4 , 'SHARE' 5 , level 6 from dual 7 connect by level <= 10 8 / Tabel is aangemaakt. SQL> create table ps_rf_inst_prod (product_id,inst_prod_id) 2 as 3 select level 4 , level 5 from dual 6 connect by level <= 10 7 / Tabel is aangemaakt. SQL> exec dbms_stats.gather_table_stats(user,'bl_tmp_intrnt') PL/SQL-procedure is geslaagd. SQL> exec dbms_stats.gather_table_stats(user,'nap_internet') PL/SQL-procedure is geslaagd. SQL> exec dbms_stats.gather_table_stats(user,'ps_rf_inst_prod') PL/SQL-procedure is geslaagd. SQL> set serveroutput off SQL> update ( select a.fix_ip_user 2 , c.product_id 3 from bl_tmp_intrnt a 4 , nap_internet b 5 , ps_rf_inst_prod c 6 where a.term_desc like '%ip%' 7 and a.service_uid = b.inst_prod_id 8 and b.setid = 'SHARE' 9 and b.nap_surf_uid = c.inst_prod_id 10 ) 11 set fix_ip_user = product_id 12 / set fix_ip_user = product_id * FOUT in regel 11: .ORA-01779: cannot modify a column which maps to a non key-preserved table
Join is one key kept in the case of b.inst_prod_id and c.inst_prod_id are unique. Please refer to the documentation for more information here: http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/views.htm#sthref3055
SQL> alter table nap_internet add primary key (inst_prod_id) 2 / Tabel is gewijzigd. SQL> alter table ps_rf_inst_prod add primary key (inst_prod_id) 2 / Tabel is gewijzigd. SQL> update /*+ gather_plan_statistics */ 2 ( select a.fix_ip_user 3 , c.product_id 4 from bl_tmp_intrnt a 5 , nap_internet b 6 , ps_rf_inst_prod c 7 where a.term_desc like '%ip%' 8 and a.service_uid = b.inst_prod_id 9 and b.setid = 'SHARE' 10 and b.nap_surf_uid = c.inst_prod_id 11 ) 12 set fix_ip_user = product_id 13 / 10 rijen zijn bijgewerkt. SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last')) 2 / PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------------------------------------------------------------- SQL_ID c7nqbxwzpyq5p, child number 0 ------------------------------------- update /*+ gather_plan_statistics */ ( select a.fix_ip_user , c.product_id from bl_tmp_intrnt a , nap_internet b , ps_rf_inst_prod c where a.term_desc like '%ip%' and a.service_uid = b.inst_prod_id and b.setid = 'SHARE' and b.nap_surf_uid = c.inst_prod_id ) set fix_ip_user = product_id Plan hash value: 1745632149 --------------------------------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem | --------------------------------------------------------------------------------------------------------------------------------------- | 1 | UPDATE | BL_TMP_INTRNT | 1 | | 0 |00:00:00.01 | 32 | | | | | 2 | NESTED LOOPS | | 1 | 10 | 10 |00:00:00.01 | 21 | | | | | 3 | MERGE JOIN | | 1 | 10 | 10 |00:00:00.01 | 9 | | | | |* 4 | TABLE ACCESS BY INDEX ROWID| NAP_INTERNET | 1 | 10 | 10 |00:00:00.01 | 2 | | | | | 5 | INDEX FULL SCAN | SYS_C00132995 | 1 | 10 | 10 |00:00:00.01 | 1 | | | | |* 6 | SORT JOIN | | 10 | 250 | 10 |00:00:00.01 | 7 | 267K| 256K| 237K (0)| |* 7 | TABLE ACCESS FULL | BL_TMP_INTRNT | 1 | 250 | 5000 |00:00:00.01 | 7 | | | | | 8 | TABLE ACCESS BY INDEX ROWID | PS_RF_INST_PROD | 10 | 1 | 10 |00:00:00.01 | 12 | | | | |* 9 | INDEX UNIQUE SCAN | SYS_C00132996 | 10 | 1 | 10 |00:00:00.01 | 2 | | | | --------------------------------------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 4 - filter("B"."SETID"='SHARE') 6 - access("A"."SERVICE_UID"="B"."INST_PROD_ID") filter("A"."SERVICE_UID"="B"."INST_PROD_ID") 7 - filter("A"."TERM_DESC" LIKE '%ip%') 9 - access("B"."NAP_SURF_UID"="C"."INST_PROD_ID") 32 rijen zijn geselecteerd. SQL> rollback 2 / Rollback is voltooid.
And it's your current statement. Please note the number of 5000 in the column begins:
SQL> UPDATE /*+ gather_plan_statistics */ BL_TMP_INTRNT A 2 SET A.FIX_IP_USER = 3 (SELECT C.PRODUCT_ID 4 FROM NAP_INTERNET B, PS_RF_INST_PROD C 5 WHERE B.INST_PROD_ID = A.SERVICE_UID 6 AND B.SETID = 'SHARE' 7 AND C.INST_PROD_ID = B.NAP_SURF_UID) 8 WHERE A.TERM_DESC LIKE '%ip%' 9 / 5000 rijen zijn bijgewerkt. SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last')) 2 / PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------------------------------------------------------------- SQL_ID f1qtnpa0nmbh8, child number 0 ------------------------------------- UPDATE /*+ gather_plan_statistics */ BL_TMP_INTRNT A SET A.FIX_IP_USER = (SELECT C.PRODUCT_ID FROM NAP_INTERNET B, PS_RF_INST_PROD C WHERE B.INST_PROD_ID = A.SERVICE_UID AND B.SETID = 'SHARE' AND C.INST_PROD_ID = B.NAP_SURF_UID) WHERE A.TERM_DESC LIKE '%ip%' Plan hash value: 3190675455 ----------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | ----------------------------------------------------------------------------------------------------------- | 1 | UPDATE | BL_TMP_INTRNT | 1 | | 0 |00:00:00.10 | 5076 | |* 2 | TABLE ACCESS FULL | BL_TMP_INTRNT | 1 | 250 | 5000 |00:00:00.01 | 7 | | 3 | NESTED LOOPS | | 5000 | 1 | 10 |00:00:00.02 | 24 | |* 4 | TABLE ACCESS BY INDEX ROWID| NAP_INTERNET | 5000 | 1 | 10 |00:00:00.01 | 12 | |* 5 | INDEX UNIQUE SCAN | SYS_C00132995 | 5000 | 1 | 10 |00:00:00.01 | 2 | | 6 | TABLE ACCESS BY INDEX ROWID| PS_RF_INST_PROD | 10 | 10 | 10 |00:00:00.01 | 12 | |* 7 | INDEX UNIQUE SCAN | SYS_C00132996 | 10 | 1 | 10 |00:00:00.01 | 2 | ----------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter("A"."TERM_DESC" LIKE '%ip%') 4 - filter("B"."SETID"='SHARE') 5 - access("B"."INST_PROD_ID"=:B1) 7 - access("C"."INST_PROD_ID"="B"."NAP_SURF_UID") 29 rijen zijn geselecteerd.
Kind regards
Rob. -
Helps with the update of Table
Hi, I have a table created in book of recent years:
I would like to 'try' and just update with the new Word.docx
Is it EASY without complication or should I try and rebuild the table from scratch in Id?
HOW THEN I update THE TABLE to ID card?
Simply:
(1) (copy the text of the .doc
(2) select the text in the table Id, delete, paste
This seems to have worked...
-
question using box with the update statement
Hi all
I have a region that uses a collection as its source and it has a check box. The intention is to check some lines and then use a PL/SQL block to update a table based on the audited lines. My problem is the table, I'm trying to update includes two primary keys.
I need to find a way to get both keys on the checked lines. How can I do this? I can get the first of the box, but when I try to refer to something like apex_application.g_f08 I get only the value in the first line and NOT the lines checked.
Here is my collection C007 represents ONE of the primary keys (header_id)
SELECT APEX_ITEM. CHECKBOX(7,C007,'UNCHECKED') ""
C001
C002
C003
C004
C005
C006
c007
c008
Of apex_collections
WHERE collection_name = "UNGROUPED_SETS."
order by C001, C002
Here are the PL/SQL that performs the update...
DECLARE
vRowNumber PLS_INTEGER;
l_rows_updated PLS_INTEGER: = 0;
BEGIN
-loop for checkboxs checkees
If NVL (apex_application.g_f07. COUNTY, 0) > 0 THEN
Start
because me in 1... apex_application.g_f07. COUNTING loop
-Updated forx_oe_line_partials with the data entered by the user in the region
Update forx_oe_line_partials_mlob
Set last_update_date = sysdate
, last_updated_by =: P6_CREATED_BY
, last_update_login =: P6_LAST_UPDATE_LOGIN
, comment_for_invoice =: P6_INVOICE_COMMENTS
where header_id = apex_application.g_f07 (i); -It works very well, but...
- AND set_id =? -put the second primary key here!
l_rows_updated: = l_rows_updated + sql rowcount %;
end loop; -Box loop
: P6_UPDATE_COUNT: = l_rows_updated;
end;
on the other
raise_application_error (-20001, 'Check box unchecked.');
end if;
END; -End main;Check {message identifier: = 9430142}
-
Need help with the insert statement
Hello
I have a question on how to write a SQL statement.
This is the table of "base":
and it comes to resoult in the target table. SQL statement must take care of the insert in a base of the target table table (example below is already provided with test data).CREATE TABLE TEMP_TBL ( id_nr NUMBER, DATE_DOK DATE, DATE_DUE DATE, DATE_DOK_PAY DATE, DEB NUMBER, KRD NUMBER ); insert into temp_tbl (ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('1',TO_DATE('11.01.2011','DD.MM.YYYY'),TO_DATE('25.02.2011','DD.MM.YYYY'),NULL,'423,24','0'); insert into temp_tbl(ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('2',TO_DATE('16.12.2011','DD.MM.YYYY'),TO_DATE('13.06.2011','DD.MM.YYYY'),NULL,'91270,15','0'); insert into temp_tbl(ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('3',TO_DATE('27.09.2011','DD.MM.YYYY'),TO_DATE('27.09.2011','DD.MM.YYYY'),NULL,'0','2000');
If someone could give me a helping hand how write correct insert statement I would be really gratefull.create table table_sod ( id_nr number ,date_from date ,date_to date ,deb_krd number ); One thing to note here : values in column deb_krd under insert 1 and 4 must be summarized in insert 4. insert into table_sod (id_nr,date_from,date_to,deb_krd) values('1',null,to_date('25.02.2011','dd.mm.yyyy'),'423,24'); insert into table_sod(id_nr,date_from,date_to,deb_krd) values('2',to_date('26.02.2011','dd.mm.yyyy'),to_date('13.06.2011','dd.mm.yyyy'),'423,24'); insert into table_sod(id_nr,date_from,date_to,deb_krd)values('3',null,to_date('13.06.2011','dd.mm.yyyy'),'91270,15'); insert into table_sod(id_nr,date_from,date_to,deb_krd)values('4',to_date('14.06.2011','dd.mm.yyyy')to_date('27.09.2011','dd.mm.yyyy'),'91693,39'); insert into table_sod(id_nr,date_from,date_to,deb_krd)values('5',null,to_date('27.09.2011','dd.mm.yyyy'),'2000');
Thank you for your time!I came here with my own assumptions with this
SQL> select rownum id_nr 2 , date_from 3 , date_to 4 , case when date_from is null then deb 5 else sum(case when date_from is not null then deb else 0end) over(order by id_nr, no) 6 end deb_krd 7 from ( 8 select id_nr 9 , case when lg_dt is null or ld_dt = date_due then null else lg_dt+1 end date_from 10 , ld_dt date_to 11 , case when deb = 0 then krd else deb end deb 12 , no 13 from ( 14 select t1.* 15 , lead(t1.date_due) over(order by t1.id_nr, t2.no) ld_dt 16 , lag(t1.date_due) over(order by t1.id_nr, t2.no) lg_dt 17 , t2.no 18 from temp_tbl t1 19 cross 20 join (select 1 no from dual union all select 2 no from dual) t2 21 order by id_nr, no 22 ) 23 where ld_dt is not null 24 ) 25 / ID_NR DATE_FROM DATE_TO DEB_KRD ---------- --------- --------- ---------- 1 25-FEB-11 42324 2 26-FEB-11 13-JUN-11 42324 3 13-JUN-11 9127015 4 14-JUN-11 27-SEP-11 9169339 5 27-SEP-11 2000
-
Need help with the IF statement.
I am trying to write an IF statement using FormCalc in LiveCycle. I have the "tpe" cell that captures the total number of points. I would attribute levels based on the number of points obtained. For example, level I = 1001-1985; level II = 851-1000; level III = 551-850; level IV = < 551. I want to 'level' of cell to show I, II, III or IV, based on the points in the cell "tpe". How can I do this? I have zero familiarity with FormCalc or scripts in general. Can someone help me with this please? Would appreciate any help! Thank you!
Just put the script in the field calculate level instead:
If (tpe tpe and > 1000<= 1985)="">=>
$ = "I"
ElseIf (tpe > 850 and tpe<= 1000)="">=>
$ = « II »
ElseIf (tpe > 550 and tpe<= 850)="">=>
$ = 'III'
ElseIf (tpe<= 550)="">=>
$ = « IV »
else $ = «»
endif
Also just have a glance to your form - for the next time that you could save yourself a lot of time in your configuration through the use of tables for all of these fields, rather than making each a numeric field separated.
-
I need help with the updates listed below
I tried several times to install updates as follows: KB 2468871 KB 2533523 for my Vista SP2 program with a 32-bit and I get the error message 643 / I use Chrome most of the time, but I also have IE.
You're certainly not alone...
You can try to repair the .NET Framework 4 and if that doesn't work, download updates relevant manually and install the same.
To repair the .NET Framework 4 Client Profile or .NET Framework 4 extended etc. -.
· Click on start/Orb and click on Control Panel.
· Go to the program and features.
· Locate the Microsoft.Net Framework 4 Client Profile or .NET Framework 4 extended, right-click.
· You should have the choice to repair or uninstall/change, click it.
· This will then give you the opportunity to fix it
· Select the repair option.
Manual download of updates (just search for the most relevant to your problem)
1. http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27017 (KB2539636)
2. http://www.microsoft.com/download/en/details.aspx?id=3556 (KB2468871)
3. http://www.microsoft.com/download/en/details.aspx?id=27014 (KB2533523)Make sure you download the one appropriate for your system.
http://support.Microsoft.com/kb/827218
Install as administrator.
Addition, it is rather a big discussion here:
Maybe you are looking for
-
How to get the FireWire on Satellite L70-A-138?
Hello! How to connect an adapter or a firewire port to my Satellite L70-A-138? I need firewire port for video capture - camcorder Mini DV "FX" 1000th (Via Adobe Premiere) Can you help me please?
-
After the stand-by mode screen turns green or the GET messy graphics - Satellite M100-165
When I leave my phone for more than 20 minutes on the stand of mode and I try to turn it on again the screen turns green or the graphics be annoying.In order to work, I have to reset and turn it back on. Does anyone know what I can do about it?Thanks
-
Article 861122 start WZC Unable to connect a computer to the network wirelee I firstly the WZC serviceand I need advice. TX
-
Changed the bad disk to another - XP key will transfer fees drive installed and how to make xp on the fresh drive?
-
"Updates installs then your computer stops" shows everyday - is this the same update
original title: "install updates then shuts down your computer"-windows vista home premium Start button still shows a small yellow icon next to the 'Off' button that says "install updates then shuts down your computer" every day. Is this the same up