SQL & PL/SQL :: Determine If / When Hierarchical Circular Reference Will Occur?
May 6, 2011
I'm trying to determine if/when a possible Hierarchical circular reference will occur in my data
Sample Hierarchical structure that I have
Emp -> Supv
A
BA
CB
DC
EC
[Code]....
Finally, to my question. It seems that I can detect the problem After it happens but do I need a trigger on the update statement to detect if/when a possible circular reference will occur?? or can I run a sql statement prior to update to detect possible circular reference?
i have implemented dataguard successfully, but later on standby machine will change and i use another machine for standby and implement dataguard from beginning but it will generate the below mention error after executing duplicate target database for standby dorecover command.
contents of Memory Script: { switch clone datafile all; }
Now I have another db where I wish to import the above dump. This is not a empty db, however, I have dropped the particular user from this db for which I have created a dump above. Then I have created the same user using 'create user....'.And now I am trying to import the above dump into this.
import goes fine but I gets the circular synonym error for some of the types.
IMP-00003: ORACLE error 4055 encountered ORA-04055: Aborted: "O_BULK_TARGET_SELECTOR" formed a non-REF mutually-dependent cycle with "T_GENERAL_IDLIST". ORA-06550: line 5, column 25: PLS-00421: circular synonym 'PUBLIC.T_GENERAL_IDLIST'
The db from which I created the dmp has no errors for these objects, but while impoting it gives these errors.I have even tried taking the whole database dmp(not a particular user), and importing it into full empty database. Then also I gets the same error.
SQL> select view_name , text from dba_views where VIEW_NAME='EMP1_VIEW';
VIEW_NAME TEXT
EMP1_VEW select empid , ename , qual, dept from emp1 where empid between 1000 and 1010
Now i tried to use create or replace option
SQL>create or replace view emp1_view as *2 select * from emp1_view with read only;* create or replace view emp1_view as *+ ERROR at line 1: ORA-01731: circular view definition encountered
Actually i want to make read only view (emp1_view) ; without doping ;
I don´t care about the order of the values in the row. In other words, I want to get disjoint sets of data connected by any of both values.Every pair in the input table is unique.
I have seen in the web that it is possible to do using connect by and hierarchical retrieving but I've been trying to make a lot of combinationts and I can reproduce the output.
I have a table that holds the definition of schedules, a schedule defines when a document should be submitted to a specific party. The schedule definition contains a start date, and end date, a recurrence type (is this submitted one time, or on a recurring schedule) and the frequency at which the document should be submitted. The second table provides a history of the submissions, this stores when it was due and when it was received. At the beginning of the month we pre-populate the submittal table with a list of records that will be due for the month. For instance, on September 1 we look through all of the schedules and determine which ones would have a record due at some point in 9/12 and then create a record in the submittal table.
I am having issues getting the calculated list of submittal records to work properly.
The DDL and DML will be in a follow-up post
Here is the query that I am currently using and fails to work properly.
with schedules as ( -- generate a list of valid permit schedules select s.schedule_id,s.submittal_frequency_months,s.recurrence_type, s.first_due_date,s.requires_approval, round(round(months_between(to_date('09/01/2012','mm/dd/yyyy'),s.first_due_date))/decode(s.submittal_frequency_months,0,1,s.submittal_frequency_months)) recurrence_number
[Code]....
-- create a list of all potential due dates for these schedules
select submittal_id_seq.nextval,schedule_Id,8,requires_approval, case when recurrence_type='One Time' then first_due_date when recurrence_type='Recurring' and trunc(first_due_date)=to_date('09/01/2012','mm/dd/yyyy')
[Code]....
-- exclude those that already have a submittal record ;
Basically I found all possible records in the schedule table that could have a record due in September, then generate a result for all possible instances and then look at only those whose calculated due date is 09/01/2012. I've determined that the root problem I have right now is this line:
(select level iteration from dual connect by level <= (select max(schedules.recurrence_number) from schedules)) d
Schedule ID 469907 has a start date of 05/15/1992 and a frequency of every 2 months. I calculate what I call the recurrence number, which is the number of times the schedule has happened since its start date to now. I use that to do an add_months calculation from the start date and then eventually compare these calculted start dates with my target month (09/12). In this one records case the calculated recurrence number is 122. So when I generate the connect by level is does 122 records for every schedule, so I end up with duplicate records in the submittal table for many of the schedules. This current query could probably work if I could figure out a way to make the level be schedule ID specific, but I've failed at that thus far.
Aside from the fact that this is returning the wrong results, I am thinking there must be a better more efficient method to determine which records are due for a given month. I was thinking there is probably some cool way to use the model clause here, but I haven't got a grasp on that one yet.
If you run the following insert statement you'll see that it inserts over 2400 records:
insert into submittal (submittal_id,schedule_id,submittal_status_type_id,requires_approval,due_date,created_by,created_date,modified_by,modified_Date) with schedules as ( -- generate a list of valid permit schedules select s.schedule_id,s.submittal_frequency_months,s.recurrence_type, s.first_due_date,s.requires_approval,
[Code]....
-- only submittals whose last due date has not passed, null last date included
and trunc(s.first_due_date,'mm') <= to_date('09/01/2012','mm/dd/yyyy') -- only valid start dates --and round(round(months_between(to_date('09/01/2012','mm/dd/yyyy'),s.first_due_date))/decode(s.submittal_frequency_months,0,1,s.submittal_frequency_months)) >0 )
-- create a list of all potential due dates for these schedules
select submittal_id_seq.nextval,schedule_Id,8,requires_approval, case when recurrence_type='One Time' then first_due_date when recurrence_type='Recurring' and trunc(first_due_date)=to_date('09/01/2012','mm/dd/yyyy')
[Code]...
You can see the problem after words:
select schedule_id,count(0) from submittal where trunc(due_date,'mm')=to_date('09/01/2012','mm/dd/yyyy') and submittal_status_type_id=8 having count(0) >1 group by schedule_id;Tony
We are investigating performance of SQL executions on a database server and we suspect I/O on the server is an issue
For example one particular statement accesses one row during execution (index access) and still takes 2.4 seconds out of which it does I/O for 1.9 seconds
which of the following sections in the AWR will give us the correct information about the I/O, it is slow or not?
1) Load Profile Logical reads per second Physical reads per second
2) Top 5 Timed Foreground Events waits / time(s) for events like "db file sequential/scattered read" average wait(ms) for events like "db file sequential/scattered read"
3) Foreground Wait Events db file sequential read db file scattered read
4) Wait Event Histogram %of waits <1ms <2ms Disk file operations I/O db file sequential read db file scattered read
5) Wait Event Histogram Detail (64 msec to 2 sec) Wait Event Histogram Detail (4 sec to 2 min)
6) IOStat by Function summary Buffer Cache Readsreads per sec
The data in the table was imported from a csv file and there is a relationship between the rows. Each combination of col1, col2 and col3 describes a full route of a journey. The row with an entry in col6 describes the full route and the other rows describes each leg in the route.
For example, for R1, the route is AA to BB via CC. Another example for R4 the route is FF to SS via XX, PP, and OO.
What i would like to do is missing a route. For example the route for R3 is DD to EE via FF. There is an entry for DD to FF but is missing an entry for FF to EE.
The results should return the following rows which are incomplete
Here is what i have come up with but it doesnt quite returned the correct result.
select * from tableA a Where not exists( select 1 from tableA b where instr(col6,col4,1)>0 and instr(col6,col1,1)>0) And a.col1=b.col1 And a.col2=b.col2 And a.col3=b.col3 )
I am trying to determine the number of times a value appears and display the count. However the value can only be counted once per 'trip' even though it may appear several times per trip.
with the above data the expected value would be two because the trip id appears twice so it was just the one trip - given a count of one. I am not sure how create a query to check this.
The db is 11.2.0.3 on a linux machine.I would like to know the "fetch size" of an application, but I was not able to find any related meteris in v$statname.
The application configruation is invisible to me.Do I need to do some calculations based on statistic metrics from v$statname?
If so, what meteris should be considered for the assumption for "fetch size" ?
The following is from manual, but the application configuration is invisible to me.
[URL]
Setting the Fetch Size
The following methods are available in all Statement, PreparedStatement, CallableStatement, and ResultSet objects for setting and getting the fetch size:
Is it possible to create a .sql script that, when executed, will determine which OS (i.e. Windows or Linux) Oracle is being hosted on? At the moment, all our scripts are written for Windows and I believe that for Linux the slashes must point the other way in order for the script to run.
Or, would the easiest thing be to create two copies of the script - one for Windows and one for Linux? :)
Quote: A.2.2 Writing Backup Scripts for Disk and Tape Scenarios
As in the disk-only scenarios, the backup scripts in this section are categorized based on database workload. as stated very clearly it depends on the workload, more precisely the rate of block change. The size of the database can be found out based on formula from
[URL]....
so how would I know the rate of block change in order to know which script is suitable for me? I try to find out the rate of block change for the database based on change tracking file but based on
[URL].....
Quote:
The size of the change tracking file is proportional to the size of the database and the number of enabled threads of redo. The size is not related to the frequency of updates to the database. So how do I determine the rate of change? can the rate of block change based on size of archive logs?
I have the following information with me:
starting from 5/10/2011 0101 ending 5/18/2011 1114
average size of each file 27,942,770,176/1644 =16996818.841849148418491484184915
average size of each day's log = 27,942,770,176/9.5 =2941344229.0526315789473684210526 about 3G
If I have a database size of 92G, based on the archive log size of about 3G per day, can I conclude that a change of 3G/92G is considered as few block change?
determine if a function is worth pinning in memory? I want to come up with a percentage, implying that if the function is already im memory 80%+ of the time then it is not worth it.
I have attempted to use the analytic function to keep a running total of the count of active calls based on the connect and disconnect times given for each record row.
I'm using apex 4.2.1.00.08 and I cannot figure out how apex manages the static files and cannot find anything in the docs (other that some high level UI description). The application is serving some file and I cannot find which one it is in any easy way.
I have a workspace where there are several files that have the same name, and I cannot understand how apex figures out which one to serve, and also don't understand what is value of associating a file with an application.
There are files associated with application 0, which don't appear to show up in the "shared components", but can be seen as
SELECT * FROM wwv_flow_files WHERE flow_id = 0;
and can apparently only be deleted using "SQL Commands" inside apex. the URL called is something like
so apparently the only parameters that matter are the workspace and the file name. The associated application is irrelevant. apparently files linked to flow_id 0 have precedence over all the other files..
I use following command to determine which table can benefit from shrinking
select * from table(dbms_space.asa_recommendations('FALSE', 'FALSE', 'FALSE')) order by reclaimable_space desc
then i give following command to get reclaimable space
alter table t1 enable row movement ; alter table t1 shrink space cascade; alter table t1 disable row movement ;
in table t1 427MB was shown as reclaimable space, after executing above commands, i run dbms_space procedure again to check the out come, but result was same.I understand tablespaces are by default ASSM in 11g, none of table has LONG datatype or LOB indexes or MVIEW with ON COMMIT.
I'd like to determine (from code defined in a button definition) which check box(es) on a Tabular Form are checked. Assuming only one check box is checked, I want to obtain one of the values in that row for further processing. How to interrogate the Tabular Form to find out which box is checked?
>select level ,empno,ename,mgr from emp connect by prior empno=mgr start with mgr is null;
Output:- > LEVEL EMPNO ENAME MGR ----- ---------- ---------- ---------- 1 7839 KING 2 7566 JONES 7839 3 7788 SCOTT 7566 4 7876 ADAMS 7788 3 7902 FORD 7566 2 7698 BLAKE 7839 3 7499 ALLEN 7698 3 7521 WARD 7698 3 7654 MARTIN 7698 3 7844 TURNER 7698 3 7900 JAMES 7698
LEVEL EMPNO ENAME MGR ----- ---------- ---------- ---------- 2 7782 CLARK 7839 3 7934 MILLER 7782
Note:- I got only this that this query is alternative of self join and it is giving manager name along with mgr id for each employee but when it gives output i couldn't able to understand how to identify who is manager of whom. Tell and explain with clause in oracle , i only know it is alternative of inline view but i want to know how does it work and how to use 'WITH' in oracle query if possible.
we have 96GB Memory on the UNIX server and 85% of its usage shows oracle processes I want to determine which Oracle processes are taking most of the memory
SGA is around 36G SGA_TARGET is 40G PGA is around 4G
the total of around 40-45 GB of usage is understandable but what other oracle process are chewing up the remaining 30-40 GB on the server is not known
load averages: 7.35, 6.46, 6.15; up 248+11:33:21 12:25:03 2202 processes: 2196 sleeping, 1 zombie, 5 on cpu CPU states: 83.8% idle, 10.5% user, 5.8% kernel, 0.0% iowait, 0.0% swap Memory: 96G phys mem, 15G free mem, 128G total swap, 128G free swap
PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND 21720 oracle 258 0 0 40G 40G cpu/48 215:28 2.04% oracle 10709 oracle 1 0 2 1816K 1448K cpu/9 0:02 0.90% res_conf_email_ [code]......
I want to display result with respective levels. for example p21 ,p30 are coming under first level . p22,p25 ,P31,P32are 2nd level. p23,p24,p26,p27 are 3rd level p28,p29 are FOURTH level item_id's.
Already I 'VE tried using CONNECT BY PRIOR clause.BUT STILL I COULDN'T GET THE RESULT.
create table test_circular_data(c1 varchar2(10),c2 varchar2(10)); insert into test_circular_data values ('c1','l2'); insert into test_circular_data values ('c1','l3'); insert into test_circular_data values ('c3','l3'); insert into test_circular_data values ('c4','l3');
commit;
There is a circular relation between columns c1 and c2, so what I'm trying to retrieve is something like that :
c1--> l2 --> l3 --> c3 --> c4
The steps to get that result is :
1.- c1 related to l2 : c1-->l2 2.- c1 related to l3 : c1-->l2-->l3 3.- l3 in the list and related to c3 : c1-->l2-->l3-->c3 4.- l3 in the list and related to c4 : c1-->l2-->l3-->c3-->c4