Compare 2 tables and fill in the missing documents based on column
I have 3 tablesTABLEBBB
TABLEBB1 - fill in the data of TableBBB according to the conditions
TABLEBB2 - fill in the data of TableBBB according to the conditions
I need a query to fill the TABLEBB2 and the TABLEBB1 for
(1) let say if I have a query to filter on R_SQUARE_VAL = 0.51, I wish to associate myself tablebbb1 to fill out the lines of A
For example, the query below I a = 2,6,7,8,9,10,11,12,13,14
I need to fill with tableBBB1 where a = 1,3,4,5 ((cause its share of A lines starting from TABLEBBB2)
SELECT * FROM TABLEBBB2 where r_square_VAL = 0.051 order by region ,a
A PROF AVERAGE REGION YLW YEAR_RUN R_SQUARE R_SQUARE_VAL
2 87 76 1 1998 1/1/2008 0.051
6 123 254 1 1998 1/1/2008 0.051
7 76 83 1 2008 1/1/2008 0.051
8 193 245 1 1998 1/1/2008 0.051
9 168 74 1 1998 1/1/2008 0.051
10 101 74 1 1998 1/1/2008 0.051
11 254 70 1 1998 1/1/2008 0.051
12 83 89 1 1998 1/1/2008 0.051
13 80 91 1 1998 1/1/2008 0.051
14 80 77 1 1998 1/1/2008 0.051 0.051
I need to display data as belowA PROF AVERAGE REGION YLW YEAR_RUN R_SQUARE R_SQUARE_VAL
1 75 123 1 2009 1/1/2008 --TABLEBBB1
2 87 76 1 1998 1/1/2008 0.051
3 108 193 1 2009 1/1/2008 --TABLEBBB1
4 76 168 1 2009 1/1/2008 --TABLEBBB1
5 95 101 1 2009 1/1/2008 --TABLEBBB1
6 123 254 1 1998 1/1/2008 0.051
7 76 83 1 2008 1/1/2008 0.051
8 193 245 1 1998 1/1/2008 0.051
9 168 74 1 1998 1/1/2008 0.051
10 101 74 1 1998 1/1/2008 0.051
11 254 70 1 1998 1/1/2008 0.051
12 83 89 1 1998 1/1/2008 0.051
13 80 91 1 1998 1/1/2008 0.051
14 80 77 1 1998 1/1/2008 0.051 0.051
(2) let say if I have a query to filter on R_SQUARE_VAL = 0.53Then I need to display a value of tableBBB1 (cause it is not a part of the lines of A)
SELECT * FROM TABLEBBB2 where r_square_VAL = 0.053 order by region ,a
A PROF AVERAGE REGION YLW YEAR_RUN R_SQUARE R_SQUARE_VAL
15 86 123 1 1998 1/1/2008 0.053
16 101 76 1 1998 1/1/2008 0.053
17 90 72 1 1998 1/1/2008 0.053
18 93 101 1 1998 1/1/2008 0.053
19 78 92 1 1998 1/1/2008 0.053
20 84 82 1 1998 1/1/2008 0.053
21 100 77 1 1998 1/1/2008 0.053
22 140 77 1 1998 1/1/2008 0.053
23 72 72 1 1998 1/1/2008 0.053
24 101 67 1 1998 1/1/2008 0.053 0.053
Table Structure of TABLEBBB1
create table TABLEBBB1
(
A NUMBER,
PROF NUMBER,
AVERAGE NUMBER,
REGION NUMBER,
YLW VARCHAR2(4),
YEAR_RUN DATE
)
;
prompt Loading TABLEBBB1...
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (1, 75, 123, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (3, 108, 193, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (4, 76, 168, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (5, 95, 101, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (41, 74, 77, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (42, 99, 74, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (43, 76, 106, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (44, 95, 83, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (45, 123, 121, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (46, 76, 77, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (47, 193, 81, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (48, 168, 76, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (49, 101, 80, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (50, 254, 79, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (51, 83, 72, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (52, 80, 101, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
insert into TABLEBBB1 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN)
values (53, 80, 92, 1, '2009', to_date('01-01-2008', 'dd-mm-yyyy'));
commit;
TABLE OF TABLEBBB2 STRUCTUREcreate table TABLEBBB2
(
A NUMBER,
PROF NUMBER,
AVERAGE NUMBER,
REGION NUMBER,
YLW VARCHAR2(4),
YEAR_RUN DATE,
R_SQUARE NUMBER,
R_SQUARE_VAL NUMBER
)
;
prompt Loading TABLEBBB2...
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (2, 87, 76, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .051);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (6, 123, 254, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .051);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (7, 76, 83, 1, '2008', to_date('01-01-2008', 'dd-mm-yyyy'), null, .051);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (8, 193, 245, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .051);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (9, 168, 74, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .051);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (10, 101, 74, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .051);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (11, 254, 70, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .051);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (12, 83, 89, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .051);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (13, 80, 91, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .051);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (14, 80, 77, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), .051, .051);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (15, 86, 123, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .053);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (16, 101, 76, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .053);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (17, 90, 72, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .053);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (18, 93, 101, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .053);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (19, 78, 92, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .053);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (20, 84, 82, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .053);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (21, 100, 77, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .053);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (22, 140, 77, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .053);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (23, 72, 72, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .053);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (24, 101, 67, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), .053, .053);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (25, 92, 73, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .454);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (26, 82, 88, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .454);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (27, 77, 123, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .454);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (28, 77, 76, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .454);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (29, 95, 193, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .454);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (30, 89, 168, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .454);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (31, 106, 101, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .454);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (32, 128, 254, 1, '1998', to_date('01-01-2008', 'dd-mm-yyyy'), null, .454);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (33, 99, 83, 1, '2007', to_date('01-01-2008', 'dd-mm-yyyy'), null, .454);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (34, 74, 70, 1, '2007', to_date('01-01-2008', 'dd-mm-yyyy'), .454, .454);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (35, 145, 69, 1, '2007', to_date('01-01-2008', 'dd-mm-yyyy'), null, .544);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (36, 115, 72, 1, '2007', to_date('01-01-2008', 'dd-mm-yyyy'), null, .544);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (37, 65, 101, 1, '2007', to_date('01-01-2008', 'dd-mm-yyyy'), null, .544);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (38, 70, 92, 1, '2007', to_date('01-01-2008', 'dd-mm-yyyy'), null, .544);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (39, 74, 82, 1, '2007', to_date('01-01-2008', 'dd-mm-yyyy'), null, .544);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (40, 72, 77, 1, '2007', to_date('01-01-2008', 'dd-mm-yyyy'), null, .544);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (54, 86, 82, 1, '1997', to_date('01-01-2008', 'dd-mm-yyyy'), null, .544);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (55, 101, 77, 1, '1997', to_date('01-01-2008', 'dd-mm-yyyy'), null, .544);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (56, 90, 77, 1, '1997', to_date('01-01-2008', 'dd-mm-yyyy'), null, .544);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (57, 93, 89, 1, '1997', to_date('01-01-2008', 'dd-mm-yyyy'), .544, .544);
insert into TABLEBBB2 (A, PROF, AVERAGE, REGION, YLW, YEAR_RUN, R_SQUARE, R_SQUARE_VAL)
values (58, 78, 72, 1, '2008', to_date('01-01-2008', 'dd-mm-yyyy'), null, null);
commit;
Hello
It is a new requirement, in any case, assuming you want only region 1
select * from
(select t1.*, null, t2.r_square_val from tablebbb1 t1, (
select r_square_val, max_val end_val,
nvl(lag(max_val) over (order by max_val), 0) + 1 start_val
from (
select distinct r_square_val, max_val
from (
select t2.r_square_val,
max(A) keep ( dense_rank Last order by a) over (partition by r_square_val) max_val
from tablebbb2 t2 where t2.region = 1 -- added the where clause to filter region
order by a
)
)
) t2
where t1.a >=t2.start_val and t1.a<=t2.end_val
and t1.region = 1 --added the where clause to filter region
union all
select * from tablebbb2
where region=1 --added the where clause to filter region)
---where r_square_val = 0.51 (if you require to filter then put it else not required)
order by a
/
Concerning
Anurag Tibrewal
Tags: Database
Similar Questions
-
linking two fields and fill in the two field based on the list drop-down selection box 1
I work for a small social service agency VERY small non-profit and I try to get our paperwork until the twentieth century. I hope someone here can help me. I have adobe acrobat, but not of other adobe products. I converted our word document that we use for client notes in fillable pdf format and so far everyone is excited to try it. I have a huge problem that I can't understand. I have a customer named created drop-down list box that contains a list of 300 customers. Box 2 is named customer ID and will contain a unique identification code assigned to each customer.
For example:
CUSTOMER ID customer JANE DOE 12345678
So here is my question how can I ensure that when Unetelle is selected 12345678 is already filled in the second field?
I fill the drop-down list with the names of customer and then enter the customer ID as the value of exports. Note You must have a unique name for each client.
If your customer ID starts at zero, then you must use a custom JavaScript, so you can keep the zero non significant.
For the customer ID field, you can use the following custom JavaScript code:
Event.Value = this.getField("DropBoxFieldName').valueAsString;
You will need to change DropBoxFieldName name of the drop-down list.
You will need a mechanism for updating the new customer form and IDs names.
-
Fill in the missing dates with level
Think im a bad thing. I have some data that missing dates (days) and I want to just fill in the missing days with 0
This sql is to look right or I'm doing something wrong:
SELECT H.URL, H.V_DT, NVL CNT (P.CNT, 0))
SELECT CAL. URL, CAL. MIN_DATE + LEVEL AS V_DT OF)
SELECT the url, MIN (D) MIN_DATE, max (D) MAX_DATE
USER_LOG_TMP2_VW where the url is not null and current_url (select distinct URL of USER_LOG_TMP_VW)
GROUP BY URL
After MAX (D) > MIN (D)) CAL
CONNECT IN CAL. MIN_DATE + LEVEL < CAL. MAX_DATE
-GROUP BY URL, CAL. MIN_DATE + level
): LEFT JOIN USER_LOG_TMP2_VW P ON P.URL = H.URL AND F.F. = H.V_DT
There are only about 75 unique URL and when I run the present it works but I can't count because there are so many lines when it should be, perhaps a few thousand. the oldest date of min goes back only a few months.
im getting strange results. As if I add a specific url like this (below)... it works perfectly for this url. But when I go out as above where it captures all urls... it gives me weird super results. As the dates twice for duplicate URLS.
SELECT H.URL, H.V_DT, NVL CNT (P.CNT, 0))
SELECT CAL. URL, CAL. MIN_DATE + LEVEL AS V_DT OF)
SELECT the url, MIN (D) MIN_DATE, max (D) MAX_DATE
OF USER_LOG_TMP2_VW, where url is not null and current_url to (select url from USER_LOG_TMP_VW where url = 'http://testing123.com/test/test"")
GROUP BY URL
After MAX (D) > MIN (D)) CAL
CONNECT IN CAL. MIN_DATE + LEVEL < CAL. MAX_DATE
-GROUP BY URL, CAL. MIN_DATE + level
): LEFT JOIN USER_LOG_TMP2_VW P ON P.URL = H.URL AND F.F. = H.V_DT
I was not post create it for the views with her but I think that maybe im just something wrong with the level.
I tried the group according to the level of url cal.min_date +, but for some reason it just keeps running and the query never ends.
Hello
Depending on your needs and your version, you may want a CONNECT BY clause like this:
CONNECT BY LEVEL< max_date="" +="" 1="" -="">
AND PRIOR url = url
AND PRIOR SYS_GUID () IS NOT NULL
-
my pc runs research and fills in the forms she self... who runs it?
My pc runs research and fills in the forms by itself. I did al worm and Trojan research...
Hi geddus,
1. what research program do you use?
2. what security software is installed on your computer?
(a) I recommend you run a virus scan online from the link given below and check if the problem persists.
Also, make sure that you have the latest update of the software antivirus installed on your computer, so that it works correctly.
(b) you can also download & run Microsoft Security Essentials on your computer.
Hope the helps of information.
Please post back and we do know. -
Can I define the contour of an object to be on top / face and filling on the bottom / back? I've asked this question before and told to go to the appearance and drag the background and outline around as if they were a layer, but this did not bring my race to the top of the image. I did this wrong somehow, or is there another method?
I was just thinking ' didn't I said this the other day... ". "in any case...
This is an object with a dark gray line and a red fill. the race is in front of the filling. any random object that you draw will be the race before filling unless you tell her not to be. You can say that the race is forwards here because it extends also on each side of the framework encompassing:
Here, the situation is reversed. Note the appearance palette. You can fill is in the front because it now covers half of the race which extends inside the frame enclosing:
If this is not the behavior you're seeing, it's time to refer to the list of Jacob.
-
I installed 5.6.2 Pages but all my old documents will open with ' 08 v.3.03 How can I remove the Pages ' 08 and update all the old documents
5 pages is located in your Applications folder.
Pages ' 08 is located in your Applications/iWork ' 08 folder.
If you open your old documents Pages ' 08 with 5 Pages it will convert and if not damage, remove a large number of useful features.
You will probably regret upgrading to 5 Pages which Apple has made extremely inconsistent and keeps changing its file format.
Peter
-
compare two tables and update the differences
Hi all
Sorry for the newbie question, but I am a beginner in the present.
I have two tables, both have same structure-
CODE - code NUMBER (6,0) store is the primary key does not change and is unique
ADDRESS1
ADDRESS2
ADDRESS3 - all VARCHAR2 (100)
One of the tables is named MASTER, the other being updated. MASTER contains hundreds of lines, while the table of UPDATES may have anywhere from zero to 10 or more.
I want to compare the table of UPDATES against the MASTER of the table and if there is a difference, ask the differences in the table in UPDATES to the MASTER of table - so if the address of an Exchange store, then the change is reflected in the MASTER table by crushing with the data contained in the UPDATES table.
I thought that maybe using sliders and compare each field but there must be a more efficient way.
I hope that I have explained quite clearly... any help would be greatly appreciated.
Thank you
BillEducation MERGE, assuming that your version supports supported the MERGER.
SY.
-
I want to compare two tables and out a boolean
This should be simple. I want to compare two tables (5 items) and return a single Boolean value (T/F), not an array of Boolean.
Thank you
Kevin
Right click on the comparison, the comparison mode, select compare the aggregates.
-
Question to load data using sql loader in staging table, and then in the main tables!
Hello
I'm trying to load data into our main database table using SQL LOADER. data will be provided in separate pipes csv files.
I have develop a shell script to load the data and it works fine except one thing.
Here are the details of a data to re-create the problem.
Staging of the structure of the table in which data will be filled using sql loader
create table stg_cmts_data (cmts_token varchar2 (30), CMTS_IP varchar2 (20));
create table stg_link_data (dhcp_token varchar2 (30), cmts_to_add varchar2 (200));
create table stg_dhcp_data (dhcp_token varchar2 (30), DHCP_IP varchar2 (20));
DATA in the csv file-
for stg_cmts_data-
cmts_map_03092015_1.csv
WNLB-CMTS-01-1. 10.15.0.1
WNLB-CMTS-02-2 | 10.15.16.1
WNLB-CMTS-03-3. 10.15.48.1
WNLB-CMTS-04-4. 10.15.80.1
WNLB-CMTS-05-5. 10.15.96.1
for stg_dhcp_data-
dhcp_map_03092015_1.csv
DHCP-1-1-1. 10.25.23.10, 25.26.14.01
DHCP-1-1-2. 56.25.111.25, 100.25.2.01
DHCP-1-1-3. 25.255.3.01, 89.20.147.258
DHCP-1-1-4. 10.25.26.36, 200.32.58.69
DHCP-1-1-5 | 80.25.47.369, 60.258.14.10
for stg_link_data
cmts_dhcp_link_map_0309151623_1.csv
DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2
DHCP-1-1-2. WNLB-CMTS-03-3,WNLB-CMTS-04-4,WNLB-CMTS-05-5
DHCP-1-1-3. WNLB-CMTS-01-1
DHCP-1-1-4. WNLB-CMTS-05-8,WNLB-CMTS-05-6,WNLB-CMTS-05-0,WNLB-CMTS-03-3
DHCP-1-1-5 | WNLB-CMTS-02-2,WNLB-CMTS-04-4,WNLB-CMTS-05-7
WNLB-DHCP-1-13 | WNLB-CMTS-02-2
Now, after loading these data in the staging of table I have to fill the main database table
create table subntwk (subntwk_nm varchar2 (20), subntwk_ip varchar2 (30));
create table link (link_nm varchar2 (50));
SQL scripts that I created to load data is like.
coil load_cmts.log
Set serveroutput on
DECLARE
CURSOR c_stg_cmts IS SELECT *.
OF stg_cmts_data;
TYPE t_stg_cmts IS TABLE OF stg_cmts_data % ROWTYPE INDEX BY pls_integer;
l_stg_cmts t_stg_cmts;
l_cmts_cnt NUMBER;
l_cnt NUMBER;
NUMBER of l_cnt_1;
BEGIN
OPEN c_stg_cmts.
Get the c_stg_cmts COLLECT in BULK IN l_stg_cmts;
BECAUSE me IN l_stg_cmts. FIRST... l_stg_cmts. LAST
LOOP
SELECT COUNT (1)
IN l_cmts_cnt
OF subntwk
WHERE subntwk_nm = l_stg_cmts (i) .cmts_token;
IF l_cmts_cnt < 1 THEN
INSERT
IN SUBNTWK
(
subntwk_nm
)
VALUES
(
l_stg_cmts (i) .cmts_token
);
DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_cmts (i) .cmts_token);
ON THE OTHER
DBMS_OUTPUT. Put_line ("token is already present'");
END IF;
WHEN l_stg_cmts EXIT. COUNT = 0;
END LOOP;
commit;
EXCEPTION
WHILE OTHERS THEN
Dbms_output.put_line ('ERROR' |) SQLERRM);
END;
/
output
for dhcp
coil load_dhcp.log
Set serveroutput on
DECLARE
CURSOR c_stg_dhcp IS SELECT *.
OF stg_dhcp_data;
TYPE t_stg_dhcp IS TABLE OF stg_dhcp_data % ROWTYPE INDEX BY pls_integer;
l_stg_dhcp t_stg_dhcp;
l_dhcp_cnt NUMBER;
l_cnt NUMBER;
NUMBER of l_cnt_1;
BEGIN
OPEN c_stg_dhcp.
Get the c_stg_dhcp COLLECT in BULK IN l_stg_dhcp;
BECAUSE me IN l_stg_dhcp. FIRST... l_stg_dhcp. LAST
LOOP
SELECT COUNT (1)
IN l_dhcp_cnt
OF subntwk
WHERE subntwk_nm = l_stg_dhcp (i) .dhcp_token;
IF l_dhcp_cnt < 1 THEN
INSERT
IN SUBNTWK
(
subntwk_nm
)
VALUES
(
l_stg_dhcp (i) .dhcp_token
);
DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_dhcp (i) .dhcp_token);
ON THE OTHER
DBMS_OUTPUT. Put_line ("token is already present'");
END IF;
WHEN l_stg_dhcp EXIT. COUNT = 0;
END LOOP;
commit;
EXCEPTION
WHILE OTHERS THEN
Dbms_output.put_line ('ERROR' |) SQLERRM);
END;
/
output
for link -.
coil load_link.log
Set serveroutput on
DECLARE
l_cmts_1 VARCHAR2 (4000 CHAR);
l_cmts_add VARCHAR2 (200 CHAR);
l_dhcp_cnt NUMBER;
l_cmts_cnt NUMBER;
l_link_cnt NUMBER;
l_add_link_nm VARCHAR2 (200 CHAR);
BEGIN
FOR (IN) r
SELECT dhcp_token, cmts_to_add | ',' cmts_add
OF stg_link_data
)
LOOP
l_cmts_1: = r.cmts_add;
l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));
SELECT COUNT (1)
IN l_dhcp_cnt
OF subntwk
WHERE subntwk_nm = r.dhcp_token;
IF l_dhcp_cnt = 0 THEN
DBMS_OUTPUT. Put_line ("device not found: ' |") r.dhcp_token);
ON THE OTHER
While l_cmts_add IS NOT NULL
LOOP
l_add_link_nm: = r.dhcp_token |' _TO_' | l_cmts_add;
SELECT COUNT (1)
IN l_cmts_cnt
OF subntwk
WHERE subntwk_nm = TRIM (l_cmts_add);
SELECT COUNT (1)
IN l_link_cnt
LINK
WHERE link_nm = l_add_link_nm;
IF l_cmts_cnt > 0 AND l_link_cnt = 0 THEN
INSERT INTO link (link_nm)
VALUES (l_add_link_nm);
DBMS_OUTPUT. Put_line (l_add_link_nm |) » '||' Has been added. ") ;
ELSIF l_link_cnt > 0 THEN
DBMS_OUTPUT. Put_line (' link is already present: ' | l_add_link_nm);
ELSIF l_cmts_cnt = 0 then
DBMS_OUTPUT. Put_line (' no. CMTS FOUND for device to create the link: ' | l_cmts_add);
END IF;
l_cmts_1: = TRIM (SUBSTR (l_cmts_1, INSTR (l_cmts_1, ',') + 1));
l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));
END LOOP;
END IF;
END LOOP;
COMMIT;
EXCEPTION
WHILE OTHERS THEN
Dbms_output.put_line ('ERROR' |) SQLERRM);
END;
/
output
control files -
DOWNLOAD THE DATA
INFILE 'cmts_data.csv '.
ADD
IN THE STG_CMTS_DATA TABLE
When (cmts_token! = ") AND (cmts_token! = 'NULL') AND (cmts_token! = 'null')
and (cmts_ip! = ") AND (cmts_ip! = 'NULL') AND (cmts_ip! = 'null')
FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "
TRAILING NULLCOLS
('RTRIM (LTRIM (:cmts_token))' cmts_token,
cmts_ip ' RTRIM (LTRIM(:cmts_ip)) ")". "
for dhcp.
DOWNLOAD THE DATA
INFILE 'dhcp_data.csv '.
ADD
IN THE STG_DHCP_DATA TABLE
When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')
and (dhcp_ip! = ") AND (dhcp_ip! = 'NULL') AND (dhcp_ip! = 'null')
FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "
TRAILING NULLCOLS
('RTRIM (LTRIM (:dhcp_token))' dhcp_token,
dhcp_ip ' RTRIM (LTRIM(:dhcp_ip)) ")". "
for link -.
DOWNLOAD THE DATA
INFILE 'link_data.csv '.
ADD
IN THE STG_LINK_DATA TABLE
When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')
and (cmts_to_add! = ") AND (cmts_to_add! = 'NULL') AND (cmts_to_add! = 'null')
FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "
TRAILING NULLCOLS
('RTRIM (LTRIM (:dhcp_token))' dhcp_token,
cmts_to_add TANK (4000) RTRIM (LTRIM(:cmts_to_add)) ")" ""
SHELL SCRIPT-
If [!-d / log]
then
Mkdir log
FI
If [!-d / finished]
then
mkdir makes
FI
If [!-d / bad]
then
bad mkdir
FI
nohup time sqlldr username/password@SID CONTROL = load_cmts_data.ctl LOG = log/ldr_cmts_data.log = log/ldr_cmts_data.bad DISCARD log/ldr_cmts_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &
nohup time username/password@SID @load_cmts.sql
nohup time sqlldr username/password@SID CONTROL = load_dhcp_data.ctl LOG = log/ldr_dhcp_data.log = log/ldr_dhcp_data.bad DISCARD log/ldr_dhcp_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &
time nohup sqlplus username/password@SID @load_dhcp.sql
nohup time sqlldr username/password@SID CONTROL = load_link_data.ctl LOG = log/ldr_link_data.log = log/ldr_link_data.bad DISCARD log/ldr_link_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &
time nohup sqlplus username/password@SID @load_link.sql
MV *.log. / log
If the problem I encounter is here for loading data in the link table that I check if DHCP is present in the subntwk table, then continue to another mistake of the newspaper. If CMTS then left create link to another error in the newspaper.
Now that we can here multiple CMTS are associated with unique DHCP.
So here in the table links to create the link, but for the last iteration of the loop, where I get separated by commas separate CMTS table stg_link_data it gives me log as not found CMTS.
for example
DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2
Here, I guess to link the dhcp-1-1-1 with balancing-CMTS-01-1 and wnlb-CMTS-02-2
Theses all the data present in the subntwk table, but still it gives me journal wnlb-CMTS-02-2 could not be FOUND, but we have already loaded into the subntwk table.
same thing is happening with all the CMTS table stg_link_data who are in the last (I think here you got what I'm trying to explain).
But when I run the SQL scripts in the SQL Developer separately then it inserts all valid links in the table of links.
Here, she should create 9 lines in the table of links, whereas now he creates only 5 rows.
I use COMMIT in my script also but it only does not help me.
Run these scripts in your machine let me know if you also get the same behavior I get.
and please give me a solution I tried many thing from yesterday, but it's always the same.
It is the table of link log
link is already present: dhcp-1-1-1_TO_wnlb-cmts-01-1 NOT FOUND CMTS for device to create the link: wnlb-CMTS-02-2
link is already present: dhcp-1-1-2_TO_wnlb-cmts-03-3 link is already present: dhcp-1-1-2_TO_wnlb-cmts-04-4 NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-5
NOT FOUND CMTS for device to create the link: wnlb-CMTS-01-1
NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-8 NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-6 NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-0 NOT FOUND CMTS for device to create the link: wnlb-CMTS-03-3
link is already present: dhcp-1-1-5_TO_wnlb-cmts-02-2 link is already present: dhcp-1-1-5_TO_wnlb-cmts-04-4 NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-7
Device not found: wnlb-dhcp-1-13 IF NEED MORE INFORMATION PLEASE LET ME KNOW
Thank you
I felt later in the night that during the loading in the staging table using UNIX machine he created the new line for each line. That is why the last CMTS is not found, for this I use the UNIX 2 BACK conversion and it starts to work perfectly.
It was the dos2unix error!
Thank you all for your interest and I may learn new things, as I have almost 10 months of experience in (PLSQL, SQL)
-
Find the missing documents and insert accordingly
Oracle version: Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
Hello gurus
I'm really grateful if someone would help out me. Thanks in advance
Examples of data
Drop, the creating and inserting in tables
drop table TYPE_MST;
drop table TYPE_VERSION;-------------------------
Create Tables:create the table TYPE_MST
(
Type_desc varchar2 (15)
);-----------------
Table insert
insert into TYPE_MST
(
Select 'First' double
Union of all the
Select 'Second' double
Union of all the
Select 'Third' double
);--------
create the table TYPE_VERSION
(
TYPE_DESC varchar2 (15).
MIN_AGE number (5),
MAX_AGE number (5),
VERSION_ID number (5)
);
---------
insert into TYPE_VERSION
(
Select 'First', 0, 5, 100 double
Union of all the
Select 'First', 5, 10, 100 double
Union of all the
Select 'First', 11,15, 100 double
);---------
Queries against existing data
Select * from TYPE_VERSION;The query result
TYPE_DESC, MIN_AGE, MAX_AGE, VERSION_ID
First 0 5 100
First 5 10 100
First 11 15 100
My requirement is that system automatically inserts type_desc missing in TYPE_VERSION.
For example, we have 3 Type_Desc, first, second, third, but in the TYPE_VERSION table, we have data available for only 1 Type_Desc who is "First", this system should insert the missing data in this table using existing data.
I need result something like below:
Required result
TYPE_DESC, MIN_AGE, MAX_AGE, VERSION_ID
First 0 5 100
First 5 10 100
First 11 15 100
Second 11 15 100
Second 5 10 100
Second 11 15 100
Third 0 5 100
Third 5 10 100
Third 11 15 100
Thanks in advance
Concerning
Shu
Hello
It is still not clear what you want.
That's what you want for the examples you gave:
MERGE INTO dst type_version
WITH THE HELP OF)
SELECT DISTINCT
m.type_desc
v.min_age, v.max_age, v.version_id
OF type_mst m
CROSS JOIN type_version v
) src
WE (dst.type_desc = src.type_desc
AND dst.min_age = SRC. MIN_AGE
)
WHEN NOT MATCHED THEN INSERT
(dst.min_age, dst.max_age, dst.type_desc, dst.version_id)
VALUES (src.min_age, src.max_age, src.type_desc, src.version_id)
;
If she's going to do what you want in general depends on what you want in general. As long as I don't know the General rules you want to set up, I don't know if it makes them or not.
This does not seem a very good design. Why do you need a table with all possible combinations? Sounds like you're saying, for example, if 2 lines have the same value of min_age, then have the same values for max_age and version_id, too. This 3rd Normal violares form. Why not have a table with the possible values for min_age max_age version_id, and simply join cross which type_mst when you need to see all possible combinations?
-
How to compare two TABLES and different lines of list?
I have two structural equal paintings aaa and bbb
that (could) have different lines.
How can I compare the tables and display different lines?
PeterSomething like this->
SELECT aaa.*,'bbb' "Not present in" FROM aaa MINUS SELECT bbb.*,'bbb' "Not present in" FROM bbb UNION ALL ( SELECT bbb.*,'aaa' "Not present in" FROM bbb MINUS SELECT aaa.*,'aaa' "Not present in" FROM aaa )
Kind regards.
LOULOU.
-
Page with ADF Table and form of the ADF, error: a value is required on CreateInsert
Dear all,
I am a beginner in the ADF and am under Jdeveloper Studio Edition Version 12.2.1.0.0.
I have a page that consists of two taskflows.
First workflow has a fragment which is to have a (non editable) table - top in picture below
Second task flow contains a form ADF - lower part in image below.
Click Add button again the below the screen with "error: a value is required appears.
and also a nonmodifiable line Table is created.
The code for the button "new".
< af:button text = 'New' id = 'bAddNew '.
actionListener="#{pageFlowScope.SalespersonsMainFMT.createInsertSalespersons}"/ >
Here is the part referencing of java Bean
public static BindingContainer {} getBindings()
Return BindingContext.getCurrent () .getCurrentBindingsEntry ();
}
public void createInsertSalespersons (ActionEvent actionEvent) {}
BindingContainer links = getBindings();
OperationBinding operationBinding;
operationBinding = bindings.getOperationBinding ("CreateInsert") (OperationBinding);
Object result = operationBinding.execute ();
}
Please let me know what I have to do to stop the insertion of new line in a Table cannot be changed
and then stop the ' error: a value is required is displayed ' message.
Hope the above is clear.
Please let me know if additional information is required.
Thanks and greetings
Arif Khadas
Instead of CreateInsert, try to use Create and let me know what happens.
Another option is to set the ChangeEventPolicy for the iterator binding votes to zero, and af:table; s immediate to false, as shown here:
http://rogersuen.blogspot.RS/2014/03/ADF-editable-table-unexpected-validation.html
-
Cannot change order of stroke and fill to the text
In Illustrator CC, I have a text with background colors and contour, and I hang outside the text, not half-n-half. From what I can read (for example Why can't fix us a line of text to the outside (as in InDesign) without having to first convert them into text vectorized?), the way to do that is in the appearance Panel, dragging filling to the top or the race down. But they don't change places when I try - I drag, but nothing changes. And in the Panel advanced stroke, the second and third options to align the lines appear dimmed.
If I saw the text, then all the choices to align the shots are allowed, but I prefer to do it with the living text. Is this possible?
It should work as follows:
-
How do you change the color of the text sign and fill in the color blue
How do you change the color of the text sign and fill it with the color blue in a pdf document
The color of the text of fill & sign is black and at the moment is not able to be changed.
Thank you
Josh
-
Audit Table and triggers for the object table 10g
Hello
I am trying to create an audit table and related triggers based on a table of objects.
I have a table called payruns.
created by this statement:
CREATE TABLE payruns to payrun_o;
I intend on creating a table of audit created by statement payruns_audit
CREATE TABLE payruns_audit)
payrun_old PAYRUN_O NOT NULL,
action VARCHAR2 (1).
default user user_resp VARCHAR2 (32) NOT NULL,
action_date date default sysdate NOT NULL);
A trigger is needed to maintain the tabel of audit update
The trigger code would be something like:
CREATE OR REPLACE TRIGGER payruns_br_ud
FRONT
INSERT OR UPDATE ON payruns FOR EACH ROW
DECLARE
lv_old_payrun payrun_o;
lv_action VARCHAR2 (1);
BEGIN
If the insertion
lv_action: = 'I ';
on the other
lv_action: = 'U ';
end if;
SELECT: old.value (pr)
IN lv_old_payrun
OF payruns pr
WHERE pr.pr_id =: old.pr_id;
INSERT INTO payruns_audit (payrun_old,
action,
user_resp,
action_date)
VALUES (lv_old_payrun,
lv_action,
user,
SYSDATE);
END;
However: old.value does not work.
Could you tell me about the correct syntax.
Thank you!Hi Alistair - try to use OBJECT_VALUE.
CREATE TABLE payruns_audit)
payrun_old PAYRUN_O NOT NULL,
payrun_new PAYRUN_O NOT NULL,
action VARCHAR2 (1).
default user user_resp VARCHAR2 (32) NOT NULL,
action_date date default sysdate NOT NULL);CREATE OR REPLACE TRIGGER payruns_after_ud
AFTER the update on payruns
FOR EACH LINE
DECLARE
lv_action VARCHAR2 (1);
BEGIN
IF the insertion and THEN lv_action: = 'I ';
ANOTHER lv_action: = 'U ';
END IF;INSERT INTO payruns_audit (payrun_old, payrun_new, action, user_resp, action_date)
VALUES (: OLD.) OBJECT_VALUE,: NEW. OBJECT_VALUE, lv_action, USER, SYSDATE);
END payruns_after_ud;Cheers, Shane.
Maybe you are looking for
-
Hey,. Spoiler (Highlight to read) Spoiler (Highlight to read) When I'm about to print something and the preferences window appears it displays my printer being designated as "copy1". Although my printer functions, I fear that it may affect the ov
-
Where can I find a display for Satellite A135-S4527
my screen is broken and is out of warranty. where can I find a screen? a new or a used one. Thank you
-
PC will not let me install update hp drivers
Hi all, have a hp presario s1610nx / / 3200 and updated to a 2.4 processor, works very well, whenever I try to update bio or drivers chipset I get the message that I must be an administrator, the pc has listed me as an administrator but that is not l
-
I'll try to be complete, I'm quite technically competent in implementing network and equipment and have been working on this for over a week. HP Pavilion under Vista SP2 desktop computer. 2x2gb sticks of RAM. PC a friend, apparently blue screened dur
-
WRT310N v1 DHCP client fails to renew the lease
I have a Linksys WRT310N v1 with firmware build 002 v1.0.10 July 19, 2010 My router is unable to renew its lease DHCP from my cable provider, causing an internet access to drop. I can still access my modem cable to 192.168.100.1, but I have to do a '