in the clause with subquery in oracle
Hi friends,
I have two tables say table1 and table2 with details below
create table test1 (identification number, name varchar2 (20));
Insert into test1 values(11,'micro');
Insert into test1 values(22,'soft');
create table test2 (identification number, name varchar2 (20));
Insert into test2 values(77,'micro,soft');
(1) if I use under request I do not receive either delivering lines
Select * from t1 test1 where t1.name in (select "': replace (t2.name, ','" ', "') |") ' from test2;
(2) if I had the fire out one subquery I get is: "micro", "smooth".
Select "' | Replace (t2.name, ',' "'," ') | " ' from test2;
But if I fire the query (1) I need the result
name identity
------------
11 microphone
22 soft
can someone please help me to get the same result with a query (1).
Few things
1. your table TEST2 is not in first normal form (1NF). It's ugly!
2. IN paragraph does not evaluate a single variable or a column with values defined as several values, they are just single value.
FAQ a few details, read Re: 7. the list of values in an IN clause?
And this is how its done (one-way)
SQL > select id, name
test1 2
3 where name in)
4 Select regexp_substr (name, "[^,] +', 1, level")
5 of test2
6 where id = 77
7. plug
8 per level<= length(name)-length(replace(name,="">=>
9 );ID NAME
---------- --------------------
11 microphone
22 soft
Tags: Database
Similar Questions
-
Using the drive with MSSQL and Oracle partitioning
Hi all
Although this isn't a likely configuration I would recommend/meeting, this issue has been driving me crazy because I can't find the answer and I don't know how to test it on my own (lack of material and knowledge).
I met a paper on SQL Server 2012 and 2008R2, which States:
When SQL Server performs sorting data IO operations, it first sorts data by partition. SQL Server accesses one disc at a time, and this can reduce performance. To improve the performance of data sorting, divide your partitions on disks data files by putting in place a RAID. In this way, although always SQL Server sorts data by partition, it can access all drives of each partition at the same time.
http://msdn.microsoft.com/en-us/library/ms190787.aspx
>
I'm curious whether Oracle has the same "limitation." I see in the 10.2 docs they say:
Although you are not required to keep each table or index partition (or subpartition) in a space separated, it is to your advantage to do so. Partitions in separate tablespaces storage allows you to:
* reduce the risk of data corruption on several partitions
* Save and retrieve each partition independently
Controls the mapping of the partitions of hard disks (important for I/O load balancing)
* Improve the manageability, availability and performance
http://docs.Oracle.com/CD/B19306_01/server.102/b14231/partiti.htm
>
But it's not precisely say it can access more than one disc at a time. I can't tell if this applies to Oracle or not. Sorry for the reference to an earlier version, but I searched this statement in 11.2 documentation but could not find.
Anyone can shed some light on this? It is eating at me :)
Thank you
RichMy PC at home came with two hard drives of 1 t. Default HP would deliver them together towards the top in a setting stripped for performance (even if I had the drive put in place like a mirror). For Windows, there is only a C"" drive. Yet, most of the documentation you have read still refer to the disk drives as your disc consists of physical disks to which you have access to. In a world record is often a block box, that is another question and discussion.
HTH - Mark D Powell.
-
Difference between the true Date of the Hijra with date Hijri Oracle
Hi all
I'd appreciate if someone please let me the solution for this problem. In my application, I displays the Hijri Date using the NLS parameter. but the question that "I'm dealing with a deference between the date of the real Hijra with the date of the Hijra oracle."
Assume that the actual Hijri date 18-SEP-2012 was 02/11/1433 in hijri but in oracle was 03/11/1433
When I run the following query it shows me "1433/11/03", but the actual date of the Hijra is "" 1433/11/02.
Select to_char (to_date ('20120918', 'YYYYMMDD'), ' DD/MM/YYYY', ' NLS_calendar = "' |') Hegira ARABIC ') FROM DUAL;
IFTIKHARCheck
FAQ on the calendar of the Hijra (Hijri) [ID 121061.1] Arabic
and
Conversion algorithm to Date in the Gregorian calendar until then Arab (Hijra) [ID 130551.1]Support of Oracle.
If you have a file called lxecal.nlt file
for Oracle 8 to $9i ORACLE_HOME/ocommon/sln
for Oracle 10 g and more $ORACLE_HOME/nlsso maybe that's the difference you see originally.
Kind regards
Bob -
[SQL] Where the problem of the clause with subqueries
Hello
I am writing a query for an apex application where I have a field (P47_UNNR) for filtering. In my where clause I try to do this:
... AND IN qo.pk_id
CASE
WHEN: P47_UNNR IS NULL
THEN
(SELECT pk_id FROM quote_orders)
ON THE OTHER
(SELECT QOR. FK_QUOTE_ORDER_ID
OF QUOTE_ORDER_RIDS QOR
JOIN THE
RID RID
WE RID. PK_ID = QOR. FK_RID_ID
WHERE RID.NAME LIKE: P47_UNNR)
END
...
But it gives an error "ORA-01427: einreihig subquery returns more than one line.
I tried several ways to work around this problem, but don't seem to be able to do. Does anyone have a suggestion on how to fix this?Try something like...
AND qo.pk_id IN (SELECT pk_id FROM quote_orders WHERE :47_UNNR IS NULL UNION ALL SELECT QOR.FK_QUOTE_ORDER_ID FROM QUOTE_ORDER_RIDS QOR JOIN RIDS RID ON RID.PK_ID = QOR.FK_RID_ID WHERE RID.NAME LIKE :P47_UNNR )
-
When the clause with conditions
Hi all
I have a report that must be filtered according to user input in a field of text and drop-down list.
The goal is to let the user enter either an exact value (based on the AutoComplete feature) or use the wildcard character %
It is where comes the menu drop down. If they choose value1, AutoComplete, the exact value is used and the where clause would look like something below,
If they choose value2, then where should deal with using the same function and % s. something like:select col1, col2, col3 from table where :P1_FILTER in (select distinct col2 from another_table)
How can I take care of this in 1 where clause? I'm kind of stuck trying to figure out.select col1, col2, col3 from table where :P1_FILTER like (select distinct col2 from another_table)
Thanks for any help.
-ChrisTry this:
select col1, col2, col3 from table where ( :P1_FILTER in (select distinct col2 from another_table) AND :P1_LOV =1 ) OR ( :P1_FILTER like (select distinct col2 from another_table) AND :P1_LOV =2 )
I hope this helps!
Sam -
with the clause with union all?
Hello
I tried to use 'by' article with union all. .but it gives me error...
What harm am I doing here? Thank you very much!!with t1 as (select '1'col1 from dual union all select '2' col2 from dual)select * from t1 union with t2 as (select '3' col1 from dual union all select '4' col1 from dual ) select * from t2
Use the WITH clause, once for you all the subqueries, and then add the main request;
with t1 as (select '1' col1 from dual union all select '2' col2 from dual), t2 as (select '3' col1 from dual union all select '4' col1 from dual) select * from t1 union select * from t2;
-
Remove the statement with subquery with more than 1 columns
Hi all
I want to delete the data in the kpi_logs table for which the kpi_def_id column is less than the max (timestamp). The timestamp is the date data type. I wrote below query but its throwing an error as an SQL error: ORA-00936: lack of expression.
DELETE FROM KPI_LOGS WHERE (Select MAX (TIMESTAMP), KPI_DEF_ID of the KPI_DEF_ID KPI_LOGS GROUP);
Hello
user12251389 wrote:
I want to delete the data in the kpi_logs table for which the kpi_def_id column is less than the max (timestamp). The timestamp is the date data type. I wrote below query but its throwing an error as an SQL error: ORA-00936: lack of expression.
DELETE FROM KPI_LOGS WHERE (Select MAX (TIMESTAMP), KPI_DEF_ID of the KPI_DEF_ID KPI_LOGS GROUP);
Whenever you have a question, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the accurate results you want from this data, so that people who want to help you can recreate the problem and test their ideas.
If you ask about a DML operation, such as DELETE, and INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum:
You want to keep only the maximum timestamp for the entire table, or you want the maximum timestamp for each distinct value of kpi_def_id?
If it is just the maximum timestamp for the whole picture, then
DELETE FROM kpi_logs
WHERE the timestamp<>
SELECT MAX (timestamp)
OF kpi_logs
);
If you want to keep the maximum timestamp for each individual value phew kpi_def_id, then:
DELETE FROM kpi_logs
WHERE (kpi_def_id, timestamp NOT IN)
SELECT kpi_def_id
MAX (timestamp)
OF kpi_logs
GROUP BY kpi_def_id
);
assuming that no column can be NULL.
Moreover, the TIMESTAMP is a data type, similar to this DAY. You'll only cause confusion by saying it is a type of data when it is really another. In addition, TIMESTAMP is a keyword from Oracle, is not a very good column name. Why not give your column a name more meaningful, accurate, such as create_date or entry_dt?
-
the clause WITH XMLNAMESPACES xmltable: do you go on the internet for xsd?
Hello
I have a request of xmltable passing an xmltype variable.
Something like this:
This query is executed in a loop, and we try to improve its performance.select id, name, data From XMLTable(XMLNamespaces ('https://www3.somesite.es/bla/bla/bla/thexsd.xsd' as "n1" , 'https://www3.somesite.es/bla/bla/bla/otherxsd.xsd' as "co") , '/n1:some/tag' passing l_my_xmltype_var COLUMNS id NUMBER(20) PATH '//n1:id' , name VARCHAR2(9) PATH '//n1:name' , data VARCHAR2(125) PATH '//co:datatxt') X
S/n told me that whenever the query is run, we need to get the two xsd via internet.
1. is this true?
2. If it is... Can I keep the local XSD or even inside the database? (I heard something on the registration of the scheme)
Thank youJulius says:
The actual query has more than 75 columns. Its consumption is spent on java, so I have to assume that this is because of the money the xmltable process analysis.You OR do something (horribly) wrong OR should move to a longer version of database great or equal to 10.2.0.3.x
PLEASE post your version of the database (all figures!)
Do you mean that, even working with a local xmltable passing a variable xmltype (not a structured xml real chart), save the scheme will do good performance?
Yep, for example by avoiding calls JAVA... through the registered XML schema validation is optimized if not only because of its kernel code, it's C - code
I guess I have to:
1 save the xsd
2 reference him when I create the xmltype variable (by adding the second parameter to the function of xmltype).Fix.
Then, during the treatment of xmltable, the engine will be smart enough to use the xsd saved info to improve the query performance? Okay, I'm a little skeptical, but will give it a try.
I will also try to facilitate the processing by specifying the path of the full tree instead of using "/ / tag.
It will make a difference (providing you're at least on 10.2.0.3.x regarding the use of XMLTABLE, the XQuery engine...)
As a curiosity, all this quest for optimization of query came when - after a change - the performance of the query went from 5 seconds to 90 seconds. Things went south when I added a * in select it the list instead of referring columns with their names. So it doesn't seem a good idea to use * with a high column number xmltable
Perhaps, but cannot say. These questions depend on many parameters and environment settings. It could be a connection problem or... or...
It's one of the reasons why we need the version of database for you give a better answer...
Published by: Marco Gralike June 8, 2011 11:17
-
AS the question of the clause with Group By
Hello everyone. I have a simple query that calculates the number of 3 expressions. It is supposed to cluster by region and province as well, but is rather the TOTAL number for each expression in the areas of the region and the province. What I am doing wrong? This is my query:
SELECT TABLE1. Province. "
TABLE1. "' Region '.
(SELECT (COUNT (TABLE1." "" 'Nationality')) "
FROM TABLE1
WHERE (TABLE1. "' Nationality ' <>'United States '.
AND TABLE1. ("' <>"Nat1"nationality")
OR (TABLE1. "" Medical <>""MEDICAL SUR ".
AND TABLE1. ("" <>Region ""CONUS")
) "TCN COUNT."
(SELECT (COUNT (TABLE1." "" 'Nationality')) "
FROM TABLE1
WHERE (TABLE1. ("' Nationality ' = 'United States')
OR (TABLE1. "" Medical <>""MEDICAL SUR ".
AND TABLE1. ("" <>Region ""CONUS")
) "US COUNT."
(SELECT (COUNT (TABLE1." "" 'Nationality')) "
FROM TABLE1
WHERE (TABLE1. ("" Nationality "="Nat1")
OR (TABLE1. "" Medical <>""MEDICAL SUR ".
AND TABLE1. ("" <>Region ""CONUS")
) 'HCN COUNT. "
FROM TABLE1
GROUP BY TABLE1. "" Province. "
TABLE1. "" Region ";
Any help would be appreciated. Thank you.
AquaBecause you spend not all values of the inner query to external...
Are you looking for this?
SELECT TABLE1."Province", TABLE1."Region", sum ( case when ( TABLE1."Nationality" != 'United States' AND TABLE1."Nationality" != 'Nat1' ) OR ( TABLE1."Medical" != 'ON MEDICAL' AND TABLE1."Region" != 'CONUS' ) then 1 else 0 end ) "TCN COUNT", sum ( case when ( TABLE1."Nationality" = 'United States' ) OR ( TABLE1."Medical" 'ON MEDICAL' AND TABLE1."Region" 'CONUS' ) then 1 else 0 end ) "US COUNT", sum ( case when ( TABLE1."Nationality" = 'Nat1' ) OR ( TABLE1."Medical" 'ON MEDICAL' AND TABLE1."Region" 'CONUS' ) then 1 else 0 end ) "HCN COUNT" FROM TABLE1 GROUP BY TABLE1."Province",TABLE1."Region";
-
What is the significance of the CURSOR WITH HOLD clause in a cursor declaration?
What is the significance of the CURSOR WITH HOLD clause in a cursor declaration?
A cursor that has been declared with the clause WITH HOLD, after the word CURSOR remains open after a COMMIT or a ROLLBACK. The following example shows how to use the following clause:
EXEC SQL DECLARE C1 CURSOR WITH HOLD FOR SELECT ENAME FROM EMP WHERE EMPNO BETWEEN 7600 AND 7700 END-EXEC.
The cursor must not be declared for the UPDATE. The WITH HOLD clause is used in DB2 to override the default, which is to close all cursors on validation. Pro * COBOL provides this clause in order to facilitate the migration of applications to DB2 to Oracle. When MODE = ANSI, use Oracle DB2 default, but all host variables must be declared in a declare Section.
Reference:
Oracle documentation!
http://docs.Oracle.com/CD/B10501_01/AppDev.920/a96109/pco03dbc.htm -
ORA-00907: lack the right parenthesis when using Group by clause with xmlagg
I have the following query and I am getting ORA-00907 error when I use the clause with the xmlagg function group.
If I remove the clause xmlagg and the group by clause, the query works well and not give me the result.select xmlelement("Mitigation", xmlelement("m_szMethodName",tm.DisplayName), xmlelement("SubstanceInterferenceProtocolList", (select xmlagg(xmlelement("MitigationProtocol", xmlelement("m_szMethodName",tm.DisplayName), xmlelement("m_szInterferenceProtocolName",tmp.protocol_name), xmlelement("m_szInterferenceSubstance",tmp.intf_mtrl_prod_code), xmlelement("m_ProtocolParameters", xmlelement("m_szProtocolName",tmp.protocol_name), xmlelement("m_Consumables", xmlelement("Consumable", xmlelement("m_szConsumId", xrl.rgnt_pack_name), xmlelement("m_szProductCode",xrl.pack_prod_code), xmlelement("m_nVolume",tmp.fluid_vol), xmlelement("m_szProtocolStep",xps.protocol_step_name))), xmlelement("m_ProtParamList", xmlagg( xmlelement("ParameterValues", xmlelement("m_szProtocolName",tmp.protocol_name), xmlelement("m_Time",xpsd.parameter_ntime_value)) group by tmp.ccd_test_id,tmp.intf_mtrl_prod_code) ))) order by tmp.ccd_test_id, tmp.intf_mtrl_prod_code, xps.protocol_step_intprotocolstep ) from XPR_tdef_mitigation_protocol tmp, xp_reagentlist xrl, xpr_protocol_settings xps, xpr_protocol_settings_default xpsd where tmp.ccd_test_id = tm.ccd_test_id and tmp.ccd_test_id = xrl.ccd_test_id and tmp.pack_prod_code = xrl.pack_prod_code and tmp.intf_type = 1 and xps.protocol_name = xpsd.protocol_name and xps.protocol_step_name = xpsd.protocol_step_name and xps.ps_action_parameterlist = xpsd.ps_action_parameterlist and xps.protocol_name = tmp.PROTOCOL_NAME ))) from XPtoXPRTdef_defn_mapping tm where tm.DisplayName = 'SYPH'
But in this code XML, the output format is incorrect for my application.
Could someone help out here?Now my problem is that this unique coating is more than 32767 characters and utl_file can write 32767 bytes per line.
Someone deal with this?Serialize the output as CLOB and DBMS_XSLPROCESSOR.clob2file procedure used to write to a file:
DECLARE xml_output CLOB; BEGIN SELECT XMLElement("Department", XMLAgg( XMLElement("Employee",e.job_id||' '||e.last_name) ORDER BY e.last_name ) ).getClobVal() AS "Dept_list" INTO xml_output FROM hr.employees e WHERE e.department_id = 30 OR e.department_id = 40; DBMS_XSLPROCESSOR.clob2file(xml_output, 'XML_DIR', 'test.xml'); END; /
-
Where can I get the documentation WITH clause?
DB version: 10 gr 2
In the OTN forums, I still see WITH clause being used to generate sample data, like the one used in the following thread
How can I ORDER HERE?
I want to learn more WITH the clause, but I could not find in Oracle Documentation(SQL Reference 10g Release 2)with data as ( select 666 as emp_id, 'JobA' as job_name, 'test_emp' as emp_name, 'test_team' as team, '08:00-11:48' as date_1, '07:00-08:00' as date_2, '08:00-11:48' as date_3 from dual union all select 666 as emp_id, 'JobA' as job_name, 'test_emp' as emp_name, 'test_team' as team, '07:00-08:00' as date_1, null as date_2, '12:00-15:36' as date_3 from dual union all . . .
Part No.B14200 - 02). No idea where I could read on the essential, usage restrictions... etc on WITH clause?Subquery factoring clause in the syntax select...
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/statements_10002.htm#SQLRF01702
-
Get ORA-00942 error with the clause, but not when the user sys.
Hello
About 3 weeks ago we increased our memary to PGA_aggregate_target = 60 GB, SGA_target = 58 GB Oracle instance. About 1 week ago our cognos user started having errors ORA-00942 for these queries generated with clause, with the same authorization. i.e.
with 'aBmtQuerySubject4' as
(select "BANK_NOTE_ADI_INFO_T". ' ' PRINT_BATCH_ID ' 'PRINT_BATCH_ID '.
'BANK_NOTE_ADI_INFO_T '. ' ' PROCESS_RUN_DT ' 'PROCESS_RUN_DT '.
'BANK_NOTE_ADI_INFO_T '. ' ' RDP_ID ' 'RDP_ID '.
'BANK_NOTE_ADI_INFO_T '. ' ' FI_ID ' 'FI_ID '.
'BANK_NOTE_ADI_INFO_T '. ' ' DEPOSIT_NB ' 'DEPOSIT_NB '.
'BANK_NOTE_ADI_INFO_T '. ' ' PROCESS_MACHINE_ID ' 'PROCESS_MACHINE_ID '.
'BANK_NOTE_ADI_INFO_T '. ' ' OUTPUT_STACKER_TYPE_CE ' 'OUTPUT_STACKER_TYPE_CE '.
'BANK_NOTE_ADI_INFO_T '. ' ' PARTITION_KEY ' 'PARTITION_KEY '.
'BANK_NOTE_ADI_INFO_T '. ' ' LOAD_ID ' 'LOAD_ID '.
'BANK_NOTE_ADI_INFO_T '. ' ' SERIAL_NUMBER_ID ' 'SERIAL_NUMBER_ID '.
'BANK_NOTE_ADI_INFO_T '. ' ' SHIFT_NB ' 'SHIFT_NB '.
'BANK_NOTE_ADI_INFO_T '. ' ' BANK_NOTE_COUNT_NB ' 'BANK_NOTE_COUNT_NB '.
of "BOISI '." BANK_NOTE_ADI_INFO_T' 'BANK_NOTE_ADI_INFO_T '.
)
'CountResultQuery5' as
(select count ("aBmtQuerySubject4". "BANK_NOTE_COUNT_NB") 'C_1' "
, count (1) 'C_2' of 'aBmtQuerySubject4 '.
After having count (*) > 0)
Select 'CountResultQuery5 '. "' C_2 ' 'Count1.
of 'CountResultQuery5 '.
;
with 'aBmtQuerySubject4' as
(select "BANK_NOTE_ADI_INFO_T". ' ' LOAD_ID ' 'LOAD_ID '.
of "BOISI '." BANK_NOTE_ADI_INFO_T' 'BANK_NOTE_ADI_INFO_T '.
)
'CountResultQuery5' as
(select count ("aBmtQuerySubject4". "LOAD_ID") 'C_1' "
, count (1) 'C_2 '.
of 'aBmtQuerySubject4' having count (*) > 0
)
Select 'CountResultQuery5 '. "' C_2 ' 'Count1' of 'CountResultQuery5 '.
;-output like:
'BANK_NOTE_ADI_INFO_T '. ' ' PROCESS_RUN_DT ' 'PROCESS_RUN_DT '.
*
ERROR at line 3:
ORA-00942: table or view does not exist
of "BOISI '." BANK_NOTE_ADI_INFO_T' 'BANK_NOTE_ADI_INFO_T '.
*
ERROR at line 3:
ORA-00942: table or view does not existSince 2 days ago, we get ORA-0403.
One thing I noticed that the coguser can run above queries correctly after they are run by a user sys...
Could you please help me on how I can resolve ORA-00942 error?
Thank you very much, much in advance for all your help and your advice! :-)
Jihong.
"One thing I've noticed the coguser can run over queries correctly after they are run by a user sys... »
Jihong,
Do you mean that queries can be run successfully as a sys user, or as long as once a sys cognos user user has run the query at least once?
Gerard
-
Hi all
I'm using oracle 11.2.0.4
I m using this for the purpose of learning
Below is my table and insert statement
CREATE TABLE COMPANY (NUMBER EMPLOYEE_ID, EMPLOYEE_NAME VARCHAR2 (30), NUMBER OF MANAGER_ID)
INSERT INTO THE COMPANY'S VALUES (1, 'FRED', ");
SOCIETY VALUES (2, 'BARNEY', '1');
SOCIETY VALUES (3, 'WILMA', '1');
SOCIETY VALUES (4, 'BETTY', '3');
INSERT IN THE VALUES(5,'PEBBLES','3') SOCIETY;
INSERT IN THE VALUES(6,'BAM-BAM','4') SOCIETY;
INSERT IN THE VALUES(7,'DINO','4') SOCIETY;
INSERT IN THE VALUES(8,'HOPPY','4') SOCIETY;
WITH RSFC(CK,PK,LVL,HIER) AS
(SELECT EMPLOYE_ID, MANAGER_ID, 0 AS LVL, EMPLOYEE_NAME LIKE YESTERDAY)
SOCIETY
WHERE MANAGER_ID IS NULL
UNION ALL
SELECT EMPLOYE_ID, MANAGER_ID, LVL + 1, YESTERDAY. '/' || EMPLOYEE_NAME
OF THE RSFC R INNER JOIN COMPANY F
ON R.CK = F.MANAGER_ID
)
WIDTH OF SEARCH FIRST BY CK ORDR SET
SELECT A.LVL, A.CK, A.PK, A.HIER, ORDR
THE RSFC HAS
ORDER BY ORDR
0 1 FRED 1 1 2 1 FRED/BARNEY 2 1 3 1 FRED/WILMA 3 2 4 3 FRED/WILMA/BETTY 4 2 5 3 FRED/WILMA/PEBBLES 5 3 6 4 FRED/WILMA/BETTY/BAM-BAM 6 3 7 4 FRED, WILMA, BETTY, DINO 7 3 8 4 FRED, WILMA, BETTY, HOPPY 8 First part, I believe, as well, explains Frank
next part in bold, I need to understand
Thanks and respect.
Guylaine
Hi, lyly,
You said that you did not understand the part highlighted in your query. It looks like the 2 lines are highlighted:
WIDTH OF SEARCH FIRST BY CK ORDR SET
SELECT A.LVL, A.CK, A.PK, A.HIER, ORDR
I guess that it's a typo. The 2nd day of these lines is just the main SELECT clause; This is the 1st line, the clause of the SEARCH, who really needs an explanation.
As far as I know, the SEARCH clause is only for the sorting of the results. In other words, the a WITH recursive clause results will be the same, no matter what you put in the SEARCH clause, or if you omit the clause of RESEARCH. The only purpose of the clause of RESEARCH is to generate the column command (ORDR in your example), which reflects where each row fits in the graph defined by your recursive query. (Maybe, if you use non-deterministic user-defined functions, it can be a difference in the results. Chances are, you never have to worry about this).
If you do not use a clause in RESEARCH at all, it seems like by default
WIDTH OF SEARCH FIRST BY NULL...
In other words, the lines appear in order by level and in no particular order after that. In your case, that would mean 'FRED' would come first, then "BARNEY" and "WILMA" (not necessarily in that order), followed by all the children of 'BARNEY' or 'WILMA' and so on. No column order would be generated, so you could not guarantee order in the ORDER BY clause.
I'm not sure that there is nothing you can do with a clause of RESEARCH that you can not do without a. In other words, the SEARCH clause automatically generates a command column. I believe you can still create an equivalent ordering column in the recursive query itself. In your example, you could say
ORDER BY lvl, ck
to get the results sorted the same way. Sometimes, using a SEARCH clause is much more convenient, and I bet that sometimes it is therefore more effective, too.
2937991 wrote:
Hi all
I'm using oracle 11.2.0.4
I m using this for the purpose of learning
Below is my table and insert statement
CREATE TABLE COMPANY (NUMBER EMPLOYEE_ID, EMPLOYEE_NAME VARCHAR2 (30), NUMBER OF MANAGER_ID)
INSERT INTO THE COMPANY'S VALUES (1, 'FRED', ");
SOCIETY VALUES (2, 'BARNEY', '1');
...
As always, thank you for posting this information: it really helps!
Manager_id is a NUMBER, it would be better if you don't quote it. In other words, it would be more clear, more effective and less prone to say:
INSERT INTO COMPANY (EMPLOYE_ID, EMPLOYEE_NAME, MANAGER_ID) VALUES (1, 'FRED', NULL);
INSERT INTO COMPANY (EMPLOYE_ID, EMPLOYEE_NAME, MANAGER_ID) VALUES (2, 'BARNEY', 1);
...
In this example, the unnecessary quotation marks do not hurt a lot, but they do not help all.
-
As for the Clause on Oracle 10 g db
Hi experts,
I had little doubt about my simple request
When I go through the black book of Oracle for db10g article on the clause
They stated something like thisSELECT * FROM EMPLOYEES (EMPLOYEE_ID = '1981');
on the clause simliar to the place where clause.
SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID = '1981'.
When I run this statement .it fine.
' using ' ON clause ' instead of ' where clause.
He didn't accept the clause on, run the command not properly ended sql.
where I'm not kidding...?
Thank you & & looks
ADF7.
Version
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionOracle provides the clause TO specify join conditions in the SELECT statements involving multiple tables. It is independent of data types and column names. As the USING clause, the clause and NATURAL JOIN are mutually exclusive.
In cases where the tables participating are more two CLAUSES, Oracle uses the first specification of the clause to join the two tables. He uses the second ON the specification of the clause to combine the next table with the result of the join of the first.
The key word THERE is also used in other contexts, such as in GRANT and INDEX statements.Notes:
After the keyword ON the join condition is written, in general, it can contain predicates connected with Boolean AND, OR, and NOT
The order of the tables is not relevant
The use of parentheses are optional in syntax, but the readability of the increasesSyntax example:
SELECT
FROM TABLE_1
JOIN TABLE_2
ON (join condition)
Usage example:
The SQL query below shows the employee's name and the name of Department of their work:
SQL > SELECT E.ENAME, D.DNAME
EMPLOYEE E JOIN DEPT D
WE (E.DEPTNO = D.DEPTNO)
Maybe you are looking for
-
Satellite U405-SP2803 turn it self
Hello my laptop turns on as at 03:50, so I wake up n try turning it off, but when I open the lip the screen was white, I touch the touchpad n (lol) nothing happened also press a nothing, everything was on but the screen. So I decided to press the pow
-
My problem is: when I put the SD card in the PC can not read
so, how I can use?
-
Recently, I reformatted the hard drive and installed Windows 7. Since that time, the sound comes not through the headphone jack. Internal speakers not turn off when the headset is connected and I don't see the icon of headset anywhere in the audio
-
I forgot my password but I can not receive a code to reset it because I mistyped my email wrong when setting up my laptop. Is there something I can do?
-
Try to renew the Muse, it does not work?
I cancelled my subscription muse earlier, and I tried to renew it 4 DAYS ago. They said, it will be renewed in 24 hours, but it shows again I have an expired subscription. My payment details are correct etc so what happens?