Several select increased in 1 query
Team of hell,I am new to this SQL world. Please help me with this: -.
I have following queries: -.
#select name from v$ database;
#select log_mode from v$ database;
#select take into account (*) "INVALID_OBJECTS" from dba_objects where status = 'INVALID ';
count (*) '_INDEXES INVALID_ n/d' #select from dba_indexes where status! = 'VALID ';
#select take into account (*) invalid 'triggers' from user_objects where OBJECT_NAME like 'TRIGGERS %' and status = 'VALID ';
#select count (*) 'Jobs broken' from dba_jobs where broken! = « Y » ;
#select count (*) "Block of Corruption" from v$ database_block_corruption;
I want a table that can be generated just select cmd and it will list the result of all of the above queires as follows: -.
DB_NAME ARCH_MOD INV_OBJ INV_IDX INV_TRG B_JOB BLK_CRP
---------- -------------------------------------- -------------------------------------- ---------- ---------- ---------- ----------
NOARCHIVELOG PROD 0 86 6 3 0
I mean I want several select queries in the 1 table (note:-I'm not saying to create a table and then insert, update (use of select other tables), it's just a sheel script who will pick up these recordings in a txt file)
Something like that?
SQL> ed
Wrote file afiedt.buf
1 select a.name,
2 a.log_mode,
3 b."INVALID_OBJECTS",
4 c."INVALID_N/A_INDEXES",
5 d."Invalid Triggers",
6 e."Broken Jobs",
7 f."Block Corruption"
8 from
9 v$database a,
10 (select count(*) "INVALID_OBJECTS" from dba_objects where status ='INVALID') b,
11 (select count(*) "INVALID_N/A_INDEXES" from dba_objects where status !='VALID') c,
12 (select count(*) "Invalid Triggers" from user_objects where OBJECT_NAME like '%TRIGGERS%' and status='VALID') d,
13 (select count(*) "Broken Jobs" from dba_jobs where broken!='Y') e,
14* (select count(*) "Block Corruption" from v$database_block_corruption) f
SQL> /
NAME LOG_MODE INVALID_OBJECTS INVALID_N/A_INDEXES Invalid Triggers Broken Jobs Block Corruption
--------- ------------ --------------- ------------------- ---------------- ----------- ----------------
ORCL ARCHIVELOG 1 1 0 3 0
SQL>
Now, just try to replace your script with this:
#! / bin/bash
export hostname = $2;
echo 'export has started. "
export ORACLE_SID = $1;
export ORACLE_HOME=/$1db/db/10.2.0;
export LD_LIBRARY_PATH = / lib: / usr/lib: / usr/local/lib: $ORACLE_HOME/lib.
export TNS_ADMIN=/$1db/db/tech_st/11.2.0/network/admin/$1_$2;
PATH = / usr/bin: / usr/sbin: / usr/ccs/bin: / usr/local/oracle/bin: / usr/local/bin: / usr/dt/bin: / usr/openwin/bin: / usr/ucb: $ORACLE_HOME/bin: $ORACLE_HOME/OPatch;
export PATH = $PATH: $ORACLE_HOME/bin.
echo $ORACLE_HOME
echo 'export complete.
#export var1=/$1db/db/tech_st/11.2.0/$1_$2.env
#export var2=/$1db/db/tech_st/11.1.0/$1_$2.env
export var3=/$1db/db/10.2.0/$1_$2.env
#. /$1dB/DB/tech_st/11.2.0/$1_$2.env
#. /$1dB/DB/tech_st/11.1.0/$1_$2.env
#./$1db/db/10.2.0/$1_$2.env
sqlplus / as sysdba<>
Select b.SID,
a.log_mode,
b."INVALID_OBJECTS."
c.' INVALID_ N/A _INDEXES. "
d."invalid triggers."
e."broken jobs."
(f)"Block Corruption".
Of
v$ database.
(select count (*) "INVALID_OBJECTS" from dba_objects where status = 'INVALID') b.
(select count (*) "_INDEXES INVALID_ n/d" from dba_objects where status! = 'VALID') c,.
(select count (*) 'invalid triggers' from user_objects where OBJECT_NAME like 'TRIGGERS %' and status = 'VALID') d.
(select count (*) 'jobs broken' from dba_jobs where broken! = 'Y') e,.
f (select count (*) "Block of Corruption" from v$ database_block_corruption);
"exit"; > filename.txt
Let us know if it works for you or not.
Concerning
Girish Sharma
Tags: Database
Similar Questions
-
How to evolve several selected objects (type) 'In Place?'
I have reflected on the window of the scale, also "scale" dialog box that is the same dialog box "pull-down" in the main menu and tool... The selected items are resized to the size but also they are resized by location so everything shrinks its place. In Illustrator CC, several selected items can be resized "in place?
Try the transformation of each command from the object > Transform menu.
-
can a custom component cause several selectable symbols as they do fingerprints?
When I do a MCU component, I do the symbol reflects the functioning of the mcu for a particular project. For example I can I use the same PIC processor for several projects but have a different symbol to reflect that processors use within a project. I end up doing it by creating a component separated with a slightly different name. Ideally, I would like to have a component of 16Fxxxxx PEAK with several symbols. Symbol names can then be charged to the project.
Hi Lucither,
My name is Mitchell Goon, technical support from National Instruments.
In regard to your request, you won't be able to use the same MCU (with its respective configurations) in the way that you described in your post, is not without creating a separate copy of the MCU with symbols / different names. At present, the method you described would be a good way to address your query.
I hope this is the information you are looking for. If this is not the case, do not hesitate to contact us and we would be more than happy to help you.
Kind regards
Goon Mitchell
National Instruments
Engineering applications
-
How can I avoid several selected files are copied / duplicated in a folder
When I start to select several files, for example in my images, for copy and move to a new folder, Win 7 a copy of the files in the source folder automatically creates before that I got the chance to copy and paste my choice to the new folder. How can I turn that off?
Check your keyboard, the CTRL key is to be released at the beginning and this is what causes the duplication. If the key is not your finger and the keyboard can be a problem.
-
Cannot change the metadata in the grid of the library through several selected Images
This was bugs me for some time. It started there when I did a CC updated a few versions (about 2015.2, I think). I wrote chalked it up to a bug that they would fix it soon, but it has not been resolved.
Since I started using Lightroom 2, I used to be able to select several images in the grid view library and then modify the metadata in the Panel to the right and he would write to all. For example, I select 12 photos and set the title information and location. So when I watched each picture they would have the new title & location applied to them.
After a CC update I lost this ability - metadata only, can I change through selected images is using keywords.
Because I've lost this ability, I serve the copy metadata (SHIFT-ALT-CMD-C) and paste (SHIFT-ALT-CMD-V) to change the metadata in multiple images, but it's a clunkier and more time-consuming method. I really liked being able to hold down the Command or SHIFT and select several images to change all their metadata quickly.
Could someone help me? Am I missing some setting or preference?
This happens in Lightroom CC 2015.6 on my iMac OSX 10.9.5 running
and also on Lightroom CC 2015.5 on my MacBook OSX 10.11.5 running
johnrellis - problem solved! I did a reset of Lightroom preferences (How to reset preferences in Lightroom?-the Lightroom Queen).
-
Several COUNTY statements in a query
Hello
I have to do the query that counts number of subjects on different criteria. I did it with the COUNT (case when... then 1 end to another null) name_of_count, another similar leader, and so on until the clausule WHERE at the end of the page and the commune OF. And it works, but I am concerned by the representations.
Is it possible to make these requests without BREAKAGE?
Usually the FROM and WHERE clauses will determine performance, instructions in the SELECTION list BOX should have a minimal impact or performance.
-
Several SELECT statements with COUNTY with different WHERE clauses.
OK, so for a bit of background on what this is trying to accomplish...
I have a small group of people in my team and I will use GROUP BY for their names.
If each person will be on their own line. Next to their names, I want to be able to have several columns that use the ACCOUNT for the different search criteria (no duplicates)Overall, it should have their names, and I would like to add the number of tickets that each person has which meet certain criteria (all in different columns)
I have applications that can do each of these tasks, but is it possible that I can group together on a single table statements, or use subqueries for these results?Do you mean you want something like that?
SQL > ed
A written file afiedt.buf1 with the team (emp_id, emp_name)
2 (select 1, 'Fred' from dual union all
3. Select 2, 'Bob' Union double all the
4. Select 3, 'Jim' to double
5 )
6, tickets (emp_id, ticket_type, ticket_id, ticket_desc)
7 (select 1, 1, 'BUG', 'First billet Freds' double Union all)
8. Select 2, 1, 'CHANGE', "Freds second ticket" of all the double union
9 select 3, 1, 'BUG', ' Freds third ticket "of any double union
10. Select 4, 2, "CHANGE", "Bobs first ticket" of any double union
11. Select 5, 3, "CHANGE", "Jims first ticket" of any double union
12. Select 6, 3, "BUG", "Jims second ticket" of all the double union
13. Select 7, 1, 'BUG', ' Freds fourth ticket ' from dual
14 )
15-
16 END OF TEST DATA
17-
18 select emp_name
19, count (case when ticket_type = 'BUG' then 1 end to another null) and bugs
20, count (case when ticket_type = 'CHANGE' then 1 end to another null) as changes
21 of the team t
22 a left join external tickets tk (t.emp_id = tk.emp_id)
23 * emp_name group
SQL > /.EMP_ CHANGES OF BUGS
---- ---------- ----------
Bob 0 1
Fred 3 1
Jim 1 1 -
NVARCHAR2 column in the select statement of the query
HelloI have table
xx_test / / DESC
Name of Type Null
-------- -------- --------------
COL1 NOT NULL NVARCHAR2 (100)
COL2 NOT NULL NVARCHAR2 (100)
COL3 NOT NULL NVARCHAR2 (100)
I am able to interview
Select * from xx_test
However if the query as
Select col1 from xx_test
Then it is in error.
ORA-00904: "COL1": invalid identifier
00904, 00000 - '% s: invalid identifier '.
* Cause:
* Action:
Error on line: column 3-131: 13
Let me know how interrogate NVARCHAR2 column and how can we put in WHERE condition?
Thank you
Abhijit
Abhijit,
Now that you have already re-created the table, it would be difficult to find the exact cause. But I suspect it could happen due to the creation of table in a way not recommended the use of quotes.
If you use double quotes while creating the table/column names, you must always use capital letters. Better is not not to use quotes in all. Here is an example of a test that could be the cause of your error.
SQL > drop table test;
Deleted table.
SQL > create table test ("col1" nvarchar2 (200), col2 varchar2 (200));
Table created.
SQL > select Col1 from test;
Select Col1 from test
*
ERROR on line 1:
ORA-00904: "COL1": invalid identifier - it is him you got. Even if there is col1 column in the table, but I'm unable to select due to the bad way to appoint.
SQL > drop table test;
Deleted table.
SQL > create table test ("COL1" nvarchar2 (200), col2 varchar2 (200));
Table created.
SQL >
SQL > select col1 from test;
no selected line
The test case above apply to the tables as well.
Ishan
-
How to report a picture when several selected in mode "n"?
Hello
I want to compare several images in the same series. I select. I press the N key, then I select in the lower bar of the band, the group photo.
I want to put a flag (or star) than only I prefer, but all of them get the flags or stars...
I need to come out to reject by clicking each X of each image for them thrown and finally choose the suite only I want to...
How to choose or star just a picture on french N (Mode SET in LR) mode
MANYS tks
Fred
I can't reproduce your problem on Mac or Windows. Quite often when the strange behavior ball arises, it is an indication that the Lr preferences file has become corrupt. Have you tried to screw up your Lr preferences file and then restart the application? The name and location of the file preferably described here preference and other locations of files in Lightroom 5
-
Get help conditional select stmt of the query
Hi I have the following data set
Now IF cd = PC for unique s_id then post it, so s_id = 100 should be displayedwith t as ( select 100 s_id ,'abc' txt,'SH' r_cd,'Z+' symb,1 rt_id,11 m_id ,111 i_id ,'GO' sub_cd,'PC' cd from dual union all select 200 s_id,'bcd','SH','Z+',2,22,222 ,'A','PC' from dual union all select 200 ,'bcd','SH','Z+',2,22,222 ,'B','AN' from dual ) select * from t
If cd = PC as well as the PC <>for unique s_id then show only the record that is <>PC (YEAR), means s_id = cd = 200 YEAR should be displayed
Expected results
Could you please help me to achieve thiss_id =100 with cd = CP s_id=200 with cd =AN
If I understand correctly, if there is only one row with PC = cd you want to return this line. If there is a line with cd = 'PC' and another line for the s_id even with a value of different CDs, you want to return this another line. If there is no line with PC = cd then ignore this identifier.
If this is correct, then something in the sense of:
SQL> with t as ( 2 select 100 s_id ,'abc' txt,'SH' r_cd,'Z+' symb, 3 1 rt_id,11 m_id ,111 i_id ,'GO' sub_cd,'PC' cd 4 from dual union all 5 select 200 s_id,'bcd','SH','Z+',2,22,222 ,'A','PC' from dual union all 6 select 200,'bcd','SH','Z+',2,22,222 ,'B','AN' from dual union all 7 select 300, 'bcd','SH','Z+',2,22,222 ,'B','AN' from dual ) 8 select s_id, txt, r_cd, symb, rt_id, m_id, i_id, sub_cd, cd 9 from (select t.*, -- or whatever columns you want 10 COUNT(DECODE(cd, 'PC', 1, null)) OVER(PARTITION BY s_id) AS pc_cnt, 11 ROW_NUMBER() OVER(PARTITION BY s_id order by DECODE(cd, 'PC', 2, 1)) rn 12 FROM t) 13 WHERE rn = 1 and 14 pc_cnt =1; S_ID TXT R_ SY RT_ID M_ID I_ID SU CD ---------- --- -- -- ---------- ---------- ---------- -- -- 100 abc SH Z+ 1 11 111 GO PC 200 bcd SH Z+ 2 22 222 B AN
If ther could be more than two lines for a s_id, then you can adjust the order by in the row_number() to choose a. If you want several lines for the case where there is a PC line and several lines not PC, then something like:
SQL> with t as ( 2 select 100 s_id ,'abc' txt,'SH' r_cd,'Z+' symb, 3 1 rt_id,11 m_id ,111 i_id ,'GO' sub_cd,'PC' cd 4 from dual union all 5 select 200 s_id,'bcd','SH','Z+',2,22,222 ,'A','PC' from dual union all 6 select 200,'bcd','SH','Z+',2,22,222 ,'B','AN' from dual union all 7 select 200,'bcd','SH','Z+',2,22,222 ,'B','AC' from dual union all 8 select 300, 'bcd','SH','Z+',2,22,222 ,'B','AN' from dual ) 9 select s_id, txt, r_cd, symb, rt_id, m_id, i_id, sub_cd, cd 10 from (select t.*, -- or whatever columns you want 11 COUNT(DECODE(cd, 'PC', 1, null)) OVER(PARTITION BY s_id) AS pc_cnt, 12 ROW_NUMBER() OVER(PARTITION BY s_id order by DECODE(cd, 'PC', 2, 1)) rn 13 FROM t) 14 WHERE pc_cnt = 1 and 15 CASE WHEN cd = 'PC' and rn = 1 THEN 'Y' 16 WHEN cd <> 'PC' and rn > 1 THEN 'N' 17 ELSE 'Y' END = 'Y'; S_ID TXT R_ SY RT_ID M_ID I_ID SU CD ---------- --- -- -- ---------- ---------- ---------- -- -- 100 abc SH Z+ 1 11 111 GO PC 200 bcd SH Z+ 2 22 222 B AN 200 bcd SH Z+ 2 22 222 A PC
John
-
selection of required sample query
Hello
example of table can be considered to be table scott.emp
In this we can see that we have all the data to date of employment between February 1, 81 'and February 20, 81'. But the select statement must retrunCREATE TABLE "EMP" ( "EMPNO" NUMBER(4,0), "ENAME" VARCHAR2(10 BYTE), "JOB" VARCHAR2(9 BYTE), "MGR" NUMBER(4,0), "HIREDATE" DATE, "SAL" NUMBER(7,2), "DEPTNO" NUMBER(2,0) ) -- INSERTING into EMP Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7369,'SMITH','CLERK',7902,to_date('17-DEC-80','DD-MON-RR'),800,20); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7499,'ALLEN','SALESMAN',7698,to_date('20-FEB-81','DD-MON-RR'),1600,30); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7521,'WARD','SALESMAN',7698,to_date('22-FEB-81','DD-MON-RR'),1250,30); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7566,'JONES','MANAGER',7839,to_date('02-APR-81','DD-MON-RR'),2975,20); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7654,'MARTIN','SALESMAN',7698,to_date('28-SEP-81','DD-MON-RR'),1250,30); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7698,'BLAKE','MANAGER',7839,to_date('01-MAY-81','DD-MON-RR'),2850,30); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7782,'CLARK','MANAGER',7839,to_date('09-JUN-81','DD-MON-RR'),2450,10); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7788,'SCOTT','ANALYST',7566,to_date('19-APR-87','DD-MON-RR'),3000,20); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7839,'KING','PRESIDENT',null,to_date('17-NOV-81','DD-MON-RR'),5000,10); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7844,'TURNER','SALESMAN',7698,to_date('08-SEP-81','DD-MON-RR'),1500,30); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7876,'ADAMS','CLERK',7788,to_date('23-MAY-87','DD-MON-RR'),1100,20); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7900,'JAMES','CLERK',7698,to_date('03-DEC-81','DD-MON-RR'),950,30); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7902,'FORD','ANALYST',7566,to_date('03-DEC-81','DD-MON-RR'),3000,20); Insert into EMP (EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) values (7934,'MILLER','CLERK',7782,to_date('23-JAN-82','DD-MON-RR'),1300,10);
values between these days with employment HAVE NULL and empno, mgr, ename, sal as 0, depno can be 0 or a number.
I tried something and I got the count for a few columns. The query goes something like this.
This works on a given range of dates. The two queries below
OUT of the SAMPLE of a statement select should be something like this:select rt.business_date, ( select count(ename) from emp where trunc(hiredate) = trunc(rt.business_date) ) ename , ( select count(empno) from emp where trunc(hiredate) = trunc(rt.business_date) ) empno , ( select count(job) from emp where trunc(hiredate) = trunc(rt.business_date) ) job, ( select count(mgr) from emp where trunc(hiredate) = trunc(rt.business_date) ) mgr , ( select count(deptno) from emp where trunc(hiredate) = trunc(rt.business_date) ) deptno FROM (select ((TO_DATE(p_startdate,'mm/dd/yyyy')-1)+rnm) as business_date from (select rownum rnm from user_objects)) rt WHERE TRUNC(rt.business_date) BETWEEN TO_DATE(p_startdate,'mm/dd/yyyy') AND TO_DATE(p_enddate,'mm/dd/yyyy')
Published by: sri on October 19, 2011 08:36empno ename job mgr HIREDATE SAL DEPTNO 7369 SMITH CLERK 7902 17-Dec-80 800 20 0 NULL NULL 0 14-Feb-81 0 0 0 NULL NULL 0 15-Feb-81 0 0 0 NULL NULL 0 16-Feb-81 0 0 0 NULL NULL 0 17-Feb-81 0 0 0 NULL NULL 0 18-Feb-81 0 0 0 NULL NULL 0 19-Feb-81 0 0 7499 ALLEN SALESMAN 7698 20-Feb-81 1600 30 7521 WARD SALESMAN 7698 22-Feb-81 1250 30 7566 JONES MANAGER 7839 2-Apr-81 2975 20 7698 BLAKE MANAGER 7839 1-May-81 2850 30 7782 CLARK MANAGER 7839 9-Jun-81 2450 10 7844 TURNER SALESMAN 7698 8-Sep-81 1500 30 7654 MARTIN SALESMAN 7698 28-Sep-81 1250 30 7839 KING PRESIDENT (null) 17-Nov-81 5000 10 7900 JAMES CLERK 7698 3-Dec-81 950 30 7902 FORD ANALYST 7566 3-Dec-81 3000 20 7934 MILLER CLERK 7782 23-Jan-82 1300 10 7788 SCOTT ANALYST 7566 19-Apr-87 3000 20 7876 ADAMS CLERK 7788 23-May-87 1100 20
Published by: sri on October 19, 2011 08:56Hello
You have changed your first message.
Sri says:
HelloI want the data in the table appears as shown. in the quereis we get count of these records for that date. But I want something different. If we can see a few dates there is no record, but the select statement to display the records in the range of dates.
put it can be cosnidered something like this:
The need of the select statement to display data hiredates for 14-20 Feb as described below, and that we don't have in our database of emp table.
empno ename job mgr HIREDATE SAL DEPTNO 7369 SMITH CLERK 7902 17-Dec-80 800 20 0 NULL NULL 0 14-Feb-81 0 0 0 NULL NULL 0 15-Feb-81 0 0 0 NULL NULL 0 16-Feb-81 0 0 0 NULL NULL 0 17-Feb-81 0 0 0 NULL NULL 0 18-Feb-81 0 0 0 NULL NULL 0 19-Feb-81 0 0 7499 ALLEN SALESMAN 7698 20-Feb-81 1600 30 7521 WARD SALESMAN 7698 22-Feb-81 1250 30 7566 JONES MANAGER 7839 2-Apr-81 2975 20 7698 BLAKE MANAGER 7839 1-May-81 2850 30 7782 CLARK MANAGER 7839 9-Jun-81 2450 10 7844 TURNER SALESMAN 7698 8-Sep-81 1500 30 7654 MARTIN SALESMAN 7698 28-Sep-81 1250 30 7839 KING PRESIDENT (null) 17-Nov-81 5000 10 7900 JAMES CLERK 7698 3-Dec-81 950 30 7902 FORD ANALYST 7566 3-Dec-81 3000 20 7934 MILLER CLERK 7782 23-Jan-82 1300 10 7788 SCOTT ANALYST 7566 19-Apr-87 3000 20 7876 ADAMS CLERK 7788 23-May-87 1100 20
Use a FULL OUTER JOIN instead of LEFT OUTER JOIN, like this:
WITH all_dates AS ( SELECT startdate + LEVEL - 1 AS dt FROM ( SELECT TO_DATE ('02/14/1981', 'MM/DD/YYYY') AS startdate , TO_DATE ('02/20/1981', 'MM/DD/YYYY') AS enddate FROM dual ) CONNECT BY LEVEL <= 1+ enddate - startdate ) SELECT NVL (e.empno, 0) AS empno , e.ename , NVL (a.dt, e.hiredate) AS hiredate -- add other columns FROM all_dates a FULL OUTER JOIN emp e ON a.dt = e.hiredate ORDER BY NVL (a.dt, e.hiredate) ;
-
Extraction of a node in an XMLtype table - selection of the previous query
Hey all,.
I work with a server Oracle 11 g r2 and basically need to be able to analyse and select nodes from it. I spent hours scouring the net and reading the manual oracle xml db trying to find an appropriate solution to my problem, but I can't seem to identify the correct way to do it. I have some experience in programming, but none with databases oracle, sql or xml in general so forgive me if this is a trivial question.
OK, so the question:
I have a very simple XML file saved under catalog.xml and it is as follows:
<>Catalog
< cd >
< title > hide your heart < /title >
< artist > Bonnie Tyler < / artist >
< Country > UK < / country >
< company > CBS Records < / company >
< price > 9.90 < / price >
< year > 1988 < / year >
< CD >
< cd >
Empire Burlesque < title > < /title >
< artist > Bob Dylan < / artist >
< country > USA < / country >
< company > Columbia < / company >
< price > 10.90 < / price >
< year > 1985 < / year >
< CD >
< / catalogue >
Now, I want to be able to extract the title of the given cd a certain artist. So, for example, if the artist is "bob dylan", the title should be "empire burlesque".
Now I created an XMLType table in Oracle as follows:
CREATE BINARY XMLTYPE STORE AS XML BINARY XMLType TABLE.
I then load my xml file into oracle by:
Insert the BINARY values (XMLTYPE (BFILENAME ('XML_DIR', 'catalog.xml'), nls_charset_id ('AL32UTF8')));
So far so good.
Now for the part of the excerpt:
First of all I've tried:
SELECT extract (b.object_value, ' / catalogue/cd/title ')
Binary b
WHERE existsNode (b.object_value,'/catalog/cd [artist = "Bob Dylan"]') = 1;
EXTRACT(B.OBJECT_VALUE,'/CATALOG/CD/TITLE')
--------------------------------------------------------------------------------
< title > hide your heart < /title >
Burlesque Empire < title > < /title >
1 selected line.
It did not work because the xml file was all in 1 row then I realized that I had to split my xml in separate rows. Doing that, I had to convert the nodes < title > a virtual table using the functions XMLSequence() and table(). These functions convert nodes two title returned by the extract() function in a virtual table composed of two XMLType objects, each of which contains a single title element.
Second test:
SELECT value (d)
Binary B,
Table (xmlsequence(extract(b.object_value,'/catalog/cd'))) d
WHERE existsNode (b.object_value,'/catalog/cd [artist = "Bob Dylan"]') = 1;
VALUE (D)
--------------------------------------------------------------------------------
< cd >
< title > hide your heart < /title >
< artist > Bonnie Tyler < / artist >
< Country > UK < / country >
< company > CBS Records < / company >
< price > 9.90 < / price >
< year > 1988 < / year >
< CD >
< cd >
Empire Burlesque < title > < /title >
< artist > Bob Dylan < / artist >
< country > USA < / country >
< company > Columbia < / company >
< price > 10.90 < / price >
< year > 1985 < / year >
< CD >
2 selected lines.
It's better because it is now divided into 2 different lines so I should be able to make a selection - where, and then select the title from the artist.
However, this is where I have questions, I tried to literally hours but I can't understand how to use the results of the query above in my next. So I tried to use a suquery in this way:
Select extract (sub1, ' cd/title')
Of
(
SELECT value (d)
Binary B,
Table (xmlsequence(extract(b.object_value,'/catalog/cd'))) d
) sub1
WHERE existsNode (sub1,'/ cd [artist = "Bob Dylan"]') = 1;
However, sql * plus displays an error:
ORA-00904: "SUB1": invalid identifier.
I've tried dozens of variations to try to use subqueries but I simly can't do things.
I heard you can do also do this using variables or pl/sql, but I don't know where to start.
Any help would be greatly appreciated I tried everything at my disposal.This should help you get started!
select banner as "Oracle version" from v$version where banner like 'Oracle%'; create table otn5test( id number, data xmltype ); insert into otn5test values (1, xmltype('
Hide your heart Bonnie Tyler UK CBS Records 9.90 1988 Empire Burlesque Bob Dylan USA Columbia 10.90 1985 sqlplus> @otn-5.sql Oracle version ------------------------------------------------------------------------------ Oracle Database 11g Release 11.2.0.1.0 - 64bit Production Table created. 1 row created. ID TITLE ---------- -------------------- 1 Empire Burlesque ID XMLCAST(XMLQUERY('/C ---------- -------------------- 1 Empire Burlesque Table dropped.
-
Please send me selection for the following query statement...
FOR I IN 1.9 LOOP
IF shift (i) IS NULL THEN
FOR y IN i + 1.9 LOOP
IF shift (y) IS NOT NULL THEN
(I) shift: shift = (y);
Shift (y): = NULL;
EXIT;
END IF;
END LOOP;
END IF;
END LOOP;
Please how to write the select query to replace the lines of code abovePlease proceed here complete and this code did SHIFT here.
-
selection of values to query where clause
Hi guys, it of maybe a silly question but do not know if I approach the solution in the correct engineering.
At the top of my form, I framed that the user fills out the different values. These values are then used to refine the query results in the block below. I know that I can go in the datablock being interrogated and set the where the clause equal to the value of the text boxes above, but I don't feel it is the right place to do it.
If I do like this when the above text box is empty, it returns no results when infact I want to ask all if the values are left white. So should I put it in motion pre? If so how should we do?
Any help would be greatly appreciated.
Thank you.In the trigger of the QUERY before block you, just put the value in the corresponding element
:block.name := :ctrl.selection ;
François
-
Several Select statements fill Horizontal
Hello
I wonder how to fill these three instructions select a line, horizontal. The data does not correctly from my code below.
The first statement returns 4 rows
The second statement returns 27 lines
The last third statement returns 31 rows
My problem is that when the code below runs more than 500 rows are returned. What I do wrong to not fill the
results.
Example of how the data should look like, I don't understand the third declaration for space.CUSTOMER NAME - CUST_FIRST_NAME -CUST_LAST_NAME - CUST_CITY | CUSTOMER NAME - CUST_FIRST_NAME -CUST_LAST_NAME - CUST_CITY 1 JOHN DOE HOUSTON 1 CHERYL JONES WACO 1 BOB BOBBY DALLAS 1 ANNETTE JONES AUSTIN --this data should not be repeating since the other select statements 1 TOM BOBBY JACOB --has more rows, these rows should be empty 1 TOMMY BANKS ROB 1 BILLY HANK TOM
I hope someone can help me with this, thanks a lot.select distinct x.*, y.*, z.* from (select count(*) as "CUSTOMER NAME", CUST_FIRST_NAME, CUST_LAST_NAME, CUST_CITY from DEMO_CUSTOMERS where CUST_FIRST_NAME like '%A%' --and HIRE_DATE BETWEEN TO_DATE(:P10_START_DATE, 'MM/DD/YYYY') AND TO_DATE(:P10_END_DATE, 'MM/DD/YYYY') GROUP BY CUST_FIRST_NAME, CUST_LAST_NAME, CUST_CITY ORDER BY CUST_FIRST_NAME ASC) x, (select count(*) as "CUSTOMER NAME", CUST_FIRST_NAME, CUST_LAST_NAME, CUST_CITY from DEMO_CUSTOMERS where CUST_FIRST_NAME not like '%A%' --and HIRE_DATE BETWEEN TO_DATE(:P10_START_DATE, 'MM/DD/YYYY') AND TO_DATE(:P10_END_DATE, 'MM/DD/YYYY') GROUP BY CUST_FIRST_NAME, CUST_LAST_NAME, CUST_CITY ORDER BY CUST_FIRST_NAME ASC) y, (select count(*) as "CUSTOMER NAME", CUST_FIRST_NAME, CUST_LAST_NAME, CUST_CITY from DEMO_CUSTOMERS --where HIRE_DATE BETWEEN TO_DATE(:P10_START_DATE, 'MM/DD/YYYY') AND TO_DATE(:P10_END_DATE, 'MM/DD/YYYY') GROUP BY CUST_FIRST_NAME, CUST_LAST_NAME, CUST_CITY ORDER BY CUST_FIRST_NAME ASC) z;
Hello
The best is probably the cross join the demo_customer table will be a table that has 3 lines (so that the demo_customers data can be repeated up to 3 times, that the conditions are met), assign a number line (r_num) for the data replcated and pivot so that data on a line by r_num like that :
WITH cntr AS ( SELECT LEVEL AS n FROM dual CONNECT BY LEVEL <= 3 ) , got_criteria AS ( SELECT d.cust_first_name, d.cust_last_name, d.cust_city , CASE WHEN c.n = 1 AND cust_first_name LIKE '%A%' THEN c.n WHEN c.n = 2 AND cust_first_name NOT LIKE '%A%' THEN c.n WHEN c.n = 3 AND cust_first_name >= 'A' THEN c.n END AS crit_num FROM demo_customers d CROSS JOIN cntr c -- WHERE hire_date BETWEEN TO_DATE (:p10_start_date, 'MM/DD/YYYY') -- Filter as much as possible here -- AND TO_DATE (:p10_end_date, 'MM/DD/YYYY') ) , got_r_num AS ( SELECT got_criteria.* , DENSE_RANK () OVER ( PARTITION BY crit_num ORDER BY cust_first_name , cust_last_name -- Be sure to include these , cust_city ) AS r_num FROM got_criteria WHERE crit_num IS NOT NULL ) SELECT r_num , NULLIF (COUNT (CASE WHEN crit_num = 1 THEN 1 END), 0) AS cnt_1 , MIN (CASE WHEN crit_num = 1 THEN cust_first_name END) AS first_name_1 , MIN (CASE WHEN crit_num = 1 THEN cust_last_name END) AS last_name_1 , MIN (CASE WHEN crit_num = 1 THEN cust_city END) AS city_1 , NULLIF (COUNT (CASE WHEN crit_num = 2 THEN 1 END), 0) AS cnt_2 , MIN (CASE WHEN crit_num = 2 THEN cust_first_name END) AS first_name_2 , MIN (CASE WHEN crit_num = 2 THEN cust_last_name END) AS last_name_2 , MIN (CASE WHEN crit_num = 2 THEN cust_city END) AS city_2 , NULLIF (COUNT (CASE WHEN crit_num = 3 THEN 1 END), 0) AS cnt_3 , MIN (CASE WHEN crit_num = 3 THEN cust_first_name END) AS first_name_3 , MIN (CASE WHEN crit_num = 3 THEN cust_last_name END) AS last_name_3 , MIN (CASE WHEN crit_num = 3 THEN cust_city END) AS city_3 FROM got_r_num GROUP BY r_num ORDER BY r_num ;
The result of your sample data is:
.R_ CNT FIRST LAST CNT FIRST LAST CNT FIRST LAST NUM _1 _NAME_1 _NAME_1 CITY_1 _2 _NAME_2 _NAME_2 CITY_2 _3 _NAME_3 _NAME_3 CITY_3 --- --- -------- -------- ---------- --- -------- -------- ---------- --- -------- -------- ---------- 1 1 ABBY DUNN MOBILE 1 JOHN EDDY DALLAS 1 ABBY DUNN MOBILE 2 1 EDWARD TODD AUSTIN 1 JOHN JAMES HOUSTON 1 EDWARD TODD AUSTIN 3 1 JOHNNY GEORGE CINCY 1 JOHN EDDY DALLAS 4 1 MILLY BROOKS DE RIDDER 1 JOHN JAMES HOUSTON 5 1 JOHNNY GEORGE CINCY 6 1 MILLY BROOKS DE RIDDER
This has only to make a pass through the demo_customers table, so I think it will be faster to do a self-join, where you have to make a separate pass mark for each criterion.
Make sure that the analytical got_rnum.r_num ORDER BY clause contains all the columns that have been in your original GROUP BY, even if you don't really care to their order. The main request will make a GROUP BY r_num, so including the columns in this clause ORDER BY to include in the GROUP BY.The problem with the full outer join is that you still do not put join conditions after the individual tables. After that the each keyword JOIN there will be a table name or a alias and immediately after that must come the key word WE followed by a coindition to join.
I made a mistake earlier: when full outerer joining several tables, would better meet you each new table in each of the previous tables, because it is unclear which of these tables may be missing due to the outer join. In other words, the join condition for f had better be:ON f.r_num = COALESCE (d.r_num, e.r_num)
because d.r_num or e.r_num could be NULL, because the outer join.
Maybe you are looking for
-
where is the possibility to change icons in facsimile?
This new update suck. where is the possibility to use only text? I hate icons!
-
Is there a reset button or a way to remove the battery to do a hard reset? I do not wait for the battery to die will do, but in another 6 hours or more mayby I'll know better. He is not responding to something... ctrl alt del, ctrl shift esc, alt f4.
-
ATV4 shows the same picture all the time during the slide show
I have a few 1000 streaming photo to my ATV4; When you make a slideshow on ATV4 it will be only shuffle through a random selection of about 50 photos. This selection changes but every time I start a new slide show. The option to turn off "repeat phot
-
I get this message on my computer and I don't know what that means. Should "Use of the high memory by Internet Explorer" I worry?
-
I think that the toolbar is too long, is there a way to shorten? It is as long as my computer screen and it bothers me because it's a little too big, don't you think? I use Windows vista btw. Vista with an 'i' not a 'y '.