Help....on oracle views!!!
hi,
I've table: "pulizie_pm"
COD_IMM.........PIANO........COD_RITMI.....TIPO_SP AZIO.......AREA_LOCALI
02015149.........P01.............................. .............V..................11,20
02015149.........P01............01................ ...............................4,08
02015149.........P01.............................. .............O..................3,78
02015149.........P01............06................ ...............................296,73
02015149.........PTE.............................. .............V..................18,30
02015149.........PTE............01................ ................................5,12
02015149.........PTE............04................ ...............................14,15
02015149.........PTE............05................ ...............................32,32
02015149.........PTE.............................. .............O..................14,99
02015149.........PTE.............................. .............O..................15,21
02015149.........PTE............05................ ................................60,26
02015149.........PTE............06................ .................................53,96
02015149.........S01.............................. ..............V..................8,74
02015149.........S01.............................. ..............O..................29,55
02015149.........S01.............................. ...............O..................68,23
02015149.........S01............05................ .................................72,19
02015149.........S01............06................ .................................33,70
view N.1
CREATE OR REPLACE VIEW TEST1 ( COD_IMM,
PIANO, COD_RITMI, CONTA_RITMI, TOTAL_AREA
) AS SELECT cod_imm, piano, cod_ritmi, COUNT(COD_RITMI),SUM(area_locali) total_area
FROM pulizie_pm
WHERE cod_ritmi IS NOT NULL
GROUP BY cod_imm, piano, cod_ritmi
COD_IMM.........PIANO......COD_RITMI......CONTA_RI TMI......TOTAL_AREA
02015149.........P01.........01................... .............1..............4,08
02015149.........P01.........06................... .............1..............296,73
02015149.........PTE.........01................... .............1..............5,12
02015149.........PTE.........04................... .............1..............14,15
02015149.........PTE.........05................... .............2..............92,58
02015149.........PTE.........06................... .............1..............53,96
02015149.........S01.........05................... .............1..............72,19
02015149.........S01.........06................... .............1..............33,7
VIEW N.2
CREATE OR REPLACE VIEW MAX_TEST1 ( COD_IMM,
PIANO, COD_RITMI, TOTAL_AREA, MAX_AREA
) AS SELECT "COD_IMM","PIANO","COD_RITMI","TOTAL_AREA","MAX_AREA"
FROM (SELECT a.*,
MAX(total_area) OVER (PARTITION BY cod_imm, piano) max_area
FROM test1 a)
WHERE max_area = total_area
COD_IMM..........PIANO......COD_RITMI......TOTAL_A REA......MAX_AREA
02015149..........P01..........06................. ...........296,73............296,73
02015149..........PTE..........05................. ............92,58............92,58
02015149..........S01..........05................. ............72,19............72,19
VIEW N.3
CREATE OR REPLACE VIEW MAX_TEST1CONTA ( COD_IMM,
COD_RITMI, MAX_RITMI, TOTAL_AREA ) AS SELECT COD_IMM,COD_RITMI, sum(conta_ritmi),SUM(TOTAL_AREA)
from test1
group by COD_IMM,COD_RITMI
COD_IMM.........COD_RITMI.......MAX_RITMI.......TO TAL_AREA
02015149.........01..............................2 .................9,2
02015149.........04............................... 1.................14,15
02015149.........05............................... 3.................164,77
02015149.........06............................... 3.................384,39
VIEW N.4
CREATE OR REPLACE VIEW COD_WITH_MAX_COD_RITMI ( COD_IMM,
PIANO, COD_RITMI, TIPO_SPAZIO, AREA_LOCALI
) AS SELECT bl.cod_imm,
bl.piano,
(CASE WHEN tipo_spazio = 'O'
THEN max.cod_ritmi
ELSE bl.cod_ritmi
END) cod_ritmi,
bl.tipo_spazio,
bl.area_locali
FROM pulizie_pm bl, max_test1 max
WHERE bl.cod_imm(+) = max.cod_imm
AND bl.piano(+) = max.piano
COD_IMM..........PIANO.......COD_RITMI.......TIPO_ SPAZIO..........AREA_LOCALI
02015149..........PTE............................. ...................V....................18,3
02015149..........PTE..........01................. ........................................5,12
02015149..........PTE..........06................. ........................................53,96
02015149..........PTE..........05................. ..................O....................15,21
02015149..........PTE..........05................. ........................................60,26
02015149..........PTE..........04................. ........................................14,15
02015149..........PTE..........05................. ...................O....................14,99
02015149..........PTE..........05................. ..........................................32,32
02015149..........P01............................. ......................V....................11,2
02015149..........P01..........01................. ...........................................4,08
02015149..........P01..........06................. ....................O....................3,78
02015149..........P01..........06................. ...........................................296,73
02015149..........S01............................. .....................V....................8,74
02015149..........S01..........05................. ....................O....................29,55
02015149..........S01..........06................. ..........................................33,7
02015149..........S01..........05................. .........................................72,19
02015149..........S01..........05................. ...................O....................68,23
VIEW N.5
CREATE OR REPLACE VIEW TEST4 ( COD_IMM,
COD_RITMI, TIPO_SPAZIO, TOTAL_AREA ) AS (SELECT cod_imm,
cod_ritmi,
null tipo_spazio,
SUM(area_locali) total_area
FROM cod_with_max_cod_ritmi
WHERE tipo_spazio = 'O'
OR tipo_spazio IS NULL
GROUP BY cod_imm, cod_ritmi)
UNION ALL
(SELECT cod_imm,
Null cod_ritmi,
'V' tipo_spazio,
SUM(area_locali) total_area
FROM cod_with_max_cod_ritmi
WHERE tipo_spazio = 'V'
GROUP BY cod_imm)
COD_IMM.........COD_RITMI.........TIPO_SPAZIO..... .......TOTAL_AREA
02015149.........01............................... ...................................9,2
02015149.........04............................... ..................................14,15
02015149.........05............................... ..................................292,75
02015149.........06............................... ...................................388,17
02015149.......................................... ..V..................................38,24
Now I must create a view TO INSERT "TIPO_SPZIO=V" in COD_RITMI with greater
frequency (max(max_ritmi)), but if the max it coincides it is necessary to take the area greater.
In this case from view MAX_TEST1CONTA I get:
cod_ritmi=05 max=3
cod_ritmi=06 max=3
I tried this view:
CREATE OR REPLACE VIEW TEST_FINALCONTA ( COD_IMM,
COD_RITMI, SOMMA ) AS select cod_imm,
cod_ritmi,
SUM(total_area) somma
from (select cod_imm,
(CASE WHEN cod_ritmi IS NOT NULL
THEN cod_ritmi
ELSE (SELECT cod_ritmi
FROM MAX_TEST1CONTA
WHERE max_ritmi = (SELECT MAX(max_ritmi)
FROM MAX_TEST1CONTA) )
END) cod_ritmi,
tipo_spazio,
total_area
from test4)
group by cod_imm, cod_ritmi
I get error: ORA-01427 because max(max_ritmi) has 2 records.
If max(max_ritmi) has more one records I must take the area greater, in this case cod_ritmi=06
and i'll have this result final:
COD_IMM.........COD_RITMI.........TIPO_SPAZIO..... .......TOTAL_AREA
02015149.........01............................... ................................9,2
02015149.........04............................... ..............................14,15
02015149.........05............................... ...............................292,75
02015149.........06............................... ...........................388,17+38,24=426,41
Thanks in advance!!!!
Hi,
There are a couple of options to identify unused users. However, don't just drop them.
We just went through this on a development database. If you are on at least 10.x and are licensed to use AWR, you can:
*query dba_hist_segstat to identify those segments that have had little to no I/O
*query dba_hist_sqltext joined to dba_hist_sqlstat to see if tables to be dropped have any sql recorded for them
*query dba_hist_active_sess_history for user_id to see if the user has been "active"
In any version, you can set up database auditing to see if anyone has logged in.
Also, query dba_dependencies for users to see if stuff they own is used by someone else that would be impacted by the drop.
This covers you against "software" users (show up in ASH) that query tables owned by the "data" users (show in dba_hist_segstat) that may never directly log in.
As noted, this can produce a list for consideration to be dropped.
HTH,
Steve
Similar Messages
-
Hi all,
DB:11.2.0.3.0
EBS:12.1.3
O/S: Sun Solaris SPARC 64 bits
I am not able to view Forms Server version in Help: About Oracle Applications after the forms upgrade 10.1.2.3.0 after the forms upgrade 10.1.2.3.0 as per note:Upgrading OracleAS 10g Forms and Reports to 10.1.2.3 (437878.1)
Java/jre upgraded to 1.7.0.45 and JAR files regenerated(without force option). Able to opne forms without any issues.
A)
$ORACLE_HOME/bin/frmcmp help=y
FRM-91500: Unable to start/complete the build.
B)
$ORACLE_HOME/bin/rwrun ?|grep Release
Report Builder: Release 10.1.2.3.0 - Production on Thu Nov
28 14:20:45 2013
Is this an issue? Could anyone please share the fix if faced the similar issue earlier.
Thank You for your time
Regards,Hi Hussein,
You mean reboot the solaris server and then start database and applications services. We have two databases running on this solaris server.
DBWR Trace file shows:
Read of datafile '+ASMDG002/test1/datafile/system.823.828585081' (fno 1) header failed with ORA-01206
Rereading datafile 1 header failed with ORA-01206
V10 STYLE FILE HEADER:
Compatibility Vsn = 186646528=0xb200000
Db ID=0=0x0, Db Name='TEST1'
Activation ID=0=0x0
Control Seq=31739=0x7bfb, File size=230400=0x38400
File Number=1, Blksiz=8192, File Type=3 DATA
Tablespace #0 - SYSTEM rel_fn:1
Creation at scn: 0x0000.00000004 04/27/2000 23:14:44
Backup taken at scn: 0x0001.db8e5a1a 04/17/2010 04:16:14 thread:1
reset logs count:0x316351ab scn: 0x0938.0b32c3b1
prev reset logs count:0x31279a4c scn: 0x0938.08469022
recovered at 11/28/2013 19:43:22
status:0x2004 root dba:0x00c38235 chkpt cnt: 364108 ctl cnt:364107
begin-hot-backup file size: 230400
Checkpointed at scn: 0x0938.0cb9fe5a 11/28/2013 15:04:52
thread:1 rba:(0x132.49a43.10)
enabled threads: 01000000 00000000 00000000 00000000 00000000 00000000
Hot Backup end marker scn: 0x0000.00000000
aux_file is NOT DEFINED
Plugged readony: NO
Plugin scnscn: 0x0000.00000000
Plugin resetlogs scn/timescn: 0x0000.00000000 01/01/1988
00:00:00
Foreign creation scn/timescn: 0x0000.00000000 01/01/1988
00:00:00
Foreign checkpoint scn/timescn: 0x0000.00000000 01/01/1988
00:00:00
Online move state: 0
DDE rules only execution for: ORA 1110
----- START Event Driven Actions Dump ----
---- END Event Driven Actions Dump ----
----- START DDE Actions Dump -----
Executing SYNC actions
----- START DDE Action: 'DB_STRUCTURE_INTEGRITY_CHECK' (Async) -----
Successfully dispatched
----- END DDE Action: 'DB_STRUCTURE_INTEGRITY_CHECK'
(SUCCESS, 0 csec) -----
Executing ASYNC actions
----- END DDE Actions Dump (total 0 csec) -----
ORA-01186: file 1 failed verification tests
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1:
'+ASMDG002/test1/datafile/system.823.828585081'
ORA-01206: file is not part of this database - wrong
database id
Thanks, -
Hi all ,
I need some help on materialized view. I have to make a MV in dbms_dtm schema
I have 2 tables like below
sales and orduct
salescolumns: salesid,prodid,subid,charges
and product columns: subid and billid
sales.subid = product.subid.
i need a materialized view for this columns salesid,prodid,sum(charges),count(subid) and billid in dbms_dtm.
have to create another materialized view for below tables
order and ordertype
order columns: orderstaus,ordertype,address,ordertypeid
ordertype columns: ordername,subordername,ordertypeid
order.ordertypeid = ordertype.ordertypeid
need a materialized view for columns orderstaus,orderstaus,ordertype,address,ordername,subordername and granularity for this cloumns.
please some give me some guidens on this issue
Thanks in advanceYou should read chapters 8 & 9 of the Data Warehousing Guide:
http://download.oracle.com/docs/cd/B28359_01/server.111/b28313/basicmv.htm
Just saying "you need a materialized view" doesn't provide enough information on what you need or how you plan to use it. -
Rebuilding of the InforSource of DBCONNECT to Oracle View
Hello,
following problem:
I use DB connect to an Oracle Database to an View
It works fine.
I change the View in the Oracle Database and recompile it.
I get an Error while loading with an InfoPackage.
I have to drop the regenerate the Datasource and
I must Drop ! the InfoSource and
rebuild it completly again to be able to load again !
This stemms due to the fact that BW seems to protocol the internal state of the Oracle View, like displayed in the Oracle Dictionnary views user_views, all_views
or dba_views.
This is an inacceptable BW system behaviour and impossible for day to day
business, development and much work, espescially if You develop a 12 or more
DBConnect View interfaces !
Does anybody out there know how to make BW a more pleasent thing , customize it better to avoid this burden ?
Thank You !
Martin Sautter, Munich / Essen> Hi,
>
> when changing the view in Oracle it isn't necessary
> to drop and recreate the ISource and DSource!!
>
> Proceed as follows:
> - change your view (of course you can't rename it!)
> - regenerate your datasource with tcode RSDBC
> - open your TRules and maintain your TStructure
> (change tab)
> - maintain your TRules
> - finally activate
>
> this is definitively enough.
>
> hope this helps...
>
> Olivier.
>
> Message was edited by:
> Olivier Cora
> Hi,
>
> when changing the view in Oracle it isn't necessary
> to drop and recreate the ISource and DSource!!
>
> Proceed as follows:
> - change your view (of course you can't rename it!)
> - regenerate your datasource with tcode RSDBC
> - open your TRules and maintain your TStructure
> (change tab)
> - maintain your TRules
> - finally activate
>
> this is definitively enough.
>
> hope this helps...
>
> Olivier.
>
> Message was edited by:
> Olivier Cora
> Hi,
>
> when changing the view in Oracle it isn't necessary
> to drop and recreate the ISource and DSource!!
>
> Proceed as follows:
> - change your view (of course you can't rename it!)
> - regenerate your datasource with tcode RSDBC
> - open your TRules and maintain your TStructure
> (change tab)
> - maintain your TRules
> - finally activate
>
> this is definitively enough.
>
> hope this helps...
>
> Olivier.
>
> Message was edited by:
> Olivier Cora
> Hi,
>
> when changing the view in Oracle it isn't necessary
> to drop and recreate the Source and DSource!!
>
> Proceed as follows:
> - change your view (of course you can't rename it!)
> - regenerate your datasource with tcode RSDBC
> - open your TRules and maintain your TStructure
> (change tab)
> - maintain your TRules
> - finally activate
>
> this is definitively enough.
>
> hope this helps...
>
> Olivier.
>
> Message was edited by:
> Olivier Cora
> Hi,
>
> when changing the view in Oracle it isn't necessary
> to drop and recreate the ISource and DSource!!
>
> Proceed as follows:
> - change your view (of course you can't rename it!)
> - regenerate your datasource with tcode RSDBC
> - open your TRules and maintain your TStructure
> (change tab)
> - maintain your TRules
> - finally activate
>
> this is definitively enough.
>
> hope this helps...
>
> Olivier.
>
> Message was edited by:
> Olivier Cora
Hello,
in all its ok, except You change the format ( number to char or char to number etc.) or the column name of DBConnect's View or Table.
In this case You have do delete the BW Datasource and rebuild it.
It is advisable to name the DBConnect View or Table exactly as
in BW. This makes setting up of the InfoSource very easy.
Thank You
Martin Sautter -
Business components based on Oracle views
I am trying to create business component objects in a master-detail relationship based on Oracle views rather than on the underlying tables. The wizard does not create associations or links since the views have no foreign keys. I created the associations and links myself, but I am unable to add them to the data model. I am using the beta v5.0, but I had the same problem in v3.23. Can anyone help?
Thanx in advance
nullHere are the steps I just tried with JDevi 9i Beta:
[list]
[*]SQLPLUS SCOTT/TIGER
[*]CREATE VIEW DEPT_VIEW AS SELECT * FROM DEPT;
[*]CREATE VIEW EMP_VIEW AS SELECT * FROM EMP
[*]On my workspace: Right-mouse / New / Empty Project
[*]On my new project: Right-mouse / New Business Components...
[*]Next, to the connection panel
[*]Set the connection, and next
[*]Pick a package name and next
[*]Tick the [x] Views checkbox, and select EMP_VIEW and DEPT_VIEW
[*]Uncheck the "View Objects and View Links" box, since we don't want these created automatically.
[*]Click (Finish)
[*]In navigator, select my "DeptView" entity and edit it (the view is called "DeptViewView").
[*]Click on the "Attributes" tab
[*]Select "Rowid" in the attribute list
[*]Click the (Remove) button
[*]Select the "Attribute Settings" tab, and select the "Deptno" attribute.
[*]Check the [x] Primary Key checkbox for "Deptno"
[*]Click (Ok).
[*]Repeat steps above on "EmpView" entity to remove Rowid attribute and make "Empno" attribute the primary key. (NOTE: Since views don't have constraints, we couldn't detect the primary key constraint, so we default the ROWID to be the primary key in the wizard).
[*]In navigator, select my "DeptView" entity, and right-mouse / New Association...
[*]Using the wizard I create a association based on the "Deptno" attribute, and with a 1 to many cardinality.
[*]I right-mouse on "DeptView" entity and select New Default View Object... to create the "DeptViewView" view object.
[*]I right-mouse on "EmpView" entity and select New Default View Object... to create the "EmpViewView" view object.
[*]I right-mouse on the DeptViewView view object and select New View Link...
[*]I create a new view link between DeptViewView and EmpViewView
[*]On the "Source Attributes" panel, I select the "Dept2Emp" association I created above, and click the ">" to shuttle it to the selected list.
[*]Click next and notice that by selecting the association, it automatically picked the right attributes for both sides for the view link automatically.
[*]click next, then (Finish)
[*]I right-mouse on my package and select New Application Module...
[*]On the datamodel panel, I see a tree view of "Available View Objects like this:
+ Project 3
|
+---[-] Package3
|
+---[SQL] DeptViewView
| |
| +--[SQL] EmpViewView via MyViewLink
|
+---[SQL] EmpViewView[*]I select DeptViewView in the available list and click ">" to shuttle it to the selected list in my data model
[*]In the SELECTED list, I select the DeptViewView that I just added, to make it the current view in the selected list.
[*]Back in the available list, I select the "EmpViewView via MyViewLink" and shuttled it to the selected list as a detail of the current view in the selected list.
[*]I click finish
[*]I right-mouse on my AppModule and select "Test..." to build and test my appmodule.
[*]I click (Connect) on the tester start page
[*]In the tester, I right mouse on "MyViewLink" and select "Show".
[list]
After these steps, I see data correctly.
null -
Sending a parameter to a Oracle view
I want to create a oracle view with a variable and i want to change the value of variable according to my needs.
Can i Do This.
Query of view is a complex one assume as like this
SELECT ........ FROM
( SELECT ........ FROM .............
WHERE tempDate=TO_DATE('2007/2/23', 'YYYY/MM/DD')
WHERE ...............................Date should be a variable.
Variable should in a sub query.
Pls Help as soon as possibleTry using a PreparedStatement and insert a parameter placeholder ("?") instead of "TO_DATE('2007/2/23', 'YYYY/MM/DD')".
Pls Help as soon as possibleUsually I don't, good you told me ... -
ORA-02070: Error when updating a SQL Server table thru an Oracle View
I have a SQL Server table TIMESHEET which contains a number of VARCHAR and NUMERIC columns plus a DATETIME column.
Only the DATETIME column is giving me trouble.
On the ORACLE side I have a view which selects from the SQL Server table but in order to get the SELECT to work, I had to either put a CAST or TO_DATE function call around the DATETIME field
Below is the relevant part of the 2 view definitions I have tried
create view TIMESHEET as
SELECT
"TsKeySeq" as TS_KEY_SEQ,
"EmployeeNo" as EMPLOYEE_NO,
CAST("PeriodEnding" AS DATE) as PERIOD_ENDING,
. . . (more columns - not relevant)
FROM [email protected];
An update to the view generates this message
ORA-02070: database OLEMSQLPSANTDAS6 does not support CAST in this context
create view TIMESHEET as
SELECT
"TsKeySeq" as TS_KEY_SEQ,
"EmployeeNo" as EMPLOYEE_NO,
TO_DATE("PeriodEnding") as PERIOD_ENDING,
. . . (more columns - not relevant)
FROM [email protected];
An update to the view generates this message
ORA-02070: database OLEMSQLPSANTDAS6 does not support TO_DATE in this context
If I don't include either the TO_DATE() or CAST() then I get
Select Error: ORA-28527: Heterogeneous Services datatype mapping error
ORA-02063:preceding line from OLEMSQLSANTDAS6
Does anyone have any idea how to update a SQL Server DATETIME column thru an ORACLE view?You can't cast accross heterogenious databases and there is no need to. HSODBC treats SQL Server DATETIME column as DATE. For example, I have SQL Server table:
CREATE TABLE [Ops].[T_JobType](
[JobType] [varchar](50) NOT NULL,
[JobDesc] [varchar](200) NULL,
[InsertDt] [datetime] NOT NULL CONSTRAINT [InsertDt_00000006] DEFAULT (getdate()),
[InsertBy] [varchar](128) NOT NULL CONSTRAINT [InsertBy_00000006] DEFAULT (user_name()),
[LastUpdated] [datetime] NOT NULL CONSTRAINT [LastUpdated_00000006] DEFAULT (getdate()),
[LastUpdatedBy] [varchar](128) NOT NULL CONSTRAINT [LastUpdatedBy_00000006] DEFAULT (user_name()),
CONSTRAINT [T_JobType_PK] PRIMARY KEY CLUSTERED
[JobType] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [DATA01FG]
) ON [DATA01FG]Now on Oracle side I do:
SQL> desc "Ops"."T_JobType"@pbods
Name Null? Type
JobType NOT NULL VARCHAR2(50)
JobDesc VARCHAR2(200)
InsertDt NOT NULL DATE
InsertBy NOT NULL VARCHAR2(128)
LastUpdated NOT NULL DATE
LastUpdatedBy NOT NULL VARCHAR2(128)
SQL> select "InsertDt" from "Ops"."T_JobType"@pbods;
InsertDt
18-AUG-08
09-OCT-08
22-OCT-09
18-AUG-08
19-NOV-08
SQL> SY. -
Need help in oracle data recovery
Friends ,i need help in oracle data recovery.
I had an oracle 8i database running on windows.
For some reason Windows operating system crashed.
It is not booting up.
I dont have current backups.But my database physical files are in the disk.
Controlfile,datafiles and redo log files are there.
Is there any way I can recover my database?
Please help in this issue.
regards
AjithHI citrus,
thanks for the reply.
I have installed database 9i on the same PC after O/S reinstallation.
You are saying that ,I need to keep oracle root folder same as that of my old installation ,and copy control files,redo log and data files in exactly same folders as that of old database,and then start the database?
thank you for your patience and support.
regards.,
Ajith -
Hi Experts ,
We have Oracle View . There is no primary key is defined in this view. I need to join this view with some table in OBIEE physical layer.
1. I have created one opaque view with query
SELECT 'YES' PRESERVE FROM DUAL (Dummy table)
and make the join ..and report is also working fine...
So is this correct method.
2. Can we define Key at OBIEE level.(Make an alias and do self join)
If we define key at obiee level the key should be uniqe and for that we need to make all the view column as key.
please suggest..which method is good.
Thanks.
Sso can i create my key on any column and do the self join by creating alias...
I just want to give a join to my view so that obiee will not give any warning...
report is coming from view only...no fact and dimension here...view is on OLTP system -
Help on Oracle streams 11g configuration
Hi Streams experts
Can you please validate the following creation process steps ?
What is need to have streams doing is a one way replication of the AR
schema from a database to another database. Both DML and DDL shall do
the replication of the data.
Help on Oracle streams 11g configuration. I would also need your help
on the maintenance steps, controls and procedures
2 databases
1 src as source database
1 dst as destination database
replication type 1 way of the entire schema FaeterBR
Step 1. Set all databases in archivelog mode.
Step 2. Change initialization parameters for Streams. The Streams pool
size and NLS_DATE_FORMAT require a restart of the instance.
SQL> alter system set global_names=true scope=both;
SQL> alter system set undo_retention=3600 scope=both;
SQL> alter system set job_queue_processes=4 scope=both;
SQL> alter system set streams_pool_size= 20m scope=spfile;
SQL> alter system set NLS_DATE_FORMAT=
'YYYY-MM-DD HH24:MI:SS' scope=spfile;
SQL> shutdown immediate;
SQL> startup
Step 3. Create Streams administrators on the src and dst databases,
and grant required roles and privileges. Create default tablespaces so
that they are not using SYSTEM.
---at the src
SQL> create tablespace streamsdm datafile
'/u01/product/oracle/oradata/orcl/strepadm01.dbf' size 100m;
---at the replica:
SQL> create tablespace streamsdm datafile
---at both sites:
'/u02/oracle/oradata/str10/strepadm01.dbf' size 100m;
SQL> create user streams_adm
identified by streams_adm
default tablespace strepadm01
temporary tablespace temp;
SQL> grant connect, resource, dba, aq_administrator_role to
streams_adm;
SQL> BEGIN
DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE (
grantee => 'streams_adm',
grant_privileges => true);
END;
Step 4. Configure the tnsnames.ora at each site so that a connection
can be made to the other database.
Step 5. With the tnsnames.ora squared away, create a database link for
the streams_adm user at both SRC and DST. With the init parameter
global_name set to True, the db_link name must be the same as the
global_name of the database you are connecting to. Use a SELECT from
the table global_name at each site to determine the global name.
SQL> select * from global_name;
SQL> connect streams_adm/streams_adm@SRC
SQL> create database link DST
connect to streams_adm identified by streams_adm
using 'DST';
SQL> select sysdate from dual@DST;
SLQ> connect streams_adm/streams_adm@DST
SQL> create database link SRC
connect to stream_admin identified by streams_adm
using 'SRC';
SQL> select sysdate from dual@SRC;
Step 6. Control what schema shall be replicated
FaeterBR is the schema to be replicated
Step 7. Add supplemental logging to the FaeterBR schema on all the
tables?
SQL> Alter table FaeterBR.tb1 add supplemental log data
(ALL) columns;
SQL> alter table FaeterBR.tb2 add supplemental log data
(ALL) columns;
etc...
Step 8. Create Streams queues at the primary and replica database.
---at SRC (primary):
SQL> connect stream_admin/stream_admin@ORCL
SQL> BEGIN
DBMS_STREAMS_ADM.SET_UP_QUEUE(
queue_table => 'streams_adm.FaeterBR_src_queue_table',
queue_name => 'streams_adm.FaeterBR_src__queue');
END;
---At DST (replica):
SQL> connect stream_admin/stream_admin@STR10
SQL> BEGIN
DBMS_STREAMS_ADM.SET_UP_QUEUE(
queue_table => 'stream_admin.FaeterBR_dst_queue_table',
queue_name => 'stream_admin.FaeterBR_dst_queue');
END;
Step 9. Create the capture process on the source database (SRC).
SQL> BEGIN
DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
schema_name =>'FaeterBR',
streams_type =>'capture',
streams_name =>'FaeterBR_src_capture',
queue_name =>'FaeterBR_src_queue',
include_dml =>true,
include_ddl =>true,
include_tagged_lcr =>false,
source_database => NULL,
inclusion_rule => true);
END;
Step 10. Instantiate the FaeterBR schema at DST. by doing export
import : Can I use now datapump to do that ?
---AT SRC:
exp system/superman file=FaeterBR.dmp log=FaeterBR.log
object_consistent=y owner=FaeterBR
---AT DST:
---Create FaeterBR tablespaces and user:
create tablespace FaeterBR_datafile
'/u02/oracle/oradata/str10/FaeterBR_01.dbf' size 100G;
create tablespace ws_app_idx datafile
'/u02/oracle/oradata/str10/FaeterBR_01.dbf' size 100G;
create user FaeterBR identified by FaeterBR_
default tablespace FaeterBR_
temporary tablespace temp;
grant connect, resource to FaeterBR;
imp system/123db file=FaeterBR_.dmp log=FaeterBR.log fromuser=FaeterBR
touser=FaeterBR streams_instantiation=y
Step 11. Create a propagation job at the source database (SRC).
SQL> BEGIN
DBMS_STREAMS_ADM.ADD_SCHEMA_PROPAGATION_RULES(
schema_name =>'FaeterBR',
streams_name =>'FaeterBR_src_propagation',
source_queue_name =>'stream_admin.FaeterBR_src_queue',
destination_queue_name=>'stream_admin.FaeterBR_dst_queue@dst',
include_dml =>true,
include_ddl =>true,
include_tagged_lcr =>false,
source_database =>'SRC',
inclusion_rule =>true);
END;
Step 12. Create an apply process at the destination database (DST).
SQL> BEGIN
DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
schema_name =>'FaeterBR',
streams_type =>'apply',
streams_name =>'FaeterBR_Dst_apply',
queue_name =>'FaeterBR_dst_queue',
include_dml =>true,
include_ddl =>true,
include_tagged_lcr =>false,
source_database =>'SRC',
inclusion_rule =>true);
END;
Step 13. Create substitution key columns for äll the tables that
haven't a primary key of the FaeterBR schema on DST
The column combination must provide a unique value for Streams.
SQL> BEGIN
DBMS_APPLY_ADM.SET_KEY_COLUMNS(
object_name =>'FaeterBR.tb2',
column_list =>'id1,names,toys,vendor');
END;
Step 14. Configure conflict resolution at the replication db (DST).
Any easier method applicable the schema?
DECLARE
cols DBMS_UTILITY.NAME_ARRAY;
BEGIN
cols(1) := 'id';
cols(2) := 'names';
cols(3) := 'toys';
cols(4) := 'vendor';
DBMS_APPLY_ADM.SET_UPDATE_CONFLICT_HANDLER(
object_name =>'FaeterBR.tb2',
method_name =>'OVERWRITE',
resolution_column=>'FaeterBR',
column_list =>cols);
END;
Step 15. Enable the capture process on the source database (SRC).
BEGIN
DBMS_CAPTURE_ADM.START_CAPTURE(
capture_name => 'FaeterBR_src_capture');
END;
Step 16. Enable the apply process on the replication database (DST).
BEGIN
DBMS_APPLY_ADM.START_APPLY(
apply_name => 'FaeterBR_DST_apply');
END;
Step 17. Test streams propagation of rows from source (src) to
replication (DST).
AT ORCL:
insert into FaeterBR.tb2 values (
31000, 'BAMSE', 'DR', 'DR Lejetoej');
AT STR10:
connect FaeterBR/FaeterBR
select * from FaeterBR.tb2 where vendor= 'DR Lejetoej';
Any other test that can be made?Check the metalink doc 301431.1 and validate
How To Setup One-Way SCHEMA Level Streams Replication [ID 301431.1]
Oracle Server Enterprise Edition - Version: 10.1.0.2 to 11.1.0.6
Cheers. -
Help with oracle 11g pivot operator
i need some help with oracle 11g pivot operator. is it possible to use multiple columns in the FOR clause and then compare it against multiple set of values.
here is the sql to create some sample data
create table pivot_data ( country_code number , dept number, job varchar2(20), sal number );
insert into pivot_data values (1,30 , 'SALESMAN', 5000);
insert into pivot_data values (1,301, 'SALESMAN', 5500);
insert into pivot_data values (1,30 , 'MANAGER', 10000);
insert into pivot_data values (1,301, 'MANAGER', 10500);
insert into pivot_data values (1,30 , 'CLERK', 4000);
insert into pivot_data values (1,302, 'CLERK',4500);
insert into pivot_data values (2,30 , 'SALESMAN', 6000);
insert into pivot_data values (2,301, 'SALESMAN', 6500);
insert into pivot_data values (2,30 , 'MANAGER', 11000);
insert into pivot_data values (2,301, 'MANAGER', 11500);
insert into pivot_data values (2,30 , 'CLERK', 3000);
insert into pivot_data values (2,302, 'CLERK',3500);
using case when I can write something like this and get the output i want
select country_code
,avg(case when (( dept = 30 and job = 'SALESMAN' ) or ( dept = 301 and job = 'SALESMAN' ) ) then sal end ) as d30_sls
,avg(case when (( dept = 30 and job = 'MANAGER' ) or ( dept = 301 and job = 'MANAGER' ) ) then sal end ) as d30_mgr
,avg(case when (( dept = 30 and job = 'CLERK' ) or ( dept = 302 and job = 'CLERK' ) ) then sal end ) as d30_clrk
from pivot_data group by country_code;
output
country_code D30_SLS D30_MGR D30_CLRK
1 5250 10250 4250
2 6250 11250 3250
what I tried with pivot is like this I get what I want if I have only one ( dept,job) for one alias name. I want to call (30 , 'SALESMAN') or (301 , 'SALESMAN') AS d30_sls. any help how can I do this
SELECT *
FROM pivot_data
PIVOT (SUM(sal) AS sum
FOR (dept,job) IN ( (30 , 'SALESMAN') AS d30_sls,
(30 , 'MANAGER') AS d30_mgr,
(30 , 'CLERK') AS d30_clk
this is a simple example .... my real life scenario is compliated with more fields and more combinations .... So something like using substr(dept,1,2) won't work in my real case .
any suggestions get the result similar to what i get in the case when example is really appreciated.Hi,
Sorry, I don't think there's any way to get exactly what you requested. The values you give in the PIVOT ... IN clause are exact values, not alternatives.
You could do something like this to map all alternatives to a common value:
WITH got_dept_grp AS
SELECT country_code, job, sal
, CASE
WHEN job IN ('SALESMAN', 'MANAGER') AND dept = 301 THEN 30
WHEN job IN ('CLERK') AND dept = 302 THEN 30
ELSE dept
END AS dept_grp
FROM pivot_data
SELECT *
FROM got_dept_grp
PIVOT ( AVG (sal)
FOR (job, dept_grp)
IN ( ('SALESMAN', 30)
, ('MANAGER' , 30)
, ('CLERK' , 30)
;In your sample data (and perhaps in your real data), it's about as easy to explicitly define the pivoted groups individually, like this:
WITH got_pivot_key AS
SELECT country_code, sal
, CASE
WHEN job = 'SALESMAN' AND dept IN (30, 301) THEN 'd30_sls'
WHEN job = 'MANAGER' AND dept IN (30, 301) THEN 'd30_mgr'
WHEN job = 'CLERK' AND dept IN (30, 302) THEN 'd30_clrk'
END AS pivot_key
FROM pivot_data
SELECT *
FROM got_pivot_key
PIVOT ( AVG (sal)
FOR pivot_key
IN ( 'd30_sls'
, 'd30_mgr'
, 'd30_clrk'
;Thanks for posting the CREATE TABLE and INSERT statements; that really helps! -
"Help" in List View, Why?
Noticing some odd behavior: when you right click on any object in list view, the first contextual item is "Help". In icon or column view there is no "Help" and the first selectable action is "Open". Oddly, "Help" in list view does nothing. Can anyone explain this behavior. More importantly, can anyone tell me how to change it?
Limnos wrote:
What do you want it to do?
Actually, I'd prefer it not be there. I'd like the first selectable item to be "Open" regardless of what view I'm in. -
How to create view object for a predefined Oracle view
Trying to create an entity object with no success,,,
I have an Oracle view(complex query in PL/SQL) that I need to encapsulate as a View Object then represent a column from this view as a '' | | linkcolumn | | ''
then get a reference of the requestParameter "p" in this case that I need to use as whereclause parameter on another view object that is part of the ListPage.jsp.
The application is basically a page of organization links that when click filters their reports as a list,
In Jdeveloper's context webBean(RowSetBrowser list [org links] to RowSetBrowser [org report list])
Can I implement this functionallity using the wizards or possibly writing custom code using the standard webBeans.Jerry,
First, you can create an entity object based on an Oracle view. If you check the "Views" checkbox in the EO wizard, you'll see a list of database views. Then you can create a view object based on your entity object, and use it like any other view object.
As for getting the page into the format you want, I suggest you start by generating your page using the BC4J JSP wizard, then customize the generated JSP.
Thanks
Blaise -
Need help on Oracle Report format
Hi,
I need help on Oracle Reports. I am generating a report in excel sheet. I have a column which is 13 digit number (In database it is CHAR datatype). In excel sheet it showing some thing like 9.78381E+12. I want to show complete number like 9783805591331.
Also sometimes leading zero's are not showing when my column values is something like 0098794859583. I need to show the leading zero's as well in excel without losing them.
Below are the parameters i am using for the report
DESFORMAT=SPREADSHEET AND DESTYPE=FILE
My Oracle 9i developer version.
Any help on this would be much appreciated.
Thanks
KishoreAn additional quote string ' character with the number field will solve this problem but if u want to display this field in report then it will look ugly
'''||yourfield from table; check ur regional settings also
plz mark it helpful correct if it is -
Query to find dependency of an oracle VIEW
Hi,
I'm using oracle 10g database.
DB name is - ORCL
ORCL DB consists two schemas - Schema1 and Schema2
I have one Oracle view called VIEW1 in Schema1.
I need to find whether Schema2 uses VIEW1 in any of the Tables,views or Programs owned by Schema2.
Is there any query available to find this one?
Regards,
KarthikHow about querying the dba_dependencies view?
SQL> conn / as sysdba
Connected.
SQL> conn aman/aman
Connected.
SQL> create table t as select * from scott.dept;
Table created.
SQL> create view v1 as select * from t;
View created.
SQL> grant select on v1 to scott;
Grant succeeded.
SQL> conn scott/tiger
Connected.
SQL> create view v_dependant as select * from aman.v1;
View created.
SQL> conn / as sysdba
Connected.
SQL> desc dba_dependencies
Name Null? Type
OWNER NOT NULL VARCHAR2(30)
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)
DEPENDENCY_TYPE VARCHAR2(4)
SQL> select owner, name , type from dba_dependencies where name='V1' and owner='AMAN';
OWNER NAME TYPE
AMAN V1 VIEW
SQL> select owner, name , type, REFERENCED_OWNER, REFERENCED_NAME from dba_dependencies where name='V1' and owner='AMAN';
OWNER NAME TYPE
REFERENCED_OWNER
REFERENCED_NAME
AMAN V1 VIEW
AMAN
THTH
Aman.... -
Hi,
I need some help... if someone can help its great.
I need to make a statement in Oracle SQL that read data from a file and insert in a Oracle Database ... if someone can show me the syntax of it i appreciate..
ThanksOkay, I see you followed the advice in that other thread and started a new post for you question. Congratulations. Your next lesson in forum etiquette is to give your posts a more relevant subject. Pretty much everybody who posts here needs help with oracle; if they need help with cooking catfish they've come to the wrong place.
It that other thread I suggested using SQL*Loader or External Tables might be a more suitable solution. Find out more.
Cheers, APC
Maybe you are looking for
-
Error when starting Mercury Quicke Test Professional
Hello, I am executing the QTP scripts through eCATT. During execution I got an error ' Error when starting Mercury Quick Test Professional'. Does anybody knows how to resove this? Thanks, Mahantesh
-
When I edit Smart Objects in CS5.5 they open in their own window; meaning I only see the smart object in my new window when I chose to edit. In CS6 I am seeing the actual document I made the Smart Object from, as well as the Smart Object when I edit
-
How to install PS CS6 Extended on a computer with no disc drive? [was: Help]
I just purchsed Photoshop CS6 Extended, got home and totally forgot my computer does not have a disk drive. How do I install it now??
-
Changes not allowed in material type
hi all i have 1 material & for this material is trading good but due to mistake i have created this material with material type FERT.but if i am going to change material type HAWA instead of this material type FERT system not allowed.showing error Pu
-
HT4946 I am getting Error 3014 when trying to restore my iphone 3GS?
I am updating the operating system on my iphone 3GS, as prompted by itunes. I have a screen on the mac saying 'iphone recovery mode' I check all the prompts but the phone failts to restore quoting Error 3014. Anyone know what the problem is and how t