General Query to identify parent columns and child columns in a table
Does anyone know a general query that can be run to identify the child records associated with the parent column within a single table.....and between other tables?
Am I correct in assuming the parent column is the 'primary key'?
Thanks.....I'm a new to oracle...and need some help understanding
my company's crazy DB structure
You can use
User_Constraints
User_Cons_Columns
views to identify parent and child table columns
SELECT * FROM User_Constraints WHERE Constraint_Type = 'R' AND Table_Name = '<TABLENAME>';
SELECT * FROM User_Cons_columns WHERE Constraint_Name = '<Name from Above query>';
will give you columns of the parent table (if you use value from constraint_name) and of child table (if you use value from r_constraint_name).
HTH..
Similar Messages
-
How to fetch the junk values of a column and the column name in oracle
Hello,
Can anyone help me in writing a procedure/dynamic SQL to fetch the column where the junk values appears and its value. Eg: If emp table contains ID and Name columns, and ID column contains junk values, the result should be the Id column and the junk value/s. It should be dynamic because next time if the other column contains junk values(like $,%...), the query should display the other column too..
Thanks in advance..Try this, I'm not sure if it'll help... and get some idea...
try to modify it as per your requirement -
select * from junk_vals;
1 ranit1
2# ranit2
3 ranit3
4$ ranit@4
5 ranit5
6 r^anit6
select 'ID', id, val from junk_vals
where regexp_like(id,'[^a-zA-Z0-9]')
UNION
select 'VALUE', id, val from junk_vals
where regexp_like(val,'[^a-zA-Z0-9]');
-- "Output :"
ID 2# ranit2
ID 4$ ranit@4
VALUE 4$ ranit@4
VALUE 6 r^anit6
NOTE - I've considered anything other than Alphabets and Numbers as a Junk Value
Edited by: ranit B on Jan 4, 2013 5:07 PM
-- o/p added -
I want to know the difference between Days column and Day1 Column
Hi All,
I used this query:
SELECT to_char(return_date_time,'dd/mon/yyyy hh24:mi:ss') Test,
DECODE ('I', 'I', DECODE (1, NULL, NULL, 0, NULL, SYSDATE + 1)) Days,
DECODE ('I', 'I', SYSDATE + 1) Day1
FROM fm_curr_locn
WHERE patient_id = 'DU00002765'
output:
Test
Days
Day1
26/oct/2013 00:00:00
26-OCT-13
10/26/2013 3:06:59 PM
I want to know the difference between Days column and Day1 column and why the days column didnt show the time
Please anyone help.....
Regards
Shagar MPleiadian wrote:
It is the decode statement that is doing this.
The format of decode is:
decode(expression, search1, result1, search2, result2, searchn, resultn, default)
All result fields must be of the same datatype and will be of the datatype of the first result (result1 in this example)
In your example (the decode for the field Days) the first result is a NULL. I suspect (gurus? anyone?) that Oracle will use the varchar2 overload of the decode statement, and the date field will be converted to varchar2 using your NLS_DATE_FORMAT settings.
In the second decode statment (Day1) the first result is of datatype date, so the result of the decode statement will be a date field (and will be parsed as such by your sql development tool)
I agree, as NULL is the first result returned the datatype is undetermined, so Oracle is picking VARCHAR2 over others, and causing an implicit datatype conversion on the resultant date value, whereas the other which is returned as a date will use the local settings of the client tool being used.
I can replicate the 'issue' in Toad, and it's rectified if we cast the first returned value of the decode statement...
SELECT DECODE ('I', 'I', DECODE (1, NULL, CAST(NULL AS DATE), 0, NULL, SYSDATE + 1)) Days,
DECODE ('I', 'I', SYSDATE + 1) Day1
FROM dual -
Change URL of Edit column and Title column link that appear on AllItems.aspx
Hi there,
In the below snapshot. I am trying to change the URL of the Edit column and Title Column. By default when click on Edit Icon on each item, it opens the EditForm.aspx for that item. Similary by clicking on title of an item, it opens DispForm.aspx.
I need to change it to my custom forms, CustomEditForm.aspx and CustomDispForm.aspx . Could anybody please suggest if it can be done by any Jquery or using SPD
I know I can change the default forms from SPD.
I don't want to change the default forms. Because for some users I need to show them default forms. for some users I need to show custom forms.
Many Regards,
Khushi
KhushiHi Alex - I understand that I need to identify users. I have the following script for that. But Where should i write so that redirection applies to all the condition items in AllItem.aspx
function IsGroupMember(GroupName)
var isGroupMember = false;
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function(xData, Status) {
if($(xData.responseXML).find("Group[Name='" + GroupName + "']").length == 1)
isGroupMember = true;
else
return isGroupMember;
Khushi -
How to add one date column and charecter column
hi all,
i have 3 column start_date(date),end_date( date),duration (varchar2)
i am trying to add start_time and duration like this
end_date := to_char(start_time) + duration;
but its showing value_error
how to add one date column and charecter column.
Thanksyou need something that does:
end_date (DATE) := start_date (DATE) + <number of
days> (NUMBER)Not necessarily, because if the duration is just a string representation of a number then it will be implicitly converted to a number and not cause an error
e.g.
SQL> ed
Wrote file afiedt.buf
1 with t as (select to_date('01/07/2007','DD/MM/YYYY') as start_dt, '3' as duration_days from dual)
2 -- END OF TEST DATA
3 select start_dt + duration_days
4* from t
SQL> /
START_DT+
04-JUL-07 -
How to freeze column and row headers of a table
How to freeze column and row headers of a table in jsp and javascript. An example is available in
http://www.massless.org/_tests/grid1/ pls help to find a solutionj
Thanks in anticipation
SreejeshAt least I don't stop you from that. I also don't see any benefits in this topic.
Success. -
Delete the parent records and child table records at a time
hi all;
I am facing the pbm like to delete the all records in child table and corresponding records in parent table at a time. so I want to delete the all the records in child table and corresponding parent records in parent table by using single SQL query. plz help me
Thanks in advanceYou want to use one single SQL statement to delete the child records in a table and the corresponding master records in the master table??
That's not quite possible with a single SQL, of course unless you are talking about Oracle Forms, where you have a relation and set the delete behavior to Cascading, like said in the above posts.
Tony -
Data transfer B/W parent windonw and child window with out java script
hi ,
i am using h:outputLink Tag to open child window , i am unable to pass parent window text box value to child window with out java script , Here i am using two different backing beans for parent and child windows . Plz help me .Hi -- I pass details between pages regularly. The following has worked for me:
ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
ValueBinding binding = factory.getApplication().createValueBinding("#{beanName}");
BeanName beanProperty = (BeanName) binding.getValue(FacesContext.getCurrentInstance());
... then set the you can set the values. Can't recall if I need to use SaveStates for the items. Probably if you use request scope beans. -
How to parse XML Column and insert values into a table
Hello,
I am working on a simple project to demonstrate how to load and extract XML using SQL, I have already made a table that contains a column of XMLTYPE and loaded an XML file into it (code below)
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
I now however need to get the XML data back out of that and loaded into a new table. Troubleshooting guides I have read online seem to only be dealing with parsing an external XML document and loading it into a table, and not what I need to do which is parse a column of XML data and load that into a table. The project trivial with simple tables containing only 3 columns.
The table that needs to be loaded is as follows:
create table InventoryOut(PartNumber Number(10), QTY Number(10), WhLocation varchar2(500));
The XML document is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thank you for any help you can offer.First of all, thank you for your help!! Still stunned that you actually took the time to write out an eample using my tables/names/etc. Thank you!!
Attached is the code, there seems to be an issue with referencing the other table, Inventory.Inv, I checked and that table and the Inv column are showing up in the database so I am not sure why it is having issues locating them, take a look at the code I wrote as well as the output (*I included the real version number for you this time :)
EDIT: In your code right here:
select xt.*
3 from Inventory inve,
4 XMLTable('/dataroot/Inventory'
5 PASSING inve.Inv
I think is where I am messing it up, perhaps not understanding fully what is going on, as you write "Inventory inve" and "inve.Inv" ---- Is inve a keyword that I am just not familiar with? I think this is where the issues lies in my code.
END EDIT
EDIT2: Well that looks like it was it, changed that to how you have it and it now works!!! Could you please explain what that few lines is doing, and what the xt.* and inve are doing? Thanks again!!!
END EDIT2
drop table InventoryOut;
create table InventoryOut (PartNumber number(10), QTY number(10), WhLocation varchar2(500));
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt;
select * from InventoryOut;
select * from v$version;
table INVENTORYOUT dropped.
table INVENTORYOUT created.
Error starting at line 4 in command:
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt
Error at Command Line:8 Column:12
Error report:
SQL Error: ORA-00904: "INVENTORY"."INV": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
PARTNUMBER QTY WHLOCATION
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
If this helps here is the code and output for the creation of the Inventory table itself:
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
directory XMLSRC created.
table INVENTORY dropped.
table INVENTORY created.
1 rows inserted.
INV
<?xml version="1.0" encoding="WINDOWS-1252"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thanks again for your help so far! Hope we can get this working :)
Edited by: 926502 on Apr 11, 2012 2:47 PM
Edited by: 926502 on Apr 11, 2012 2:49 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Updated issue to solved - Edited by: 926502 on Apr 11, 2012 2:55 PM -
How to display 3 month columns and YTD column
Hello,
I need a help. My report layout requires to display the data in 3 dynamic month columns and one Fiscal year Year-to-date column for a period of time. For example, ending month is FEB:
Items : DEC : JAN : FEB : FY YTD
A : $10 : $11 : $12 : $100
B : $1 : $2 : $3 : $10
(Note: FY YTD is the total sum from OCT to FEB (5 months), not 3 months to be displayed)
I tried to create a query and use Matrix with group, but the report always display five (5) month columns
from OCT to FEB instead of displaying three (3) month columns. If the query is limited to display
three months as desired, then the total sum will be 3 displayed months only (instead of 5 months).
How to create a query or how to display three months and FY YTD or do anything else with Oracle Builder9i?
Thanks,You could use the DECODE function and variables
i.e. have a four column report
in your query use somthing like
, decode(period,:P_PERIOD1,1,0)* amount as period1
, decode(period,:P_PERIOD2,1,0)* amount as period2
, decode(period,:P_PERIOD3,1,0)* amount as period3
, amount as ytd
In your before report trigger poulate the variables with your required values -
Unique row based on two columns and single column
Dear Members,
I have a table which contains duplicate rows, for which a query should be able to fetch the unique row from the table. Here the unique is not based on one column, but it should be on two columns and also check for uniqueness on one column.
create table addr ( firstname varchar2(10), lastname varchar2(10), area varchar2(3));
insert into addr values('bob', 'james', '1');
insert into addr values('bob', 'james', '1');
insert into addr values('harry', 'bert', '1');
insert into addr values('jimmy', 'bert', '1');
insert into addr values('sam', 'mac', '1');
insert into addr values('sam', 'knight', '1');
insert into addr values('tom', 'sand', '1');
insert into addr values('cat', 'mud', '1');
The output of query should contain 3 rows.
bob - james
harry - bert or jimmy - bert [ either one of them, but not both ]
sam - mac or sam - knight [ either one of them, but not both ]
tom - sand
cat - mud
SELECT firstname, lastname as total from addr WHERE area = '1' GROUP by firstname,lastname; This does not take of single column duplication..
Any suggestions..SQL> with t_data
as
select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all
select 'bob', 'james', '1' from dual union all
select 'harry', 'bert', '1' from dual union all
select 'jimmy', 'bert', '1' from dual union all
select 'sam', 'mac', '1' from dual union all
select 'sam', 'knight', '1' from dual union all
select 'tom', 'sand', '1' from dual union all
select 'cat', 'mud', '1' from dual
SELECT
firstname,
lastname,
area
FROM
SELECT
t.*,
row_number() over(partition BY firstname order by 1) rn,
row_number() over(partition BY lastname order by 1) rn1
FROM
t_data t
WHERE
rn = 1
AND rn1 =1 ;
FIRSTNAME LASTNAME AREA
bob james 1
cat mud 1
jimmy bert 1
sam knight 1
tom sand 1
SQL> -
How to enter a data into the specified column and row in a created table
Hi,
I want to enter some data to specified column and row in a already created table. Please let me know how to do this.
Regards
Shivakumar SinghA table is just a 2D array of strings. Keep it in a shift register and use "replace array element" to modify the desired entry programmatically.
If you want to modify it manually and directly from the front panel, make it into a control and type directly into the desired element. (In this case your program would need to write to it using a local variable).
Atttached is a simple example in LabVIEW 7.0 that shows both possibilities.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
ChangeTableEntries.vi 41 KB -
List all of the existing column and there column format and data format?
Hello Gurus,
I am new to OBIEE and i have a requirement to verify the column format and data format for all of the existing column while generating a analysis report. Is there any way i can list down all of the columns which are exposed and list there column format and data format?
For checking the individual column properties i know there is an option called 'Column Properties' but want to know all in once go.
Kindly help me and thanks in advance.
ThanksI don't think you have anything in answers to get that, Go to Repository and Utilities -> Generate Metadata Dictionary that will give columns and datatype.
Award points if it helps
~Srix -
Diff. between Formula column and Placeholder column
Can any one explain me the difference between a formula column and place holder column in Reports.
Place holder columns are used to hold a value and they are populated by formula columns and in the following places.
- the Before Report Trigger, if the placeholder is a report-level column
- a report-level formula column, if the placeholder is a report-level column
- a formula in the placeholder's group or a group below it
(the value is set once for each record of the group)
But Formula columns perform a user defined computation on one or more columns including placeholder columns. You can set the value of placeholder column in a formula column. But you cannot set the value of a formula coulmn in a placeholder column's PL/SQL.
Regards,
Siva B -
SWAP COLUMNS AND ROW IN AN INTERNAL TABLE to display in ALV
Hi ,
I want to swap all the rows in an internal table with the column of the internal table to display it horizontally in ALV grid.
e.g
1 2 3 (field names)
A P X
B Q Y
C R Z
should look like :
D A B C
E P Q R
F X Y Z
Where D , E, F in first column is already apended in new table.
Or else is there a way to rotate the ALV grid so that it can display rows as columns & columns as rows.
regardshi,
i have an internal table which is like
f1 f2 f3 f4 (column header)
A 1 2 3
B 4 5 6
C 7 8 9
the values in o/p table should be
A B C ( column header)
1 4 7
2 5 8
3 6 9
Please help!!
Maybe you are looking for
-
How to I save to an external hard drive that is used on a PC also?
I have a Iomega hard drive that i have lots of stuff on from my laptop (windows) at home. I need to be able to se it both on mac and pc as I don't have mac at home. Annoyingly the when it is plugged into the mac the external hard drive becomes read o
-
Images constantly in "working..." state
In the Library module, several of my images are constantly in 'working' state with an ellipsis "..." shown above the preview. It's as if LR is trying to generate a high res preview but cannot do so. Switching to Develop shows the high res preview cor
-
Error: The document "filename.pages" couldn't be opened.
I got a new Mac Mini and put 2009 iWork on it and immediately ran the update. I can't open any documents!! All I get is "The document "filename.pages" couldn't be opened." What is going on? I have a legitimate iWork disc and DO not want to have to bu
-
When-timer-expired hit the cursor position
Some of our forms sometimes have timers running, to monitor progress of this and that. We've found that if the timer expires when you're typing in a form field, there's a tendency for the cursor to momentarily move to the beginning of the field then
-
I have Safari 5.1.10 on my iMac 10.6.8 Snow Leopard. Constantly told need to update browser to 6.0. Software Update indicates no update available. What can I do?