View's base table ?
how do i knw the views base table...
i can view text from user_source
but i there any dictionary table which show view name and base table name..?
Hmm , jsut a note to mention that you may use , v$fixed_view_definition also.
For example,
SQL> select view_definition
2 from v$fixed_view_definition where view_name=’V$LOG’;
VIEW_DEFINITION
select GROUP# , THREAD# , SEQUENCE# , BYTES , MEMBERS , ARCHIVED , STATUS , FI
RST_CHANGE# , FIRST_TIME from GV$LOG where inst_id = USERENV(’Instance’)
SQL> select view_definition
2 from v$fixed_view_definition where view_name=’GV$LOG’;
VIEW_DEFINITION
select le.inst_id, le.lenum, le.lethr, le.leseq, le.lesiz*le.lebsz, ledup, decod
e(bitand(le.leflg,1),0,’NO’,'YES’), decode(bitand(le.leflg,24), 8, ‘CURRENT’,
16,’CLEARING’, 24,’CLEARING_
CURRENT’, decode(sign(leseq),0,’UNUSED’, decode(sign((to_number(rt
.rtckp_scn)-to_number(le.lenxs))* bitand(rt.rtsta,2)),-1,’ACTIVE’,'INACTI
VE’))), to_number(le.lelos), to_date(le.lelot,’MM/DD/RR HH24:MI:SS’,'NLS_CALENDA
R=Gregorian’) from x$kccle le, x$kccrt rt where le.ledup!=0 and le.lethr=rt.rtnu
m and le.inst_id = rt.inst_id
SQL>HTH
Aman....
Similar Messages
-
Changes through views to base tables
Dear All
in which conditions oracle allow to update or make changes in base table through simple views not materialized views?a user can perform all dml transactions on normal views,so that those changes can occur in the associated tables.
simple views i.e.any select statement without any group functions or join of tables is there,we can perform all dml operations on the view. -
Need to know base table and base column name for Oracle view columns
I am trying to load metadata for some views and that requires me to know what the final table and column name would be corresponding to the view column.
For example, if I have a view x_v that is select a,b from x_v2; and x_v2 is a view that is select a,b,c from x;
I need to get the following information.
View View Col Base Table Base Col
X_V A X A
X_V B X B
and so on.
Is it possible to get this programmatically using any SYS schema tables or Dependency tables?
I tried an indirect approach wherein I lock tables using LOCK TABLE or FOR UPDATE OF. But I'm not too sure if I can go down to the level of individual view columns.
Can you help me with this?Thanks. I was looking at some indirect approaches.
I came up with this script that does it faster than dependencies but thats just for tables and not column mapping.
declare
cursor bt(cp_sid number) is
select u.name uname, o.name oname
from sys.obj$ o, sys.user$ u
where o.obj# in (select id1
from v$lock
where sid=cp_sid)
and u.user# =o.owner#;
cursor c_sid is
select sid
from v$session
where audsid =userenv('sessionid');
l_sid number;
l_view varchar2(100):= 'PER_PEOPLE_V';
l_schema varchar2(10):= 'APPS';
begin
open c_sid;
fetch c_sid into l_sid;
close c_sid;
dbms_output.put_line('SID: '||l_sid);
execute immediate 'lock table '||l_schema||'.'||l_view||' in row share mode nowait';
for i in bt(l_sid) loop
dbms_output.put_line(i.uname||'.'||i.oname);
execute immediate 'alter table '||i.uname||'.'||i.oname||' disable table lock';
execute immediate 'alter table '||i.uname||'.'||i.oname||' enable table lock';
end loop;
end;
It basically uses locks on views to verify locks on the base tables.
Just wondering, can we use FOR UPDATE OF statements to get to the columns? -
Creating View for a table with parent child relation in table
I need help creating a view. It is on a base table which is a metadata table.It is usinf parent child relationship. There are four types of objects, Job, Workflow, Dataflow and ABAP dataflow. Job would be the root parent everytime. I have saved all the jobs
of the project in another table TABLE_JOB with column name JOB_NAME. Query should iteratively start from the job and search all the child nodes and then display all child with the job name. Attached are the images of base table data and expected view data
and also the excel sheet with data.Picture 1 is the sample data in base table. Picture 2 is data in the view.
Base Table
PARENT_OBJ
PAREBT_OBJ_TYPE
DESCEN_OBJ
DESCEN_OBJ_TYPE
JOB_A
JOB
WF_1
WORKFLOW
JOB_A
JOB
DF_1
DATAFLOW
WF_1
WORKFLOW
DF_2
DATAFLOW
DF_1
DATAFLOW
ADF_1
ADF
JOB_B
JOB
WF_2
WORKFLOW
JOB_B
JOB
WF_3
WORKFLOW
WF_2
WORKFLOW
DF_3
DATAFLOW
WF_3
WORKFLOW
DF_4
DATAFLOW
DF_4
DATAFLOW
ADF_2
ADF
View
Job_Name
Flow_Name
Flow_Type
Job_A
WF_1
WORKFLOW
Job_A
DF_1
DATAFLOW
Job_A
DF_2
DATAFLOW
Job_A
ADF_1
ADF
Job_B
WF_2
WORKFLOW
Job_B
WF_3
WORKFLOW
Job_B
DF_3
DATAFLOW
Job_B
DF_4
DATAFLOW
Job_B
ADF_2
ADF
I implemented the same in oracle using CONNECT_BY_ROOT and START WITH.
Regards,
MeghaI think what you need is recursive CTE
Consider your table below
create table basetable
(PARENT_OBJ varchar(10),
PAREBT_OBJ_TYPE varchar(10),
DESCEN_OBJ varchar(10),DESCEN_OBJ_TYPE varchar(10))
INSERT basetable(PARENT_OBJ,PAREBT_OBJ_TYPE,DESCEN_OBJ,DESCEN_OBJ_TYPE)
VALUES('JOB_A','JOB','WF_1','WORKFLOW'),
('JOB_A','JOB','DF_1','DATAFLOW'),
('WF_1','WORKFLOW','DF_2','DATAFLOW'),
('DF_1','DATAFLOW','ADF_1','ADF'),
('JOB_B','JOB','WF_2','WORKFLOW'),
('JOB_B','JOB','WF_3','WORKFLOW'),
('WF_2','WORKFLOW','DF_3','DATAFLOW'),
('WF_3','WORKFLOW','DF_4','DATAFLOW'),
('DF_4','DATAFLOW','ADF_2','ADF')
ie first create a UDF like below to get hierarchy recursively
CREATE FUNCTION GetHierarchy
@Object varchar(10)
RETURNS @RESULTS table
PARENT_OBJ varchar(10),
DESCEN_OBJ varchar(10),
DESCEN_OBJ_TYPE varchar(10)
AS
BEGIN
;With CTE
AS
SELECT PARENT_OBJ,DESCEN_OBJ,DESCEN_OBJ_TYPE
FROM basetable
WHERE PARENT_OBJ = @Object
UNION ALL
SELECT b.PARENT_OBJ,b.DESCEN_OBJ,b.DESCEN_OBJ_TYPE
FROM CTE c
JOIN basetable b
ON b.PARENT_OBJ = c.DESCEN_OBJ
INSERT @RESULTS
SELECT @Object,DESCEN_OBJ,DESCEN_OBJ_TYPE
FROM CTE
OPTION (MAXRECURSION 0)
RETURN
END
Then you can invoke it as below
SELECT * FROM dbo.GetHierarchy('JOB_A')
Now you need to use this for every parent obj (start obj) in view
for that create view as below
CREATE VIEW vw_Table
AS
SELECT f.*
FROM (SELECT DISTINCT PARENT_OBJ FROM basetable r
WHERE NOT EXISTS (SELECT 1
FROM basetable WHERE DESCEN_OBJ = r.PARENT_OBJ)
)b
CROSS APPLY dbo.GetHierarchy(b.PARENT_OBJ) f
GO
This will make sure it will give full hieraracy for each start object
Now just call view as below and see the output
SELECT * FROM vw_table
Output
PARENT_OBJ DESCEN_OBJ DESCEN_OBJ_TYPE
JOB_A WF_1 WORKFLOW
JOB_A DF_1 DATAFLOW
JOB_A ADF_1 ADF
JOB_A DF_2 DATAFLOW
JOB_B WF_2 WORKFLOW
JOB_B WF_3 WORKFLOW
JOB_B DF_4 DATAFLOW
JOB_B ADF_2 ADF
JOB_B DF_3 DATAFLOW
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
ORA-01776: cannot modify more than one base table through a join view
I have created EO based on a database view than consists of two tables, and only one is updateable.
When I try to update a row using EO, I got a following message: "ORA-01776-cannot modify more than one base table through a join view"
In Forms, this issue is resolved by setting "Query Only" property of non-updateable items to "True".
Is it possible to do something like that in ADF BC?
ThanksThanks for answer.
When I set "updateable" property to "Never", that attribute is protected from any change.
I'm sorry for incomplete usecase.
I have set up a list of value on that attribute, because it is a lookup field for another table and I need to get an ID from that table.
Basically, I need that attribute to be updateble for BC, but not for database.
Edited by: MarioK on Oct 13, 2011 9:28 AM -
Cannot modify more than one base table through a join view
hi guys, my current problem is that i have a datablock based on a view, now all the fields bar 1 are updateable, but this one field that is obtained through a join is displayed, the user can enter data in this field which then pupulates other fields which are required, but this specific field should not be updated. Is there an option to state this as i keep getting the error:
cannot modify more than one base table through a join view
Any help would be greatly appreciated, thanks.the user can enter data in this field which then pupulates other fields So, using the value of "this field" you then query the rest of the fields? Can you show us the code you use to populate the rest of the fields?
but this specific field should not be updatedHave you tried setting the "Query Only" property of the field to "Yes" and the other DML properties (Ins, Upd, Del) to No?
Also, what is your Forms version?
Thanks,
Craig B-)
If someone's response is helpful or correct, please mark it accordingly. -
Create a materized view without primary key constraint on the base table?
Hi
I tried to create a materized view but I got this error:
SQL> CREATE MATERIALIZED VIEW TABLE1_MV REFRESH FAST
START WITH
to_date('04-25-2009 03:00:13','MM-dd-yyyy hh24:mi:ss')
NEXT
sysdate + 1
AS
select * from TABLE1@remote_db
SQL> /
CREATE MATERIALIZED VIEW TABLE1_MV REFRESH FAST
ERROR at line 1:
ORA-12014: table 'TABLE1' does not contain a primary key constraint.
TABLE1 in remote_db doesn't have a primary key constraint. Is there anyway that I can create a materized view on a base table which doesn't have a primary key constraint?
Thanks
LizHi,
Thanks for your helpful info. I created a materialized view in the source db with rowid:
SQL> CREATE MATERIALIZED VIEW log on TABLE1 with rowid;
Materialized view log created.
Then I created a MV on the target DB:
CREATE MATERIALIZED VIEW my_schema.TABLE1_MV
REFRESH FAST
with rowid
START WITH
to_date('04-25-2009 03:00:13','MM-dd-yyyy hh24:mi:ss')
NEXT
sysdate + 1
AS
select * from TABLE1@remote_db
SQL> /
CREATE MATERIALIZED VIEW my_schema.TABLE1_MV
ERROR at line 1:
ORA-12018: following error encountered during code generation for
"my_schema"."TABLE1_MV"
ORA-00942: table or view does not exist
TABLE1 exists in remote_db:
SQL> select count(*) from TABLE1@remote_db;
COUNT(*)
9034459
Any clue what is wrong?
Thanks
Liz -
Dear All,
I have created a materialized view which refreshes on commit.materialized view is enabled query rewrite.I have created a materialized view log on the base table also While inserting into the base table it takes lot of time................Can u please tell me why?Dear Rahul,
Here is my materialized view..........
create materialized view mv_test on prebuilt table refresh force on commit
enable query rewrite as
SELECT P.PID,
SUM(HH_REGD) AS HH_REGD,
SUM(INPRO_WORKS) AS INPRO_WORKS,
SUM(COMP_WORKS) AS COMP_WORKS,
SUM(SKILL_WAGE) AS SKILL_WAGE,
SUM(UN_SKILL_WAGE) AS UN_SKILL_WAGE,
SUM(WAGE_ADVANCE) AS WAGE_ADVANCE,
SUM(MAT_AMT) AS MAT_AMT,
SUM(DAYS) AS DAYS,
P.INYYYYMM,P.FIN_YEAR
FROM PROG_MONTHLY P
WHERE SUBSTR(PID,5,2)<>'PP'
GROUP BY PID,P.INYYYYMM,P.FIN_YEAR;
Please help me if query enable rewrite does any performance degradation......
Thanks & Regards
Kris -
REG: base table/view error
Hi,
I am trying the execute my interface last week and it was running fine but when i try to execute i am getting the following error. can any one tell me what is the cause.
0 : : org.netezza.util.PSQLException: ERROR: Base table/view 'xxxxx' attr 'MILES_DRIVEN' has changed (precision); rebuild view 'xxxx'
Thanks,
GAHi Srinivas...
I restricted the view with following selection condition.
JEST INACT NE 'X'.
After that i get like that 2 records.
Example:
EQUNR ESTAT AEDAT STSMA
000000001000000798 E0005 25.03.2004 ZE_00002
000000001000000798 E0007 30.06.2007 ZE_00002
But for that Equip number if i select the OBJNR and check the STATUS in JEST i have only one active record
050 IE000000001000000798 E0005 001
Actually then in the output u should get only record as said by you since u are getting one status value for objnr .....
Actually in our case for a particular objnr we got 6 status values out of these two status values are inactive... so we are left with 4 active status values we took thee four values and checked in text table and we got four values and in this there is one no display so we finally got three values....for a order...
we need to loop over the particular order and store all the status values into a single field ...
this cant be achieved directly through a view i gueesss we need to go for function module...
i has to implement this and i will gett back to you once it is done.....
regards
vamsi -
Getting list of base tables of view
Hi,
how to find the list of base tables of some partuicular view ?Try this
SQL>desc user_dependencies
Name Null? Type
NAME NOT NULL VARCHAR2(30)
TYPE VARCHAR2(18)
REFERENCED_OWNER VARCHAR2(30)
REFERENCED_NAME VARCHAR2(64)
REFERENCED_TYPE VARCHAR2(18)
REFERENCED_LINK_NAME VARCHAR2(128)
SCHEMAID NUMBER
DEPENDENCY_TYPE VARCHAR2(4) -
Column in base table corresponds to column in view
Hi,
I have a view based on one table. I want to know the colum name of the view is corresponds to which column names in the base table. Showing the creation statement does not help because it has many colums and I cann't track this colum to which name.
Please advise how to show this info....Just because the create statement is too hard for you doesn't mean that isn't, in fact, the way to find out. Try harder. Format the create statement - you'd be surprised how much it helps to put in indentation and carriage returns.
-
Updating base table with Materialized View's data
Hi,
In order to update base table with MVs data, I am trying real time data transfer between two databases. One is Oracle 8i and other is Oracle 9i. I have created an updatable MV in 9i on a base table using database link. The base table is in 8i. Materialized View log is created in 8i on base table. MV has to be associated to some replication group, but I am not able to create replication group in 9i to which MV has to be associated. The required packages are not installed.
Replication packages are to be used to create replication group are :
/*Create Materialized View replication group*/
BEGIN
DBMS_REPCAT.CREATE_MVIEW_REPGROUP (
gname => 'TEST_MV_GRP',
master => 'TEST_DATA_LINK',
propagation_mode => 'ASYNCHRONOUS');
END;
But above block is giving error.
Can anyone suggest how to resolve this, or are there any other approaches (by not using replication packages) to update base table with MVs data ?
Thanks,
ShaileshYes, I created link between two databases and was able to update tables on 8i from 9i database using that link.
The error I am getting while creating replication group is :
ORA-06550
PLS-00201 : identifier 'SYS.DBMS_REPCAT_UTL2@'TEST_DATA_LINK' must be declared
ORA-06550
PLS-00201 : identifier 'SYS.DBMS_REPCAT_UNTRUSTED@'TEST_DATA_LINK' must be declared
ORA-06512 : at "SYS.DBMS_REPCAT_UTL", line 2394
ORA-06512 : at "SYS.DBMS_REPCAT_SNA_UTL", line 1699
ORA-06512 : at "SYS.DBMS_REPCAT_SNA", line 64
ORA-06512 : at "SYS.DBMS_REPCAT", line 1262
Is there any other approach which can be used to update base table with MVs data instead of using replication packages ?
Thanks,
Shailesh -
Indexed views using indexes on base table
Hi all,
CREATE VIEW Sales.vOrders
WITH SCHEMABINDING
AS
SELECT SUM(UnitPrice*OrderQty*(1.00-UnitPriceDiscount)) AS Revenue,
OrderDate, ProductID, COUNT_BIG(*) AS COUNT
FROM Sales.SalesOrderDetail AS od, Sales.SalesOrderHeader AS o
WHERE od.SalesOrderID = o.SalesOrderID
GROUP BY OrderDate, ProductID;
GO
--Create an index on the view.
CREATE UNIQUE CLUSTERED INDEX IDX_V1
ON Sales.vOrders (OrderDate, ProductID);
GO
--This query can use the indexed view even though the view is
--not specified in the FROM clause.
SELECT SUM(UnitPrice*OrderQty*(1.00-UnitPriceDiscount)) AS Rev,
OrderDate, ProductID
FROM Sales.SalesOrderDetail AS od
JOIN Sales.SalesOrderHeader AS o ON od.SalesOrderID=o.SalesOrderID
AND ProductID BETWEEN 700 and 800
AND OrderDate >= CONVERT(datetime,'05/01/2002',101)
GROUP BY OrderDate, ProductID
ORDER BY Rev DESC;
In the above code block, Sales.SalesOrderDetail and Sales.SalesOrderHeader are base tables.
Say suppose there are some indexes on some of the columns of these base tables. Are these indexes used when we write a query in which indexed view is mentioned
in the from clause?
Thanks, SrikarSO far as its a indexed view it wont use the indexes on base tables when you use it in a query as indexed view is persisted and exists as a physical object. SO it doent require definition to be substituted and data to be retrieved from the base objects.
The indexes will come handy while populating the indexed view.
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Updating a Base Table through a View having UNPIVOT function.
Hi,
I have a requirement of updating a Base Table through a View.
This View has the query using a UNPIVOT function for displaying the columns of the Base tables in rows.
I need to update/insert into/delete the Base Table by accessing the View (The user doesn't have an access to the Base Table, hence the DML's on the View).
Following is the table I've created:-
CREATE TABLE PERSON_DETAILS
PID VARCHAR2(10 BYTE),
FIRSTNAME VARCHAR2(1000 BYTE),
LASTNAME VARCHAR2(1000 BYTE),
PHONENUMBER VARCHAR2(1000 BYTE),
ADDRESS1 VARCHAR2(1000 BYTE),
ADDRESS2 VARCHAR2(1000 BYTE),
COUNTRY_CODE VARCHAR2(1000 BYTE),
LANGUAGE_CODE VARCHAR2(1000 BYTE),
EMAIL VARCHAR2(1000 BYTE)
)The sample values are inserted in this table through the below script:-
insert into person_details values ('1','XYZ','ABC','1234567890','India','Asia','IN','EN','[email protected]');
insert into person_details values ('2','XYZ2','ABC2','1234567890','India','Asia','IN','EN','[email protected]');The code for the view is as below:-
CREATE OR REPLACE FORCE VIEW PERSON_DETAILS_VIEW
PID,
CD_NAME,
CD_VALUE
AS
SELECT "PID", "CD_NAME", "CD_VALUE"
FROM person_details UNPIVOT INCLUDE NULLS (cd_value
FOR cd_name
IN (firstname AS 'First Name',
lastname AS 'Last Name',
phonenumber AS 'Phonenumber',
address1 AS 'address1',
address2 AS 'address2',
country_code AS 'Country Code',
language_code AS 'Language Code',
email AS 'Email') );Below are the values from the view:-
PID CD_NAME CD_VALUE
1 First Name XYZ
1 Last Name ABC
1 Phonenumber 1234567890
1 address1 India
1 address2 Asia
1 Country Code IN
1 Language Code EN
1 Email [email protected]
2 First Name XYZ2
2 Last Name ABC2
2 Phonenumber 1234567890
2 address1 India
2 address2 Asia
2 Country Code IN
2 Language Code EN
2 Email [email protected] user would fire some statement like below:-
update person_details_view
set cd_value = 'US' where CD_NAME = 'IN'The above statement should update the base table PERSON_DETAILS.
I understand I can write an INSTEAD OF trigger but I do not know what logic to write in the trigger so that the requirement gets fulfilled.
My Oracle Version
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Solaris: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - ProductionAny help would be highly appreciated.
Thank You,
Ankit Khare.
Edited by: Ankit_Khare84 on Jun 28, 2012 2:47 PMit is definitively possible with an instead of trigger.
for Example:
create or replace
TRIGGER ioft_person
INSTEAD OF UPDATE
ON person_details_view
FOR EACH ROW
declare
firstname1 person_details.firstname%type;
BEGIN
SELECT firstname_new into firstname1
FROM (SELECT pid, cd_name, cd_value
FROM
select * from person_details_view where (pid, cd_name) not in (select :new.pid, :new.cd_name from dual)
union all
select :new.pid, :new.cd_name, :new.cd_value from dual
PIVOT ( max(cd_value) AS new FOR (cd_name) IN
('First Name' AS firstname,
'Last Name' as lastname,
'Phonenumber' as phonenumber,
'address1' as address1,
'address2' AS address2,
'Country Code' as country_code,
'Language Code' as language_code,
'Email' as email
) where pid = :old.pid;
UPDATE person_details
SET firstname = firstname1
WHERE pid = :old.pid;
END ioft_role_perm;and than run
update person_details_view
set cd_value = 'X|X' where cd_name = 'First Name' and pid=1The logic is: you must convert back the view through pivoting -
List the base tables of a view
Hi All,
I have a view but I do not have any information about the base tables and the query that was used to set up this view. Is there a way to atleast list the base tables on which the view was created!
Thanks in advance!
~SQL> desc user_source
Name Null?
Type
NAME
ARCHAR2(30) - > Name of the View.
TYPE
ARCHAR2(12)
LINE
NUMBER
VARCHAR2(4000) -> will give you the text to
create the View.-----------------------------------------------------------------------------------------------------------------------
For some reason the view I have is not listed in the NAME ..
Maybe you are looking for
-
Hi everyone, We're currently experiencing some issues saving a site as an template. This is the error we get in the event viewer: Exception information: Exception type: InvalidOperationException Exception message: Error saving solution to t
-
Deployment error in adapter module
HI , The deployment of the adapter module was successful but with exception.below is the log. Any help with this is appreciated --- Deploying file(s): C:\Users\am90001042\workspace\File_EAR\File_EAR.ear --- Status: Deploy finished with warnings. ---
-
Performance Problems with MS Access & Tomcat
Hello folks, I have a small JSP/Servlet application that uses an MS Access Database and a Microsoft Access Driver (Version 4). I use Tomcat 3.3 as the JSP server and this is within an IIS machine. The total number of users is fifty maximum of which i
-
Best way to select pixels in a low res image
Hi, I need to trace the attached logo and make it white. I've tried selecting the pixels using the quick selection tool but it's very low res and even with some tweaks (removing and adding to the selection) its still not getting a good selection. Wha
-
4.6C to ERP6.0 Upgrade - what are the recommendations for Unicode and Java
Hi All, Forgive such a basic question. We are just beginning to look at our ERP6.0 upgrade and am unclear whether we should convert to unicode at the same time, and also what are the uses for the Java stack. Unicode? We are a single language Latin-1