QUESTION: HOW TO WRITE QUERY WITH MANY TO MANY RELATIONSHIPS
Could someone help me out here?
I was sitting here looking at some tables ie table_name and synonyms and wondering.
If a table can belong to many synonyms and a synonym can belong to many tables how would one write a query where I would like to know which tables belong to each synonym or on the other hand which synonym belongs to what tables?
Would I try to develop an outside join for this, a corrolated query or a query with a subquery or would there be another format that would work better?
What would be the best method of attack on this?
Thanks for your thoughts on this.
al
Actually, the relationship is not many to many. A table can have many synonyms, but a synonym within a namespace (i.e. a PUBLIC synonym, or a private synonym created by a user) can only point to one table. The xxx_synonmys tables already contain the information about the table_name and table_owner.
John
Similar Messages
-
How to write query with low cost
hi
i want to write a query of low cost for the following scenario.
in a table
if a person got a salary >=10000 he is in grade A
if a person got salary >=7000 he is in grade B
if a person got salary >=5000 he is in grade C
if a person got salary >=3000 he is in grade D
else grade E.use CASE
case when salary >= 10000 then 'A'
when salary >= 7000 then 'B'
else 'E'
end as grade
-
How to write ! , . with virtual keyboard?
how to write ! , . with virtual keyboard?
Thanks!What do you mean by virtual keyboard?I guess he means the "Robot" class, and the answer is
to "press" shift, then press the 1 key, then release
the 1 key then release shift.Are you basing that on the steering the mouse question?
I guess. -
How to write query for this in TopLink ?
I am doing a simple search in jsp where the search will the based on the choices chosen by user.
I had given 3 check boxes for those choices.
The problem is, query will be based on the choice or choices chosed by the user.
How to write query for this in TopLink ?
Thanks in Advance..
JayaganeshTry below solution, it is NOT best solution but might work:
Declare @Questions TABLE (QuestionID INT, QuestionText Varchar(100))
INSERT INTO @Questions
VALUES (1, 'Comment'), (2, 'Score')
DECLARE @Answers TABLE (authkey INT, QuestionID INT, questiontext VARCHAR(100), answertext VARCHAR(100))
INSERT INTO @Answers
VALUES (101, 1, 'comment', 'hi!!'), (101, 2, 'score', '4'), (102, 1, 'comment', 'excellent'), (102, 2, 'score', '5'), (103, 2, 'score', '6'), (104, 2, 'score', '8')
SELECT
A.AuthKey
,Q.QuestionID
,Q.QuestionText
,A.AnswerText
FROM
@Questions Q
INNER JOIN @Answers A ON Q.QuestionID = A.QuestionID
UNION
SELECT
A.AuthKey
,Q.QuestionID
,Q.QuestionText
,Null
FROM
@Questions Q
CROSS JOIN @Answers A
WHERE
NOT EXISTS (SELECT 1 FROM @Answers SubQry WHERE SubQry.AuthKey = A.AuthKey AND SubQry.QuestionID = Q.QuestionID)
Output
AuthKey | QuestionID
| QuestionText
| AnswerText
101 | 1 | Comment | hi!!
101 | 2 | Score | 4
102 | 1 | Comment | excellent
102 | 2 | Score | 5
103 | 1 | Comment | NULL
103 | 2 | Score | 6
104 | 1 | Comment | NULL
104 | 2 | Score | 8
Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered. -
How to write strings with an underline on the TOP-OF-PAGE of ALV
How to write strings with an underline on the TOP-OF-PAGE of ALV
if u r using classes and methods it can be done
but if u r using normal fms and then u have to use HTML_TOP_OF_PAGE but the drawback for this it cannot be printed when the report is printed . -
How to write query to list all the employees of deptno 20
Hi ,
I am new to Oracle...Recently I got job.... Could you please help me....
How to write a query for
1) List all the Clerks of Deptno 20 and
2) List the emps along with their exp and whose daily salary is more than 100rsits not wrong that you ask , but this is basic question and my suggestion is to start reading some manual specially since you got job , Read oracle documentation gogole what you want if you didn't find any answer post here and we will help you .
Check this link
http://www.oracle-dba-online.com/sql/oracle_sql_tutorial.htm
http://www.w3schools.com/sql/default.asp
http://www.java2s.com/Tutorial/Oracle/CatalogOracle.htm
And you will find more & more .. create your own vmware oracle provide with learning database called XE (express edition) test it and hope this information is useful for you -
Designer beginner's question: How to populate form with XML web service output?
sorry, here is yet another Adobe Designer beginners question: <br /><br />My form uses a webservice data connection which returns <br />an xml-string like this: <br /><br /><?xml version="1.0" encoding="utf-16"?> <br /><CurrentWeather> <br /> <Location>Sion, Switzerland (LSGS) 46-13N 007-20E 481M</Location> <br /> <Time>Apr 26, 2007 - 09:50 AM EDT / 2007.04.26 1350 UTC</Time> <br /> <Wind> from the WSW (240 degrees) at 15 MPH (13 KT):0</Wind> <br /> <Visibility> greater than 7 mile(s):0</Visibility> <br /> <SkyConditions> partly cloudy</SkyConditions> <br /> <Temperature> 80 F (27 C)</Temperature> <br /> <DewPoint> 46 F (8 C) </DewPoint> <br /> <RelativeHumidity> 30%</RelativeHumidity> <br /> <Pressure> 29.88 in. Hg (1012 hPa)</Pressure> <br /> <Status>Success</Status> <br /></CurrentWeather> <br /><br />What is the simplest and recommended way to extract the <br />element fields to my form? <br /><br />Thank you very much an kind regards, <br />Hans Grund
The question is still unanswered!
Let me give some details and break up the problem
in more specific questions:
- In Designer 8.1 I click new data binding --> wsdl -->
http://www.webservicex.net/globalweather.asmx?wsdl
A message box comes up and says "cannot load wsdl file"
==> 1. Question:
Why maybe refuses Designer to load the http-wsdl,
although this option is explicitly allowed?
- When I save the wsdl to a file, Designer loads it
without any problems. The web service uses two input parameters
(CountryName and CityName) and returns an xml-string GetWeatherResult)
like the one in my first posting. I drag these fields from the binding view to my form, and it runs ok!
- THE PROBLEM IS, THAT I NEET TO EXTRACT THE ELEMENT FIELDS
FROM THE RESULT XML-STRING!
==> 2. Question:
How to extract xml element fields from wsdl output into a form?
- I tried with eclipse and XmlSpy to build a modified wsdl file
with structured output definition, so that the specific element fields
show up in the data binding view and are usable to my form,
and the modified wsdl maps consistently to the web service result string.
So far without success: In the PDF -preview or Reader-
when the wsdl-binding is executed and the web service output
should show up in the result fields, just nothing happens.
==> 3. Question:
Can this strategy to provide a "modified wsdl" possibly succeed,
and how?
==> 4. Question:
Is is possible -and how?- to check whether an xml string
is valid as web service output against the wsdl-definition?
==> 5. Question:
How to debug a web service connection with Designer?
- Finally I tried to find a way to load the result xml-string
into a local var in the script editor and parse it, much like:
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.load(DataSet.MyForm.GetWeatherResult.rawValue);
==> 6. Question:
Is it possible -and how?- to use a framework like dotnet?
How to utilize SAX or DOM in Designer?
Many thanks and appreciations for your help!! -
How to write XML with attributes to a table in Oracle?
I tried to find solutions over the internet. Some of the stuff I looked at:https://forums.oracle.com/thread/2182669 http://www.club-oracle.com/forums/how-to-insert-data-from-xml-to-table-t2845/
In all these cases, the solution considers XML structure with only nodes and child nodes but not attributes. In fact, one of the solutions suggests transforming the XML into a canonical form with only nodes w/o attributes.
This is a sample of xml structure I am working with:
Sample XML
<rep type="P" title="P List"> <as> <a id="3" /> <a id="4" /> </as> </rep>
I am working with oracle client 11.2 and SQL developer
My question is: how to write XML data into a table with attributes also as column values, beside the nodes?My question is: how to write XML data into a table with attributes also as column values, beside the nodes
The question you should be asking is : "how do I access attributes in the XPath language?"
and the answer to that is easily found in any XPath tutorial you may find over the Internet, it is not related to Oracle in particular.
Short answer : you use an "attribute::" axis before the attribute name, or more commonly a "@", e.g. @type, @id etc.
Using the method described in the first link, something like this will extract the root attributes :
SELECT x.*
FROM XMLTable(
'/rep'
passing <xmltype variable/column goes here>
columns type varchar2(1) path '@type'
, title varchar2(30) path '@title'
) x ;
For deeper levels, use additional XMLTable calls as described in the mentioned post. -
Re-write query with ANY operator
Hi,
How to write the given query using 'ANY ' operator , I dont need to fetch to grade_master table twice in database, just need to fetch within the result set.
SELECT dsg_code,dsg_name,dsg_grade FROM designation_master WHERE dsg_orgn='&&Orgn' and dsg_ctry='&&ctry'
And dsg_loc ='&&loc' And dsg_oru = '&&oru' and dsg_grade in decode('&&radio_group',
1, SELECT grd_code FROM grade_master WHERE grd_osm_code in (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&Orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'),
2, SELECT grd_code FROM grade_master WHERE grd_osm_code > (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' and grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code),
3, SELECT grd_code FROM grade_master WHERE grd_osm_code < (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'))
thanks
rincyplease post your question in separate SQL and PL/SQL section this is FORMS section
-
Some basic questions how to handle Exceptions with good style
Ok I have two really basic Exception questions at once:
1. Until now I always threw all exceptions back all the way to my main method and it always worked well for me but now I am sitting at a big project where this method would explode the programm with throwings of very many exceptions in very many methods. So I would like to know if there is a more elegant solution.
2. What do I do with exceptions that will never occur?
Lets say I have a method like this:
void main() {calculate();}
void calculate()
sum(3,5);
void sum(int a,int b)
MathematicsA.initialise("SUM"); // throws AlgorithmNotFoundException, will never occur but has to be handled
}So what is the most elegant way?:
h4. 1. Ignore because it will not happen
void sum(int a,int b)
try {MathematicsA.initialise("SUM");}
catch(AlgorithmNotFoundException) {}
}h4. 2. Print stacktrace and exit
void sum(int a,int b)
try {MathematicsA.initialise("SUM");}
catch(AlgorithmNotFoundException e)
e.printStackTrace();
System.exit();
}h4. 3. throw it everywhere
void main() throws AlgorithmNotFoundException, throws ThousandsOfOtherExceptions {}
void calculate() throws AlgorithmNotFoundException, throws HundretsOfOtherExceptions
sum(3,5);
void sum(int a,int b) throws AlgorithmNotFoundException
MathematicsA.initialise("SUM");
}h4. 4. Create special exceptions for every stage
void main() throws MainParametersWrongException
try {calculate();}
catch(Exception e)
throw new MainParametersWrongException();
void calculate() throws SumInternalErrorException
try {sum(3,5);}
catch (SumInternalErrorException) {throw new CalculateException();}
void sum(int a,int b) throws SumInternalErrorException
try
MathematicsA.initialise("SUM");
} catch (AlgorithmNotFoundException e) {
throw new SumInternalErrorException();
}P.S.: Another problem for me is when a method called in a constructor causes an Exception. I don't want to do try/catch everytime I instantiate an object..
Example:
public class MySummation()
Mathematics mathematics;
public MySummation()
mathematics.initialise("SUM"); // throws AlgorithmNotFoundException
void sum(int x,int y)
return mathematics.doIt(x,y);
}(sorry for editing all the time, I was not really sure what I really wanted to ask until i realised that I had in fact 2 questions at the same time, and still it is hard to explain what I really want to say with it but now the post is relatively final and I will only add small things)
Edited by: kirdie on Jul 7, 2008 2:21 AM
Edited by: kirdie on Jul 7, 2008 2:25 AM
Edited by: kirdie on Jul 7, 2008 2:33 AM
Edited by: kirdie on Jul 7, 2008 2:34 AMsphinks wrote:
I`m not a guru, but give my point of view. First of all, the first way is rude. You shouldn`t use try with empty catch. "rude" isn't the word I'd use to describe it. Think about what happens if an exception is thrown. How will you know? Your app fails, and you have NO indication as to why. "stupid" or "suicidal" are better descriptions.
Then for the second way, I`ll reccomend for you use not printStackTrace(); , but use special method for it:
public void outputError (Exception e) {
e.printStackTrace();
}It`ll be better just because if in future you`d like to output error message instead of stack of print it on GUI, you`ll need change only one method, but not all 'try' 'catch' statements for changing e.printStackTrace(); with the call of new output method.I disagree with this. Far be it from me to argue against the DRY principle, but I wouldn't code it this way.
I would not recommend exiting from a catch block like that. It's not a strategy for recovery. Just throw the exception.
Then, the third way also good, but I suppose you should use throws only if the caller method should know that called method have a problem (for example, when you read parametrs from gui, so if params are inccorect, main method of programm should know about it and for example show alert window)."throw it everywhere"? No, throw it until you get to an appropriate handler.
If you're writing layered applications - and you should be - you want to identify the layer that will handle the exception. For example, if I'm writing a web app with a view layer, a service layer, and a persistence layer, and there's a problem in the persistence tier, I'd let the service layer know what the persistence exception was. The service layer might translate that into some other exception with some business meaning. The view layer would translate the business exception into something that would be actionable by the user.
And in all other cases I suppose you should use the fourth way. So I suppose it`s better to combine 2,3,4 ways as I have mentioned above.I don't know that I'd recommend special exceptions for every layer. I'd reuse existing classes where I could (e.g., IllegalArgumentException)
Sorry, I can give you advice how to avoid problem with try-catch in constructor. :-(You shouldn't catch anything that you can't handle. If an exception occurs in a constructor that will compromise the object you're trying to create, by all means just throw the exception. No try/catch needed.
You sound like you're looking for a single cookie cutter approach. I'd recommend thinking instead.
% -
How to write query group by time(minutes)
Hi,
i am writting query like this.
select host_id,pd_user, pdUserUtil,
timestamp from
(select host_id,pd_user,
avg(pd_cpu) pdUserUtil,
to_Char(PD_REPORTED_TIMESTAMP,'yyyy-mm-dd hh:MI') timestamp
from sp_process_detail_current SP
where exists (select * from
sp_process_detail_current
having
max(PD_REPORTED_TIMESTAMP)-sp.PD_REPORTED_TIMESTAMP<5/1440)
group by pd_user,host_Id,to_Char(PD_REPORTED_TIMESTAMP,'yyyy-mm-dd hh:MI'))
where host_id='DSCP04881' and pd_user='TOMCAT'
TIMESTAMP PD_USER
2006-06-30 08:07 TOMCAT
2006-06-30 08:08 TOMCAT
2006-06-30 08:10 TOMCAT
BUT WHILE ACCESSING IN JAVA
java.lang.NumberFormatException: For input string: "30:08:07"
at java.lang.NumberFormatException.forInputString(NumberFormatException.Question: What datatype in Java are you using as placeholder for the timestamp column?
It's only taking the "2006-06-" part.
Post here the java code (an exceprt of course), though I feel there's better forums for this subject. -
Hi
I have UDF on form. How to make query, to choose values values from OITM in U_MODEL where U_BRAND = definite valueHi,
1.Use same query (as attached in screen shot) and assign to U_model as per attached below.
2. To get list, just Press shift + F2 at U_model
Thanks & Regards,
Nagarajan -
Hi,
I need expert advice.
on daily basis we are updating meter reading ( meter reading is nothing but "meter number / unit / date".
Let say there are 10 apartment and each apartment has separate meter.
i need to write query get missing meter reading on a specific date.
ThanksUnit Master
401
402
403
404
Daily Meter Reading
date unit meter
01-01-01 1 401
01-01-01 1 402
01-01-01 1 404 ( on 1st of jan user update the meter reading but if you notice unit number 403 is missing)
02-01-01 1 401
02-01-01 402 ( on 2nd of jan user update the meter reading but if you notice this time 402 is meter unit is missing)
02-01-01 1 403
02-01-01 1 404
03-01-01 401
03-01-01 1 402
03-01-01 1 403 ( on 3rd of jan user update the meter reading but if you notice this time meter unit is missing for 401 and 404 is unit is missing)
We want the following output
if user run report on 1st of jan system should return value of 403 unit number
if user run report on 2nd of jan then system should return value of 402 unit number
if user run report on 3rd of jan then system should return value of 401/404 unit number
Hope this help to get my expected answer. -
How to write Sql statement for M:M relationship set?
If theres two Entity sets "Department" and "Employee".....
Department Entity contains this attribute dno,dname,address etc and
"Employee" entity contain attribute like Empno,Empname,date,time etc
and theres Many to Many relationship between Employee and Deapartment Entity set,i.e.each employee can work in any department, and each department has at least one employee (Many to Many relationship)
What should be the SQL statement to create table for Many to Many relationship sets for Employee and Department set..
Any helps will be appreciated.
Femicreate 3 tables: employee, department and empdept
in the empdept table you reference foreign keys from the 2 other tables. so if my employee id was 42 and I work for departments 1,2 and 3, this table would look like this:
emp_fk | dept_fk
42 1
42 2
42 3 -
Sql question how to write this query
This is my query:
SELECT msi.segment1 item, bsd.operation_code, bd.department_code,
bsd.operation_description
FROM mtl_system_items msi,
bom_operational_routings bort,
bom_operation_sequences bos,
bom_departments bd,
bom_operation_resources br,
bom_resources bor,
bom_standard_operations bsd
WHERE msi.inventory_item_id = bort.assembly_item_id
AND msi.organization_id = bort.organization_id
AND bort.routing_sequence_id = bos.routing_sequence_id
AND bos.department_id = bd.department_id
AND bd.department_id = bsd.department_id
AND bos.standard_operation_id = bsd.standard_operation_id
AND bos.operation_sequence_id = br.operation_sequence_id
AND bor.resource_id = br.resource_id
AND bos.reference_flag = 1
AND msi.organization_id = '82'
AND bos.disable_date IS NULL
GROUP BY msi.segment1,
bsd.operation_code,
bd.department_code,
bos.operation_description,
bsd.operation_description,
bor.resource_code
Which essentially produces this output:
Item Op code Dept Description
123 10 Warehouse Move parts
123 20 Assembly Finish Parts
123 30 Inspection Complete
I need to capture when the part goes into Inspection and from where it came, so in this case, From Assembly to Inspection.
I don't even know where to start
Thanks for any directionNot sure I've got the columns names right from your example, but does this get you started at all?
It sounds like you might need an analytic function like LAG or LEAD.
with t as
(select 123 item, 10 op, 'Warehouse' code, 'Move' dept, 'parts' description
from dual
union
select 123, 20, 'Assembly', 'Finish', 'Parts'
from dual
union
select 123, 30, 'Inspection', 'Complete',null
from dual)
select *
from (
select item, op, code, dept, description, lag(code) over (partition by item order by op) previous_code
from t
where code = 'Inspection';
ITEM OP CODE DEPT DESCR PREVIOUS_C
123 30 Inspection Complete AssemblyMessage was edited by:
dombrooks
Maybe you are looking for
-
11i Advanced Pricing Questions on usage of Item Category Segment Values
Hi All, we are on 11i, i am trying to setup on modifiers using Item Categories. Customer has 4 segment category structure. Category structure= Vendor, Group, Style, Price code , here is how Data looks = 060.10.800.40 In 11i, can we setup Modifiers on
-
Thumbnail images in Lightroom.
In Bridge you can enhance imported thumbnail images to a high quality, however in Lightroom 3 or 4 this does not appear to be the case, with images appearing of a lesser quality. Is there a process in Lightroom which will enhance thumbnail images to
-
I can't find anything about how to properly manage the tablet's layout in horizontal or in vertical position. If I consult my website in vertical position, it's ok but, If I turn my tablet, all the hyperlinks and all general visualization are wrong.
-
My first Mac and questions on TV
So after 12 years of PC, I went ahead and bought my first Mac... a Macbook Pro... things are sooooo different... and simplified... Seeing the high quality of video display on Mac, I was looking for the following solution - I would like to (1)Wireless
-
I brought new Ipad air, when ever I try to delete apps, ipad air crashes, tries many times unable to remove apps.