Correlated update: how to upgrade ONLY the lines that need?
HelloCan you please help me debug this query? I would like to do a correlated update where only CERTAIN lines must be updated, the other should be unchanged.
{color: #0000ff} * 1. Set up: * {color}
CREATE product TABLE
(
Whole ProductID ACTIVATE NOT NULL,
ProductName varchar2 (20) NULL NOT, ALLOW
CategoryName varchar2 (20) NULL NOT, ALLOW
CategoryID integer NULL,
CONSTRAINT PK_Product PRIMARY KEY (ProductID)
) ;
/
-DROP TABLE category
CREATE TABLE category
(
Whole CategoryID ACTIVATE NOT NULL,
CategoryName varchar2 (20) NULL NOT, ALLOW
CONSTRAINT PK_Category PRIMARY KEY (CategoryID)
) ;
/
INSERT INTO category (CategoryID, CategoryName) VALUES (1, 'Food');
INSERT INTO category (CategoryID, CategoryName) VALUES (2, 'Software');
INSERT INTO category (CategoryID, CategoryName) VALUES (3, 'Electronic');
/
INSERT INTO product (ProductID, ProductName, CategoryName, CategoryID) VALUES (1, 'Tomato', 'Vegetables', 1);
INSERT INTO product (ProductID, ProductName, CategoryName, CategoryID) VALUES (2, 'Cray CX1","Electronic", null);
INSERT INTO product (ProductID, ProductName, CategoryName, CategoryID) VALUES (3, 'Ubuntu', 'Software', 3); {color: #ff0000}-bad CategoryID {color}
INSERT INTO product (ProductID, ProductName, CategoryName, CategoryID) VALUES (4, 'Milk', 'Food', 1);
/
{color: #0000ff} * 2. Review wrong data * {color}
* ProductID 2 and 3 are incorrect. They have corresponding CategoryName but different CategoryID as the reference table of categories
* 1 ProductID is technically incorrect, but because it has no counterpart CategoryName ("plant") in the reference table, there is not enough information to correct for this ProductID line should NOT be updated
* 4 ProductID is OK, nothing to update
In conclusion only TWO records produced must have their CategoryID update:
SELECT PROD.*, CAT. CategoryName
PRODUCT PROD
JOIN INTERNAL category CATS CAT. CategoryName = PROD. CategoryName
WHERE to merge (prod.) CategoryID, 0) & lt; & gt; CAT. CategoryID
* {color: #0000ff} 3. A correlation between the update {color} *.
UPDATE product PROD
CategoryID = SET
(
SELECT THE CAT. CategoryID
The CATEGORY cat
WHERE CAT. CategoryName = PROD. CategoryName AND Coalesce(PROD.) CategoryID, 0) & lt; & gt; CAT. CategoryID
);
* {color: #ff0000} 4. Question {color} *.
The update in step 3 has updated the entire table of the product. 1 ProductID and 4 that shouldn't be updated have had their CategoryID NULL value.
Can you please help me with the difficulty of the request?
Thank you very much in advance for any help.
I want to know the most effective way to resolve this type of query.
Well... How do you know that's not effective? Did run you it?
You can also try join editable views, but this will only work if you have primary keys correct or updated unique indexes in place.
update
(
select p.categoryid p_categoryid
,c.categoryid c_categoryid
from product p
,category c
where c.categoryname = p.categoryname
and nvl(p.categoryid,0) != c.categoryid
)
set p_categoryid = c_categoryid;
You'll know what I mean if you get the error "key preserved table.
Tags: Database
Similar Questions
-
I received an error message telling me that my display driver was not at the height, & that some improvements would not be enabled. I've since updated my display driver. How can I get the improvements that have been initially disabled?
Thank you...
If you have all the features you need and there is no problem. let alone ps.
-
How to upgrade only the page numbers from a table of contents in Indesign CS6?
Hello!
Help, please! I make a medical book with more then 1300 pages and about 40 different table of contents.
I want to update only the page numbers on all the table of contents. But I don't see the option to update the table of contents.
I've seen on other forums that it is a very old and familiar problem. Do you have Adobe already fixed it?
Nothing has changed with the function table of contents. If you update a table of contents using the standard method of the table of contents, the complete table of contents are updated.
You can get the page numbers only updates manually by creating your table of contents by using cross-references.
-
How to backup only the images that are found only in the white rectangle?
Hello!
Good morning/afternoon/evening, I have a question... when I try to draw outside the lines, in my project final when I export it to an image file, looks... weird here, I'll try to upload some pictures.as I want to do as in my last project (picture) all I want is the substance that is in the white rectangle.
Incidentally, I learn how to use it so I'm sorry!
How do you save your picture? What type of file? What version of Illustrator?
For example, try one of these:
1.) export > click on work plans 'use '.
or
(2.) in the file > "Save for Web" it is an option for "Clip for work plan" which is what you're after.
Perhaps one of those who will help and meet your needs?
-
get the only the lines that the max column
Hello
This is my entry
Thanks in advance for any help2 x1 18/03/2003 59,4 2 x1 03/04/2003 55 2 x1 01/01/2002 51,65 33 y1 22/08/2005 44 61 z1 22/08/2005 55 61 z1 01/01/2008 55 64 z2 16/01/2004 44 64 z2 22/08/2005 44 How can I do to get only the rows having the max data_iv, that is: 2 x1 03/04/2003 55 33 y1 22/08/2005 44 61 z1 01/01/2008 55 64 z2 22/08/2005 44
You can use the analytical functions with a view online, for example
SELECT * FROM ( SELECT col1 , col2 , col3 , col4 , RANK() OVER (PARTITION BY col1 ORDER BY col3 DESC) ranking FROM table ) WHERE ranking = 1
-
How to fill out the lines that have been drawn with the paint brush tool?
I keep trying to use the paint bucket tool, and it does not. I need help, because I need to work on this animation.
It is usually because there are gaps in the line. There is a trick which called narrow gaps that is available when you click on the paint bucket tool. Select one of the options, and it's much easier to fill something drawn with a brush.
-
How to upgrade only the UPDATED / CHANGED column in a FORM
Hello
I have a FORM that is based on a table to say... TABLE1:
When create/apply changes.. .He calls the default process DML and does the insert/update of the TABLE1 table.
at the same time, I have other processes PL\SQL... who does the insert/update manual in the other table... TABLE2 for some pulse columns col1, col2, col3...
When I'm in UPDATE mode and have not changed the column col1, col2, col3... even my next manual update will be pulled... The AUDIT is run, and it updates the last_update_date & last_updated_by...
HOW TO AVOID THIS PROBLEM?
Thank youupdate table2 set col1 = :p_col1, col2 = :p_col2, col3 = :p_col3
DeepakDeepak,
You can change your trigger to address this issue...
IF :new.col1 != :old.col1 OR :new.col2 != :old.col2 OR :new.col3 != :old.col3 THEN :new.last_updated_by := v('APP_USER'); :new.last_updated_on := SYSDATE; END IF;
See you soon,.
Hari -
How to remove the lines that have the employee name double?
Hello world
Greetings
I'm using oracle 11g.
Suppose I have a table and I want to delete lines that have the name used twice?
So given below is my table so I only delete lines that have more than one 'Ram' and 'Dilip' ename.
How to do this?
EmpID Ename salary Commission depnto 101 RAM 5000 453 1 102 RAM 6000 765 2 103 Sisi 3456 876 3 104 Dilip 7656 675 4 105 Mohan 9878 767 5 106 Dilip 5646 987 6 107 Ganesh 9823 455 7 You can use a simple code as follows
Delete From EMP
Where rowid! = (select min (rowid) of the group by Ename EMP);
For preserved older values using 'min (rowid)'
and for the most recent values required use "max (rowid)"
Thank you.
-
Collections by ignoring the lines that were not updated
Hi all
I have a report based on a collection. In the present report is a lov in which a user can assign a value to the recording. However, the user doesn't have to update all records before saving. Based on the examples of the collection I've seen, it seems to be an assumption that all records will be updated. I'm having trouble trying to update only the lines in the collection that the user has entered a value for.
Any ideas would be greatly appreciated.
Thank youDon't know what you have in mind. If you are thinking to add another value of the column to the collection and handling, it should work better than the box. You will have at least a NULL value or a value of text associated with each line in your collection.
-
How can I change the line spacing?
I looked everywhere to find how I can change the line spacing in my e-mail address when sending. Can't find any dishes. CAM help me?
The answer is probably some handmade css coding which is not a trivial thing to do.
Why you want to change the line spacing? A larger or smaller font would be useful for you?
-
How to call only the operations of several connectors of ICF through simple connector server
Hi Experts,
I developed two connectors of the ICF (ICF1 and ICF2) and placed the beams of connector on the same server connector.
Please guide me how to get only the authorities of each of the connector to call operations of each separately.
I use following code-
List of < ConnectorInfo > this.getConnectorInfoManager = cInfos () .getConnectorInfos ();
System.out.println (cInfos.Size ());
for {(ConnectorInfo cInfo:cInfos)
APIConfiguration apiConfiguration = cInfo.createDefaultAPIConfiguration ();
setPoolConfigurations (apiConfiguration);
Discoveryendpointspecifie configProps = apiConfiguration.getConfigurationProperties ();
this.setUpConfigurationProperties (configProps);
ConnectorFacadeFactory facadeFactory = ConnectorFacadeFactory.getInstance ();
ConnectorFacade connectorFacade = (apiConfiguration) facadeFactory.newInstance;
connectorFacade.test ();
}
Methods of all connectors are called here to test and how do I selectively invoke test() selective connectors?
Hello
The connector of the ICF is called by these configurations in the 'Lookup.CONNECTOR_NAME. Research of configuration. The search name is configured in the COMPUTER resource
We have the following values configured in the search based on who the connector class fires is
Name of the connector
org.identityconnectors.CONNECTOR_NAME. Connector
Main connector class identity. It is the class that implements the SPI of the ICF framework operations.
Name of the bundle
org.identityconnectors.CONNECTOR_NAME
Name of the identity connector bundle
In Version
11.1.1.5.x
Version connector identity
-
Hi all. I am new and on a free trial right now.
How can I manage the preferences that LR do not take up space on my MAC hard drive and works only on the external hard drive?
Monthly payment included cloud storage?
Peut I manage backups? And how?
-Amir
Hi amireos,
Yes, you can create your workflow where you can keep all your images on the external hard drive and the Lightroom catalog file as well.
If you start with Lightroom and then use the Destination location as external hard drive when you import your image of the external source such as a camera or SD.
If you already have your Images on the Mac HD drive, then play all your Image on the external hard drive first and then import images directly from there.
Finally, you can change the location of the Lightroom Catalog as well.
Default location: folder on the Mac Drive HD, there is folder called Lightroom that you can move on the external drive too (however catalog Lightroom can't memory space as its only import previews of the images is not the real image and full)
Once you move the file catalog Lightroom external hard disk, then you need to browse the catalog file when you launch Lightroom only once.
See thread: LR catalog moving on external hard drive
Let us know if it helps.
Kind regards
~ Mohit
-
I'm drawing a curved line with the pen tool, but he fills in a solid form. I want only the line - what I have to change?
pmreagans,
Set the fill to zero at the bottom of the Toolbox.
-
How to select only the last child nodes in a piece of XML via XMLTABLE?
Hello
I use Oracle 10.2.0.4.
I have the following XML:
and I want to choose the last child nodes where the FruitType is Apple or pear.with sd as (select xmltype('<Fruits> <Fruit> <FruitType>Apple</FruitType> <FruitSubtype>Granny Smith</FruitSubtype> </Fruit> <Fruit> <FruitType>Pear</FruitType> <FruitSubtype>Anjou</FruitSubtype> </Fruit> <Fruit> <FruitType>Pear</FruitType> <FruitSubtype>Comice</FruitSubtype> </Fruit> <Fruit> <FruitType>Plum</FruitType> <FruitSubtype>Victoria</FruitSubtype> </Fruit> <Fruit> <FruitType>Apple</FruitType> <FruitSubtype>Bramley</FruitSubtype> </Fruit> </Fruits>') fruit_xml from dual) select * from sd;
So far, I've got:
but I just want to finish with the last child node by FruitType, for example:with sd as (select xmltype('<Fruits> <Fruit> <FruitType>Apple</FruitType> <FruitSubtype>Granny Smith</FruitSubtype> </Fruit> <Fruit> <FruitType>Pear</FruitType> <FruitSubtype>Anjou</FruitSubtype> </Fruit> <Fruit> <FruitType>Pear</FruitType> <FruitSubtype>Comice</FruitSubtype> </Fruit> <Fruit> <FruitType>Plum</FruitType> <FruitSubtype>Victoria</FruitSubtype> </Fruit> <Fruit> <FruitType>Apple</FruitType> <FruitSubtype>Bramley</FruitSubtype> </Fruit> </Fruits>') fruit_xml from dual) select x.* from sd, xmltable('//Fruits/Fruit[FruitType=''Apple'' or FruitType=''Pear'']' passing sd.fruit_xml columns fruit_type VARCHAR2(25) path '//FruitType', fruit_subtype VARCHAR2(25) path '//FruitSubtype') x; FRUIT_TYPE FRUIT_SUBTYPE ------------------------- ------------------------- Apple Granny Smith Pear Anjou Pear Comice Apple Bramley
Is it possible to do through XMLTABLE, or I have to number each of the lines that results from (what I know how to do) and then create a group to prove XMLTABLE? The latter seems awkward to me, so I'd avoid it if possible, but if this is the way to go, I can do it.FRUIT_TYPE FRUIT_SUBTYPE ------------------------- ------------------------- Pear Comice Apple Bramley
Thank you.Is it possible to do through XMLTABLE, or I have to number each of the lines that results from (what I know how to do) and then create a group to prove XMLTABLE?
Indeed, it is a possible way:
select x.fruit_type, min(fruit_subtype) keep(dense_rank last order by rn) as fruit_subtype from sd, xmltable('/Fruits/Fruit' passing sd.fruit_xml columns fruit_type VARCHAR2(25) path 'FruitType', fruit_subtype VARCHAR2(25) path 'FruitSubtype', rn for ordinality) x where fruit_type in ('Apple','Pear') group by fruit_type ;
Other options, should push the logic of consolidation in the XQuery:
select x.* from sd, xmltable('/Fruits/Fruit[FruitType="Apple"][last()] | /Fruits/Fruit[FruitType="Pear"][last()]' passing sd.fruit_xml columns fruit_type VARCHAR2(25) path 'FruitType', fruit_subtype VARCHAR2(25) path 'FruitSubtype' ) x ;
or,
select x.* from sd, xmltable('for $i in distinct-values(/Fruits/Fruit/FruitType) return /Fruits/Fruit[FruitType=$i][last()]' passing sd.fruit_xml columns fruit_type VARCHAR2(25) path 'FruitType', fruit_subtype VARCHAR2(25) path 'FruitSubtype' ) x where x.fruit_type in ('Apple','Pear') ;
or,
select x.* from sd, xmltable('/Fruits/Fruit[not(following-sibling::Fruit/FruitType=./FruitType)]' passing sd.fruit_xml columns fruit_type VARCHAR2(25) path 'FruitType', fruit_subtype VARCHAR2(25) path 'FruitSubtype' ) x where x.fruit_type in ('Apple','Pear') ;
Edited by: odie_63 APR 17. 2012 17:56 - added latest example
-
How can I get the lines for the date between 2 different days
Hi all,
How can I get the lines for the date between 2 different days.
Sample data:
Table name: Articles
Title start_date end_date
Heading1 08-22-2011 2011-09-11
2011-08-01-2011-09-01 Title2
Title 3 2011-08-21 08-21-2011
title4 2011-08-28 2011-09-11
Result will be:
Title start_date end_date
Heading1 08-22-2011 2011-09-11
2011-08-01-2011-09-01 Title2
title4 2011-08-28 2011-09-11
This is my example query:
SELECT * FROM items WHERE trunc (es.date_start) > = TO_DATE('2011-08-22', 'YYYY-MM-DD') AND trunc (es.date_end) < = TO_DATE ('2011-08-28', 'YYYY-MM-DD')
but I can not get the expected results. Any help would be much appreciated.
Thanks in advancenot read your question properly before...
Please try this
Select * FROM items
WHERE (TO_DATE ('2011-08-22', 'YYYY-MM-DD') between TRUNC (es.date_start))
AND TRUNC (es.date_end)) OR
(TO_DATE ('2011-08-28', 'YYYY-MM-DD') between TRUNC (es.date_start))
AND TRUNC (es.date_end))
Maybe you are looking for
-
I went back to play a Friday game and console XBOX360 recognize not or read a game disc. It says "Play DVD" "." -No matter what I do. I tried to go to XBOX Live Support but they have experienced a problem and the phone number and web support link ca
-
Hi, I get a blue screen with a stop error message: (0 x 001090203, 0 x 82396670, 0xc0000102, 0x00000000) can someone tell me what this means? I can't go through this screen.
-
Screen black with visible only mouse - SafeMode or normal won't start.
When I turn on my computer, all I get after the dell screen is a black screen with only the mouse visible. The mouse moves. I ran the diagnostic test Fn/F8 and everything comes back normal. I have the data I prefer not to lose. I tried normal and saf
-
Problem of sound and microphone
In my computer laptop sound is not clear. It seems like its release, mix with the wired its crunchiness. But when I use my headset works well. And also my microphone does not work. But recently it has worked well. New operating system does not instal
-
I recently bought a U450p at Costco and I love it however, it came not with the bluetooth module installed. I would find this module. I called Lenovo CS and got the part number 20001972 but can't seem to find it anywhere. Elsewhere on the forums t