Comparison between two tables
Hello
I have two tables USERS and LISTS:
And I want that there is a comparison between these two tables executed when user table USERS connect to the application.
They must compare the columns between the SEXES and AGE and if some users have the same attributes in its ranks as in a line in the table LISTS (here is unique each line) so that the user gets in his line in the column 'LIST_ID' the ID of the line with which attributes between GENDER and AGE.
Example:
USERS TABLE: exampleuser | Boby | McGrahem | Male | 18. -------
LISTS OF TABLE: 28 | examplelist | Male | 18
Once the Login of the user Boby gets in its ranks the ID = 28 because the SEX and AGE corresponds to the row of table LIST:
Result:
USERS TABLE: exampleuser | Boby | McGrahem | Male | 18. 28
CREATE TABLE "USERS" ( "USERNAME" VARCHAR2(15) NOT NULL ENABLE, "FORRNAME" VARCHAR2(15) NOT NULL ENABLE, "SURNAME" VARCHAR2(15) NOT NULL ENABLE, "GENDER" VARCHAR2(10) NOT NULL ENABLE, "AGE" NUMBER, "LIST_ID" NUMBER, CONSTRAINT " USERS_PK" PRIMARY KEY ("USERNAME") USING INDEX ENABLE
CREATE TABLE "LISTS" ( " LIST_ID" NUMBER NOT NULL ENABLE, " LISTNAME" VARCHAR2(50) NOT NULL ENABLE, "GENDER" VARCHAR2(10) NOT NULL ENABLE, "AGE" VARCHAR2(3) NOT NULL ENABLE, CONSTRAINT " LISTS_PK" PRIMARY KEY ("LIST_ID") USING INDEX ENABLE
I need help for coding this, if someone be so good.
This is my essay:
DECLARE v_listid varchar2(100); BEGIN SELECT LIST_ID into v_listgid FROM LISTS WHERE GENDER = (SELECT GENDER FROM USERS WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER))) AND AGE = (SELECT AGE FROM USERS WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER))); UPDATE USERS SET LIST_ID = v_listid WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER)); END;
I'd like to REALLY shy away using the USER name as the primary key, because the fact that users can create duplicate user names... YOU should NEVER base a PK on the entry of user, the better to let the database create and maintain this element of date...
FIX:
UPDATE to users U
SET List_Id = (SELECT List_Id OF lists L WHERE L.Gender = U.Gender and L.SOMENUMBER = U.SOMENUMBER) AND
Upper (U.UserName) = UPPER(:APP_USER);
Don't really want to cut the strings, Oracle which will do since they are of type varchar2 columns...
Thank you
Tony Miller
Software LuvMuffin
Ruckersville, WILL
Tags: Database
Similar Questions
-
I got a prob while creating a link/link between two tables in a jdeveloper11g
Hi guys...
I got a prob while creating a link/link between two tables in a jdeveloper11g, help me.
I use two table employee, Department.
Unfortunately there is no primary key and foreign key in these tables.now i updated on those of table structure.
I want to create a form like it should be a link between the Department data, i.e. data and employee while the Department is changed then only present corresponding employees in this block...
Table structure as follows
Employee:
-------------------
employe_id,
name,
Department,
GR,
Date of birth
Department of justice
Department:
--------------------
department_id,
department_name;
Note: in the employee department table is the same as in the department table department_id...
So, you want to build master / detail between Department & sub_departments?
In the same way, create a new, yet another link between departments & sub_departments, so that the connection is:
Department.Department_Id = sub_departments.department_id
-
I need to implement Drag N Drop between two tables that saves the two records
I need to implement Drag N Drop between two tables that saves the two records on a third page, using drag 'n drop.Check out this video http://baigsorcl.blogspot.com/2011/01/drag-and-drop-collection-in-oracle-adf.html
-
two relationships between two tables
Hi all
I created a cube in my db (using OWB) of two relationships to my time dimension. A relationship shows the start time of a process, that the other represents the date of termination or end.
example of the cube:
Fact1
Fact2
Dim_Time1
Dim_Time2
where Dim_time1 and Dim_Time2 link to the same dimension.
Unfortunately I have trouble this manually import in obiee administrator. I imported the fact table and the dimension of the physical layer table. Can I move to the business layer and create the two joins between two tables. But the overall consistency check up a mistake, I shouldn't have two relationships between two tables and remove a foreign key.
What I am doing wrong?
Kind regards
KnutKnut,
In your example, you should have a time dimension in the phyiscal layer and alias of this 2 x, for Dim_time1 and for Dim_time2, in this way aliases are separate tables as the BI server point of view and you define releations separate on the same table, you can define specific to each alias dim relevant time joins.
In this way, you will have two time decreases intensity in MDB layer also, has 'Dim-Start Time' and a ' Sun - term time "or similar.
Hope this helps,
Alastair -
Use a where clause clause if there is a relationship between two tables
Is it possible to use a where clause clause if there is a relationship between two tables.
I have a relationship between two tables:
And a.customer = b.customer (+)
If b.customer exists in a.customer I would add this in where clause
And b.info = 'X '.
But how?It's the outer joins by chance?
If so, why not just:
and b.customer(+) = a.customer and b.info(+) = 'X'
BTW, I put the two "b" on the left column to make it easier to read. Some people mix that makes me crazy, but makes no difference to the query.
-
How to remove the extra space between two Table HTML
Hello
I wrote a code for printing costs. But there is more space between two Table Html, how I can remove it.
Please run that Code
Start
HTP.p (')
< html >
(< body > ');
HTP.p (')
< TABLE align = "left" width = "500" cellspacing = "0" cellpadding = "0" border = "1" >
< tr > < td align = 'right' white-space: nowrap; > Ph-2201751 < table >
< td > < table >
< /tr >
< tr > < td align = "center" white-space: nowrap; > < B > < table > < /B > SATYAM MODERN PUBLIC SCHOOL
< td > < table >
< /tr >
< b >
< td align = "center" white-space: nowrap; > < i > < H3 > (AFFILIATED to THE CBSC, NEW DELHI CODE No. 53544) < / H3 > < /I > < table >
< td > < table >
< /tr >
< tr > < td align = "center" white-space: nowrap; > new colony Braham, - 131001 (h) < table >
< td > < table >
< /tr >
< tr > < td align = "center" white-space: nowrap; > RECEPTION COSTS < table >
< td > < table >
< /tr >
< /table >
< TABLE width = "500" cellspacing = "0" cellpadding = "0" border = "1" >
< b >
< td width = "100" white-space: nowrap; > receipt no.: < table >
< td width = "100" white-space: nowrap; > Date received: < table >
< /tr >
< b >
< td width = "100" white-space: nowrap; > name: < table >
< td width = "100" white-space: nowrap; > father name: < table >
< /tr >
< b >
< td width = "100" white-space: nowrap; > class & s: < table >
< td width = "100" white-space: nowrap; > A/C No. : < table >
< /tr >
< b >
< td width = "100" white-space: nowrap; > from: < table >
< td width = "100" white-space: nowrap; > to: < table >
< /tr >
(< /table > ');
HTP.p (')
< / body >
(< / html > ');
end;
Thank you
EdHello
HTML is valid, that your code print?
Wouldn't be as below?
BR, Jari
Published by: jarola on December 18, 2009 15:22
I test your code
http://Apex.Oracle.com/pls/OTN/f?p=40323:25
I can't see any extra space between the tablesThe most elegant way to get the difference between two tables - not least!
Hello
Simplified example of what I'm trying to achieve - I have two tables ORIGINAL and REVISED.
My aim is to compare the two, such as; -
When there is data in the two tables I get the difference between the Budget column, and if there is no difference, so I don't want no lines.
When data exists in the ORIGINAL, but not in review, I want to the inverse of the current value of the Budget column.
Where the data exist in REVISED I want the REVISED value.
I can see how I can do this, see below, but is there a more elegant solution?
Data for the ORIGINAL table
Data for the REVISED tableselect '801040' entity, '2186' expense_type, 234000 budget from dual union all select '801040' entity, '3001' expense_type, 1000 budget from dual union all select '801040' entity, 'P132' expense_type, 34000 budget from dual union all select '801040' entity, 'P135' expense_type, 43000 budget from dual
Desired outputselect '801040' entity, '2186' expense_type, 235000 budget from dual union all select '801040' entity, 'P132' expense_type, 34000 budget from dual union all select '801040' entity, 'P139' expense_type, 56000 budget from dual
ENTITY EXPENSE_TYPE DIFFERENCE
------ ------------ ----------
801040 2186 1000
801040 3001-1000
801040 P135-43000
801040 P139 56000
5 selected lines.
Code current to achieve this, is there a better way?
Thanks a lot for your comments,.select original.entity , original.expense_type , (nvl(revised.budget,0) - original.budget) as difference from original , revised where original.entity = revised.entity(+) and original.expense_type = revised.expense_type(+) and (nvl(revised.budget,0) - original.budget) != 0 union all select revised.entity , revised.expense_type , revised.budget as difference from revised where not exists (select 'x' from original where original.entity = revised.entity and original.expense_type = revised.expense_type) and revised.budget != 0
Robert.
Published by: Robert Angel on January 17, 2012 03:31 to change is not equal to! = - Thanks for the heads upSQL> with original 2 as 3 ( 4 select '801040' entity, '2186' expense_type, 234000 budget 5 from dual 6 union all 7 select '801040' entity, '3001' expense_type, 1000 budget 8 from dual 9 union all 10 select '801040' entity, 'P132' expense_type, 34000 budget 11 from dual 12 union all 13 select '801040' entity, 'P135' expense_type, 43000 budget 14 from dual 15 ) 16 , revised 17 as 18 ( 19 select '801040' entity, '2186' expense_type, 235000 budget 20 from dual 21 union all 22 select '801040' entity, 'P132' expense_type, 34000 budget 23 from dual 24 union all 25 select '801040' entity, 'P139' expense_type, 56000 budget 26 from dual 27 ) 28 select * 29 from ( 30 select nvl(o.entity, r.entity) entity, 31 nvl(o.expense_type, r.expense_type) expense_type, 32 nvl(r.budget,0) - nvl(o.budget,0) budget 33 from original o 34 full join revised r 35 on o.entity = r.entity 36 and o.expense_type = r.expense_type 37 ) 38 where budget <> 0 39 / ENTITY EXPE BUDGET ------ ---- ---------- 801040 2186 1000 801040 P135 -43000 801040 3001 -1000 801040 P139 56000 SQL>
getting data between two tables
Hi everyone, I need help with a query that seems simple, but I can't understand. consider the following data.
with data as (
s élire 802 cd from dual union all
select 803 cd from dual union all
select 804 cd from dual
data2 as
( select 804 cd from dual )
I want to join the two tables so that the result will be as follows:
in the above data, we can see that 804 is common in both tables. in this case, the output should be 804.
Similarly, if 2 data include the following:
data2 as
( select 804 cd from dual union all
Select 803 cd from dual
)
the output is then 803 804.
Now consider the following data
with data as (
s élire 802 cd from dual union all
select 803 cd from dual union all
select 804 cd from dual
)
take data2 table is empty
I want to join the two tables, and in this case, the output should be 802,803,804. data2 table is empty, then the default behavior is to get all the data in the data table. Since there is no line that corresponds to rows in the data table,
the default behavior is to display output all data in the data table. in this case 802,803,804
can someone write a query for this?
Hello
elmasduro wrote:
Hi Frank, thanks for the request. These are very good questions. Here are the answers
What happens if data2 rows, but none of them match data CD?
It won't happen because the integrity of the data.
...
I see it; a data line 2 will be in the data. You have a FOREIGN KEY constraint, or something similar, so if cd = 804 exists in database2, then it must also exist in the data.
What happens if the data is empty and data2 is not?
If data is empty and data2 is not, then the data2 data should be released.
for example
with the data as)
data table is empty
data2 as
(select cd 804 Union double all the)
Select cd 805 double
)
When you join data and data2 account with the above data, then the output should be 804 805. data2 data should be the display if the data table is empty. ...
Doesn't that contradict what you said earlier? Previously, it seemed to say that each row of data2 will be in the data, but now you give an example where all data2 lines are not in the data.
If the first is true, then the solution in response #2 should work.
If the latter is true, you can change the query like this:
WITH got_r_num AS
(
SELECT NVL (d.cd, d2.cd) AS cd
DENSE_RANK () (ORDER IN CASE
WHEN d.cd IS NOT NULL
AND d2.cd IS NOT NULL
THEN "A".
WHEN d.cd IS NOT NULL
THEN 'B '.
ANOTHER 'C '.
END
) AS r_num
DATA d
FULL OUTER JOIN data2 d2 ON d.cd = d2.cd
)
SELECT cd
OF got_r_num
WHERE r_num = 1
ORDER BY cd
;
Difference between two tables (ORA-01722)
I am trying to get the difference of two tables on two databases.
Walker I run the script below, it gives me a result that is not accurate.
Select name, creation_time of v$datafile@REMOTE_database.com
However, when I run this script, I get an accurate count of the difference. How can I list the exact number instead of only to count the difference? Want lists all five name missing on table 2.
2 LESS THAN
3 select name, creation_time from v$ datafile;
I get 14 ranks of foregoing.
SQL > SELECT a.cnt - b.cnt
> count 2 (name) select cnt (of v$datafile@REMOTE_database.com) a, b3 (select count (name) NTC v$ datafile);
edited by: Albert Zaza on July 19, 2010 11:19
A.CNT - B. CNT
-----------
5have you tried:
select trim(upper(name)) from v$datafile@REMOTE_database.com MINUS select trim(upper(name)) from v$datafile;
Hello
I am a beginner absolut for LabView and I learned LV tutorials, but I have a question and need your help.
I have two digital inputs and one digital output and I want to output for example as many entries. What I need is how to compare two entry and decide for one of them.
When I use a comparison operator as equal or smaller, I get a Boolean result but not a numeric. How can I use this to get for example the bigger or smaller?
Thank you
Oliver
For example, you can use your superior decide who is actually higher then select this one through a structure of matter or a Select who will send you one to forward more great.
That functionality is already attached to the Min/Max function, check it out.
/Y
Left join between two tables using two different conditions
I have following three tables with their data, as shown below.
CREATE TABLE TIREMASTERPROCESS_TEMP
(
PRODUCTIONCODE TANK (12 BYTES),
FIELDNAME CHAR (12 BYTES),
DATACHR VARCHAR2 (60 BYTE),
REVISIONNO TANK (3 BYTES),
DATANUM NUMBER (9.4)
)
Whether the table c. and its sample data are like
FIELDNAME DATACHR REVISIONNO DATANUM PRODUCTIONCODE
AB No. Nch 1 100 0
AB No. Nch 1 108 0
AB No.-of-Nch 1 1 0
Ass42 teased dishes 1 0
Ass42 BTDrumNo1 BTD-051 1 0
AB53 BTDrumNo1 BTD-051 104 0
CREATE TABLE materialcode
(
UPPERMATERIALCODE CHAR (20),
PROCESSNO TANK (3),
PROCESSADOPTDATE TANK (9)
)
Whether the table b. and its sample data are like
UPPERMATERIALCODE PROCESSNO PROCESSADOPTDATE
Ass42 1 20120717
AB53 108 20121121
111 20111104 AS05
104 20120928 AS30
CREATE TABLE BUILDINGSCHEDULEMASTER
(
BUILDINGSIZE TANK (5 BYTES),
GTCODE FLOAT (4 BYTES),
TIREPERCART NUMBER (3.0).
BUILDINGLOT NUMBER (3.0)
)
Whether table and its sample data are like
BUILDINGSIZE GTCODE TIREPERCART BUILDINGLOT
AB42A 4 12 ass42
AB53A 4 88 AB53
AS30A AS30 4 80
BF03A 1 90 BF03
Now, I need to get some data in these fields by using the suite of mappings.
« PR_ » || Trim (a.BUILDINGSIZE) | ' / MPL2' Processid,--PRIMARY KEY
TO_DATE (substr (NVL(b.PROCESSADOPTDATE,'19800101'), 7, 2) |) » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 5, 2) | » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 1, 4). (' 01:00:00 ',' dd-mm-yyyy hh24:mi:ss') starteff, to_date (SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 7, 2) |) » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 5, 2) | » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 1, 4). (' 01:00:00 ',' dd-mm-yyyy hh24:mi:ss') startDate.
b.PROCESSNO revisioncodeid,
a.BUILDINGLOT tirepercart ,
CASE WHEN c.FIELDNAME = 'BTDrumNo1' then c.DATACHR end drumtype1.
BOX WHEN (trim (C.DATACHR) = '1' and trim (C.FIELDNAME) = "No. Nch") and THEN click 'YES '.
ANOTHER 'NO '.
END may-BUG,
case
When c.FIELDNAME = 'Wavy'
AND c.DATACHR = 'Use' THEN on 'YES '.
When c.FIELDNAME = 'Wavy'
AND c.DATACHR <>'Use' THEN 'NO '.
fine wavy
Now for the tables A and B I have the simple join as condition
a.GTCODE = b.UPPERMATERIALCODE
But I have to use two different left join conditions to join the table B and C to calculate the RESP fields according to the condition.
Now, I have to use
(trim (b.UPPERMATERIALCODE)). » -'|| Trim (b.PROCESSNO) = Trim (c.PRODUCTIONCODE) | » -'|| Trim (c.REVISIONNO)
condition to get the data for the WAVY and DRUMTYPE1 fields.
But at the same time, I have to use
substr (Trim (b.UPPERMATERIALCODE), 1, 2). » -'|| Trim (b.PROCESSNO) = Trim (c.PRODUCTIONCODE) | » -'|| Trim (c.REVISIONNO)
conition to derive the CHAFER field.
And for this reason I am come so many duplicates and do not correct results for JUNEBUG, WAVY, DRUMTYPE1, and STARTDATE field.
I need some advice as how can I do so that I get the correct results without duplicates for the PRIMARY KEY.
Thank you
MaheshIt would have been easier to answer if you gave us your example query that gives incorrect results - which both show us what you are doing and give us a starting point.
Insert instructions for data, rather than only the data would have helped too, making it more quick to test this point.
You do not show what you have done with your two outer join criteria, but I think you need to list TIREMASTERPROCESS_TEMP in your query twice, with alias names. Here's what I did:select a.BUILDINGSIZE, a.GTCODE, b.PROCESSNO , c1.FIELDNAME, c1.DATACHR, C2.FIELDNAME, C2.DATACHR , CASE WHEN c1.FIELDNAME='BTDrumNo1' then c1.DATACHR end drumtype1 , CASE WHEN (trim(c2.DATACHR) = '1' and trim(c2.FIELDNAME) = 'No-of-Nch') THEN 'YES' ELSE 'NO' END CHAFER , case when c1.FIELDNAME='Wavy' AND c1.DATACHR='Use' THEN 'YES' when c1.FIELDNAME='Wavy' then 'NO' else null end wavy from BUILDINGSCHEDULEMASTER A join materialcode b on a.GTCODE=b.UPPERMATERIALCODE left outer join TIREMASTERPROCESS_TEMP c1 ON trim(b.UPPERMATERIALCODE)||'-'||trim(b.PROCESSNO) = trim(c1.PRODUCTIONCODE)||'-'||trim(c1.REVISIONNO) left outer join TIREMASTERPROCESS_TEMP c2 ON substr(trim(b.UPPERMATERIALCODE),1,2)||'-'||trim(b.PROCESSNO) = trim(c2.PRODUCTIONCODE)||'-'||trim(c2.REVISIONNO)
C1 is an alias for the TIREMASTERPROCESS_TEMP line which is necessary for drumtype1 and wavy, c2 is an alias for the TIREMASTERPROCESS_TEMP line required for JuneBug. There was some minor errors in your calculations of field I tried to correct.
The results are:
BUILD GTCO PRO FIELDNAME DATACHR FIELDNAME DATACHR DRUMTYPE1 CHA WAV ----- ---- --- ------------ ---------- ------------ ---------- ---------- --- --- AB53A AB53 108 No-of-Nch 1 YES AB42A AB42 1 BTDrumNo1 BTD-051 No-of-Nch 1 BTD-051 YES AB42A AB42 1 Wavy NotUse No-of-Nch 1 YES NO AS30A AS30 104 NO
Hope this helps,
DavidHello
I want to retrieve those records where full word of the 'text' column does not match with the word in the column 'object' of another table.
for example
for id 101 table abc, it contains the Word as "Air Blow" which is exactly with 101 id of table of bcd. I don't want the case
With abc as
(
Select 101 as id, "Air Blow" as double union text
Select 102, 'Air' Union double
Select 103, 'Sink' double union
Select 104, 'Air press' Union double
Select 105, 'Putting out fires' double
),
BCD as
(
Select 101 as id, "Air blown near the mount" as subject, 'WE' as a double union countries
Select 102, "Air breath seen here," 'China' of the double union
Select 103, 'Throughput', 'canada' to double union
Select 104, 'air pressure', 'UK' Union double
Select 105, 'Fire engine', 'Ubdy' from dual
)
Select * from abc, bcd
where abc.id = bcd.id
and upper (abc.text) <>(bcd.subject) upper
OUTPUT
ID TEXT ID_1 Object COUNTRY 102 Air blown 102 Blowing air saw China 103 Water flow 103 Water flow Canada 105 Putting out fires 105 Firefighter Ubdy Another corresponding original solution post results...
SQL > ed
A written file afiedt.buf1 with abc as)
2. Select 101 as id, "Air BLOW" as double union text
3. Select 102, 'Air' Union double
4. Select 103, 'Sink' double union
5. Select 104, 'Air press' Union double
6 select 105, 'Fire extinguish' from dual
7 ),
8 bcd as
9 (
10. Select 101 as id, "Air blown near the mount" as subject, 'WE' as a double union countries
11. Select 102, "Air breath seen here," 'China' of the double union
12. Select 103, 'Throughput', 'canada' to double union
13. Select 104, 'air pressure', 'UK' Union double
14 select 105, 'Fire engine', 'Ubdy' from dual
15)
16. Select *.
17 ABC join bcd on (abc.id = bcd.id)
18 * where no regexp_like (bcd.subject, abc.text, 'i')
SQL > /.
TEXT ID COUNTR OBJECT ID
---------- --------------- ---------- ----------------------- ------
102 air blowing here view China 102
103 103 water flow flow of water canada
Fire 105 105 fire Ubdy3 selected lines.
connect before between two tables
I have this table structure
I have what it takes to return the value on prior connection
create table OBJECT_LIST ( cal_objid NUMBER(4) not null, obj_name VARCHAR2(100), obj_type VARCHAR2(20), obj_title VARCHAR2(20), description VARCHAR2(50) ); alter table OBJECT_LIST add constraint OBJECT_LIST_PK primary key (CAL_OBJID); create table CAL_ERD ( obj_child NUMBER(5) not null, obj_parent NUMBER(5) not null, obj_rel_type VARCHAR2(50) ); alter table CAL_ERD add constraint CAL_ERD_PK primary key (OBJ_CHILD, OBJ_PARENT); alter table CAL_erd add constraint cal_parent_FK foreign key (obj_parent) references object_list (CAL_objid); alter table CAL_erd add constraint cal_child_FK foreign key (obj_child) references object_list (cal_objid); insert into object_list (cal_objid, obj_name, obj_type) values(1192, 'MainObject', 'Form'); insert into object_list (cal_objid, obj_name, obj_type) values(1193, 'SecondObject', 'Form'); insert into object_list (cal_objid, obj_name, obj_type) values(1194, 'ThirdObject', 'Form'); insert into object_list (cal_objid, obj_name, obj_type) values(1195, 'FourthObject', 'Form'); insert into object_list (cal_objid, obj_name, obj_type) values(1196, 'FirthObject', 'Form'); insert into cal_erd values(1193,1192,null); insert into cal_erd values(1194,1193,null); insert into cal_erd values(1195,1194,null);
in the first table values
CAL_OBJID OBJ_NAME, OBJ_TYPE OBJ_TITLE DESCRIPTION
1192 MainObject form
1193 SecondObject form
1194 ThirdObject form
1195 FourthObject form
1196 FirthObject formthe second value of the table
OBJ_CHILD OBJ_PARENT OBJ_REL_TYPE
1192 1193
1194 1193
1195 1194SQL script that I am trying
WITH t AS (SELECT li.obj_name, li.obj_type, li.obj_title, li.DESCRIPTION, LEVEL AS lvl, SYS_CONNECT_BY_PATH(li.obj_name, '/')paths FROM object_list li,cal_erd er where li.cal_objid = er.obj_parent(+) START WITH obj_parent IS NULL CONNECT BY NOCYCLE PRIOR obj_child = obj_parent) SELECT obj_name, LEAD(obj_name) OVER(ORDER BY paths) AS child_name, obj_type , obj_title , DESCRIPTION , substr(paths, INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) + 1 , INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl END) - INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) - 1 ) AS parent_name FROM t;
get valueOBJ_NAME, OBJ_TYPE OBJ_TITLE DESCRIPTION PARENT_NAME CHILD_NAME
FirthObject FourthObject form
FourthObject formI what like to be like that
OBJ_NAME, OBJ_TYPE DESCRIPTION OBJ_PARENT OBJ_TITLE OBJ_CHILD
SecondObject MainObject form
ThirdObject SecondObject form MainObject
fourthObject ThirdObject shape SecondObject
I would like if possible show the id of ojb_name
Hello
Here's a way to achieve the expected results, you want to:
WITH t AS (SELECT obj_parent , li.obj_name , li.obj_type , li.obj_title , li.DESCRIPTION , LEVEL AS lvl , SYS_CONNECT_BY_PATH(li.obj_name, '/')paths FROM object_list li LEFT JOIN cal_erd er ON (li.cal_objid = er.obj_child) START WITH obj_parent IS NULL CONNECT BY NOCYCLE PRIOR cal_objid = obj_parent), t2 AS ( SELECT LEAD(obj_name) OVER(PARTITION BY substr(paths, 1 , CASE WHEN INSTR(paths, '/', 1, 2)> 0 THEN INSTR(paths, '/', 1, 2)-1 ELSE LENGTH(paths) END) ORDER BY paths) AS child_name , obj_name , obj_type , obj_title , DESCRIPTION , substr(paths, INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) + 1 , INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl END) - INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) - 1 ) AS parent_name FROM t) SELECT * FROM t2 WHERE child_name IS NOT NULL;
Result:
CHILD_NAME OBJ_NAME, OBJ_TYPE OBJ_TITLE PARENT_NAME DESCRIPTION
SecondObject MainObject form
ThirdObject SecondObject form MainObject
FourthObject ThirdObject shape SecondObject
Kind regards
Steve
Several foreign key joins between two tables
Hello
I have a question about the creation of a repository.
I have a date and a fact dimension. The fact table has about 10 columns in foreign key to the date Dimension.
In this case I should create 10 aliases to create joins in the physical layer and MDB or y at - it another way to handle this situation.
I ask this question because 10 aliases can get very confusing for me at the later stage of time when creating reports.
With the help of OBIEE 10.1.3If you want to see in the industry as
End date, start date, date etc. nearby
you need to create 10 aliases for this purpose in the physical layer, make them drag in MDB and model, and then drag to the area of topicScore pls correct/good
- Hi all
Employee table should accept the definition name and column of file while EMP_temp must accept the column definition only.
Should compare employee and EMP_TEMP
CREATE TABLE employee
(INPUT_FILE VARCHAR2 (100 BYTE),
COLUMN_DEFINITION VARCHAR2 (4000 BYTES)
)
CREATE TABLE EMP_TEMP
(COLUMN_DEFINITION VARCHAR2 (4000 BYTE)
)
INSERT INTO employee VALUES ('EMP_Sets.csv ',' emp_Id dept_ID; sal");
INSERT INTO EMP_TEMP VALUES
(emp_id, dept_id, first_name, last_name, sal);
power required:
Number of columns in the Employee table:
Number of columns in the input file
Can anyone suggest me.
Thanks in advance
Maybe you are looking for
-
not all the events of the day on the notification screen
Hello I can't get all the events of the day in the calendar widget on the screen of the notification of my iPad. Genius Bar and Apple Support are unable to solve. Can anyone help? Thank you
-
Want to F9M09UA #ABA: cursor will not appear on the browser
My cursor will not appear when the browser window. I tried to restart, stop, update and everything I could find on the internet, but nothing has worked.
-
I have a cluster consisting of 10 Boolean buttons. Is it possible to easily disable some of the Boolean buttons inside the cluster without unbundling and rebundling of the cluster?
-
4615 Deskjet ink advantage will not print in black
Hello I replaced the black cartridge about a week ago and it worked fine until today. The printer indicates that the cartridge is full. Today used out in the middle of a print, and will not return. I tried all the procedures of cleaning recommended
-
When I try to open the basic games, i.e., Solitaire, the message appears "unable to create DirectX device". I checked the program on my computer and he says that he has no problem. What should I do to correct this?