Create the view with the CLOB of TABLE data type with the LONG data type
Please need support to create the table viewSource table: (itemid varchar2, longrec)
need to create the table view Source
(itemid varchar2, CLOBrec)
A BUSINESS object must have a storage in the database, so you can't have a CLOB column in a view by pointing to a not lob data column.
Max
[My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/01/17/supporto-di-xml-schema-in-oracle-xmldb/]
Tags: Database
Similar Questions
-
create a view with the double data type
I have Windows XP with 10g 10.2.0.1.0
I need to create a view of the double and with the type of data, such as NUMBER (5.2), NUMBER or VARCHAR2 (20).
such as:
create see test (view_test varchar2 (20)) as (select view_test from double)
Help, please. Thanks in advance.It seems a little strange, but you can do something like this with the CAST function:
SQL> create view dual_view as 2 select cast(null as number(5,2)) col1 3 ,cast(null as date) col2 4 ,cast(null as varchar2(30)) col3 5 from dual; View created. SQL> desc dual_view Name Null? Type ----------------------------------------- -------- ------------------------- COL1 NUMBER(5,2) COL2 DATE COL3 VARCHAR2(30)
I used the NULL values, but you can use the actual values if you wish.
-
create a view with subquery generating insufficient privileges!
Hello
I want to create a view by a DB user with DBA role, the view is based on a query that extracts data from 2 users, next to the query contains the subquery. When I run the query itself - without clause CREATE VIEW - it works and gets the data, but when I try to create a view based on this request, it generates ORA-01031: insufficient privileges pointing to the subquery.
Any suggestion.
Saad,Hello
To use the table in a view, privileges must be granted directly to the owner of the view (or public). Privileges granted to a role are not enough to use the table in a view.
-
How to create a view with columns from multiple lines
I posted this in the SQL/PSL forum, but I hope that experts from the database in this group can give me ideas also, the necessity is also BI reports.
I have a table, for example, project_milestones, that has these columns in order:
PROJ_ID, milestone_name, actual_end_date
with data:
PROJ_ID, milestone_name, actual_end_date
===== ================ ==============
1001, key approval, 2009-10-02
1001, final synopsis, 2009-10-07
1001, approved final Protocol, 2009-10-15
1001, FPFV, 2010-01-10
1001, LPFV, 2010-03-12
...
1002, key approval, 2008-12-02
1002, final synopsis, 2009-01-07
1002, approved final Protocol, 2009-01-12
1002, FPFV, 2009-03-30
1002, LPFV, 2009-10-04
...
There are about 10 steps in each project.
I need to create a view for dish these data at the project level, looks like this:
PROJ_ID, key_element_date, final_synopsis_date, final_protocol_approved_date, FPFV_date, LPFV_date, key_element_to_final_synopsis_days, final_synopsis_final_protocol_days...
How can I do this?
Thank youuser9175541 wrote:
I posted this in the SQL/PSL forum, but I hope that experts from the database in this group can give me ideas also, the necessity is also BI reports.I have a table, for example, project_milestones, that has these columns in order:
PROJ_ID, milestone_name, actual_end_date
with data:
PROJ_ID, milestone_name, actual_end_date
===== ================ ==============
1001, key approval, 2009-10-02
1001, final synopsis, 2009-10-07
1001, approved final Protocol, 2009-10-15
1001, FPFV, 2010-01-10
1001, LPFV, 2010-03-12
...
1002, key approval, 2008-12-02
1002, final synopsis, 2009-01-07
1002, approved final Protocol, 2009-01-12
1002, FPFV, 2009-03-30
1002, LPFV, 2009-10-04
...
There are about 10 steps in each project.
I need to create a view for dish these data at the project level, looks like this:PROJ_ID, key_element_date, final_synopsis_date, final_protocol_approved_date, FPFV_date, LPFV_date, key_element_to_final_synopsis_days, final_synopsis_final_protocol_days...
How can I do this?
Thank you
Create a PivotTable and put "milestone_name" in the columns, under the labels section.
Put 'actual_end_date' in the section of measures and to change the rule of the aggregation of 'Max '.
The rest of the attributes keep in the lines section. -
How to create a view with "WITH CLAUSE"
Hello
I have one query with 'BY' ARTICLE, I need to create a view of this query. But I get the error message like
ORA-32034: Unsupported sue clause.
Please help me...!
Please find below my request...!
ConcerningWITH RANGE AS (SELECT A.MASTERMACHINEID, a.startdate, a.enddate, a.startdate - (1 / 3) + (lvl) * 1 / 3 SHIFT_ST_DT, a.startdate + (lvl) * 1 / 3 AS SHIFT_END_DT, a.quantity, (LEAST ( enddate, TODATE) - GREATEST ( FROMDATE, startdate)) * 24 TOTAL_HRS, (enddate - startdate) * 24 AVAIL, todate, fromdate FROM OMP A, (SELECT LEVEL lvl FROM (SELECT MAX (enddate - startdate) AS diff FROM OMPWORKORDER) CONNECT BY LEVEL <= (diff) * 3), MASTER B WHERE A.MASTERMACHINEID = B.MASTERMACHINEID AND lvl / 3 <=(enddate - startdate) + 1 ORDER BY SHIFT_ST_DT) SELECT shift_date, shift_num, shift_hrs, DECODE (SIGN (SHUT_DWN_TIME), -1, 0, SHUT_DWN_TIME), 8 - DECODE (SIGN (SHUT_DWN_TIME), -1, 0, SHUT_DWN_TIME) shift_avail_hrs, qty, total_qty FROM (SELECT TRUNC (SHIFT_ST_DT) shift_date, ROW_NUMBER () OVER (PARTITION BY TRUNC (SHIFT_ST_DT) ORDER BY SHIFT_ST_DT) shift_num, 8 shift_hrs, (LEAST ( SHIFT_END_DT, TODATE) - GREATEST ( FROMDATE, SHIFT_ST_DT)) * 24 SHUT_DWN_TIME, quantity / (avail - TOTAL_HRS) qty, round(((SHIFT_END_DT - SHIFT_ST_DT) * 24 - (LEAST (SHIFT_END_DT, TODATE) - GREATEST (FROMDATE, SHIFT_ST_DT)) * 24) * QuantiTY / (AVAIL - TOTAL_HRS),2) TOTAL_QTY FROM RANGE A );
KPR
Published by: BluShadow on March 17, 2011 09:48
addition of {noformat}{noformat} tags for readability
Try to create the view on the next request, if it helps you:
SELECT shift_date, shift_num, shift_hrs, decode(SIGN(shut_dwn_time), -1, 0, shut_dwn_time), 8 -decode(SIGN(shut_dwn_time), -1, 0, shut_dwn_time) shift_avail_hrs, qty, total_qty FROM ( SELECT TRUNC(shift_st_dt) shift_date, row_number() over(PARTITION BY TRUNC(shift_st_dt) ORDER BY shift_st_dt) shift_num, 8 shift_hrs, (least(shift_end_dt, todate) -greatest(fromdate, shift_st_dt)) *24 shut_dwn_time, quantity /(avail -total_hrs) qty, ROUND(((shift_end_dt -shift_st_dt) *24 -(least(shift_end_dt, todate) -greatest(fromdate, shift_st_dt)) *24) *quantity /(avail -total_hrs), 2) total_qty FROM ( SELECT a.mastermachineid, a.startdate, a.enddate, a.startdate -(1 / 3) +(lvl) *1 / 3 shift_st_dt, a.startdate +(lvl) *1 / 3 AS shift_end_dt, a.quantity, (least(enddate, todate) -greatest(fromdate, startdate)) *24 total_hrs, (enddate -startdate) *24 avail, todate, fromdate FROM omp a, (SELECT LEVEL lvl FROM (SELECT MAX(enddate -startdate) AS diff FROM ompworkorder) CONNECT BY LEVEL <=(diff) *3), master b WHERE a.mastermachineid = b.mastermachineid AND lvl / 3 <=(enddate -startdate) + 1 ORDER BY shift_st_dt ) a ) ;
Kind regards
Dipali.l -
How to create relational views based on an xmltype table which included sev
Hello
I'm using oracle 11.2.0.1.0.
How to create a relational view based on a table xmltype including the content of the .xml files several different?
Thank you.
For examle:
SQL > SELECT OBJECT_VALUE FROM document;
Published by: cow on January 6, 2011 19:57In general, you can use XMLTable to create these views...
You will need to create a view for each collection
The notice will contain the data of all documents...
-
Error ORA-00911 create a view with PL/SQL
Hello. Working with SQL Developer, I'm writing a procedure that creates a view.
After a compilation successful, whenever I try to run it, I get an error ORA-00911 and I'm not able to find the reason.
Here is my code. Thanks in advance.
CREATE OR REPLACE PROCEDURE "DWH_STAR"."STORICO_DATA" ( DATA_INPUT IN VARCHAR2 )AS BEGIN EXECUTE IMMEDIATE ' CREATE OR REPLACE FORCE VIEW DWH_STAR.V_PORT_STOR_DATA (DATA_DESC, CLIENTE_KEY, PRODOTTO_KEY, AGENTE_KEY, TIPOLOGIA_KEY, NUM_ORDINE, NUM_UNITA, RICAVO_LORDO, RICAVO_NETTO, COSTO_STD_TOTALE, GROSS_PROFIT) AS SELECT dt.DATA_DESC, fv.CLIENTE_KEY, fv.PRODOTTO_KEY, fv.AGENTE_KEY, fv.TIPOLOGIA_KEY, fv.NUM_ORDINE, SUM (NUM_UNITA) NUM_UNITA, SUM (RICAVO_LORDO) RICAVO_LORDO, SUM (RICAVO_NETTO) RICAVO_NETTO, SUM (COSTO_STD_TOTALE) COSTO_STD_TOTALE, SUM (GROSS_PROFIT) GROSS_PROFIT FROM F_VENDUTO fv, D_TEMPO dt WHERE fv.TEMPO_KEY = dt.TEMPO_KEY AND TO_NUMBER(TO_CHAR(dt.DATA_DESC,''YYYYMMDD'')) <=' || DATA_INPUT ||' GROUP BY fv.CLIENTE_KEY, fv.PRODOTTO_KEY, fv.AGENTE_KEY, fv.TIPOLOGIA_KEY, fv.NUM_ORDINE, dt.DATA_DESC ORDER BY dt.DATA_DESC, fv.CLIENTE_KEY, fv.PRODOTTO_KEY, fv.AGENTE_KEY, fv.TIPOLOGIA_KEY, fv.NUM_ORDINE; UNION SELECT dt.DATA_DESC, fs.CLIENTE_KEY, fs.PRODOTTO_KEY, fs.AGENTE_KEY, fs.TIPOLOGIA_KEY, fs.NUM_ORDINE, - SUM (NUM_UNITA) NUM_UNITA, - SUM (RICAVO_LORDO) RICAVO_LORDO, - SUM (RICAVO_NETTO) RICAVO_NETTO, - SUM (COSTO_STD_TOTALE) COSTO_STD_TOTALE, - SUM (GROSSO_PROFIT) GROSS_PROFIT FROM F_SPEDITO fs, D_TEMPO dt WHERE (fs.CAUSA_RESO_KEY = 0 AND fs.TEMPO_KEY = dt.TEMPO_KEY AND TO_NUMBER(TO_CHAR(dt.DATA_DESC,''YYYYMMDD'')) <=' || DATA_INPUT ||' ) GROUP BY fs.CLIENTE_KEY, fs.PRODOTTO_KEY, fs.AGENTE_KEY, fs.TIPOLOGIA_KEY, fs.NUM_ORDINE, dt.DATA_DESC ORDER BY dt.DATA_DESC, fs.CLIENTE_KEY, fs.PRODOTTO_KEY, fs.AGENTE_KEY, fs.TIPOLOGIA_KEY, fs.NUM_ORDINE ' ; END; /
delete the order and the semicolon (;) of the first select statement. I hope you know that the operator union the same set of columns to be selected.
But try to avoid to create objects on the fly, unless and until it is absolutely necessary and inevitable.
Concerning
REDA
Published by: R.Subramanian on June 21, 2010 07:52
Published by: R.Subramanian on June 21, 2010 07:53
-
Create a view which limits a large table, but also allows an outer join?
Oracle 10.2.0.4
CREATE TABLE MY_PAY_ITEMS
(EMP VARCHAR2 (8) NOT NULL)
, PAY_PRD VARCHAR2 (8) NOT NULL
, KEY1 VARCHAR2 (8) NOT NULL
, KEY2 VARCHAR2 (8) NOT NULL
, LN_ITEM VARCHAR2 (4) NOT NULL
, ITEM_AMT NUMBER (24.2) NOT NULL
VARCHAR2 (100) FILL NON-NULL)
INSERT INTO MY_PAY_ITEMS
SELECT A.EMP
B.PAY_PRD
C.KEY1
D.KEY2
E.LN_ITEM
F.ITEM_AMT
, ' '
FROM (SELECT TO_CHAR (ROWNUM, ' 00000000') 'EMP' FROM DUAL CONNECT BY LEVEL < = 50) has
, (SELECT '2010-' |) To_char(rowNum,'00') 'PAY_PRD' FROM DUAL CONNECT BY LEVEL < = 52) B
, (SELECT TO_CHAR (ROWNUM, ' 000') 'KEY1' FROM DUAL CONNECT BY LEVEL < = 8) C
, (SELECT TO_CHAR (ROWNUM, ' 000') 'Key2' FROM DUAL CONNECT BY LEVEL < = 5) D
, (SELECT TO_CHAR(ROWNUM,'000') 'LN_ITEM' FROM DUAL CONNECT BY LEVEL < = 20) E
(round (DBMS_RANDOM. VALUE * 400.2) "ITEM_AMT" of the double) F
CREATE A UNIQUE INDEX MY_PAY_ITEMS ON MY_PAY_ITEMS (MEP, PAY_PRD, KEY1, KEY2, LN_ITEM)
CREATE TABLE MY_ITEM_DISPLAY
(THE VARCHAR2 (4) OF DISPLAY_CODE NOT NULL)
, NUMBER (2) SEQUENCE NON-NULL
, COLUMN_ITEM1 VARCHAR2 (4) not null
, COLUMN_ITEM2 VARCHAR2 (4) not null
, COLUMN_ITEM3 VARCHAR2 (4) not null
COLUMN_ITEM4 VARCHAR2 (4) not null)
INSERT INTO MY_ITEM_DISPLAY VALUES ('01 ', 10, '001', '003', '004',' 005');
INSERT INTO MY_ITEM_DISPLAY VALUES ('01 ', 20 '007', '013', '004',' 009');
INSERT INTO MY_ITEM_DISPLAY VALUES ('01', 30 ' 001', '004', '009',' 011');
INSERT INTO MY_ITEM_DISPLAY VALUES ('01', 40, '801 ', ' 304 ', 209',' 111');
INSERT INTO MY_ITEM_DISPLAY VALUES ('02 ', 10, '001', '003', '004',' 005');
INSERT INTO MY_ITEM_DISPLAY VALUES ('02 ', 20 '007', '013', '004',' 009');
INSERT INTO MY_ITEM_DISPLAY VALUES ('02', 30 ' 001', '004', '009',' 011');
MY_PAY_ITEMS is a table that stores line of payslip items. It has a total area of 500,000,000 lines.
PEM is the unique id, we have about 200,000 employees (with about 50,000 being active today).
PAY_PRD is a weekly pointer (2010-01, 2010-02, 2010-52), we have the 2004 data and add a new pay period each week. 2010 01 is defined as the first Monday in 2010 for the first Sunday in 2010, etc.
Key1 is an internal key, it follows the chronology in the pay period.
KEY2 is a child of KEY1, there follows the sequence of events in KEY1.
LN_ITEM is the component of actual compensation resulting from the event, on average, a person produces 20 lines per event. Note that in this example, everyone gets the same LN_ITEM values, but in practice it is selected 20 of 300
ITEM_AMT is the net salary per command line.
FILLING is a set of fields that are unrelated to this issue, but act as a brake on the charges of the line.
MY_ITEM_DISPLAY is an array that describes how some screens should display items. The screen itself is a grid of 4 poles, with the content of each cell is defined as a LN_ITEMS search to retrieve the relevant LN_AMT.
We have an application that receives a DISPLAY_CODE and an EMP. It automatically creates an sql statement in the sense of
SELECT * FROM MY_VIEW WHERE DISPLAY_CODE =: 1 AND EMP =: 2
and returns the output to the user.
My challenge is that I need to rewrite MY_VIEW as follows:
(1) (select the relevant lines from MY_ITEM_DISPLAY where DISPLAY_CODE =: 1)
(2) select the relevant all MY_PAY_ITEMS lines that meet the criteria
(a) EMP =: 2
(b) PAY_PRD = (a more recent for EMP and sysdate, so if he got last paid 2010-04, return 2010-04)
(c) KEY1 = (highest key1 in EMP and PAY_PRD)
(d) KEY2 = (highest key2 in KEY1, PAY_PRD and EMP)
(3) I then need to cross reference to create tabular output
(4) Finally, I have to return a 0 line where there is no LN_ITEMs (DISPLAY_CODE 01, 40 sequence contains possible values for this scenario)
The following query is part of it (but not the PAY_PRD, KEY1, KEy2)
Select * from)
SELECT A.DISPLAY_CODE
B.EMP
A.SEQUENCE
, MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM1, B.ITEM_AMT, 0)) 'COL1 '.
, MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM2, B.ITEM_AMT, 0)) 'COL2 '.
, MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM3, B.ITEM_AMT, 0)) 'COL3 '.
, MAX (DECODE (B.LN_ITEM, A.COLUMN_ITEM4, B.ITEM_AMT, 0)) 'COL4 '.
OF MY_ITEM_DISPLAY A, MY_PAY_ITEMS B
WHERE B.PAY_PRD = ' 2010-03'
GROUP OF A.DISPLAY_CODE, B.EMP, A.SEQUENCE)
WHERE DISPLAY_CODE = '01'
AND EMP = '0000011'
SEQUENCE ORDER
My questions
(1) how I do PAY_PRD, KEY1, KEY2 forced, can I use a form any of ROW_NUMBER() FUNCTION?
(2) how can I deal with the fact that none of the 4 LN_ITEMS column can exist (see sequence 40, none of these can exist)... Ideally the SQL above should return
01, 0000011, 10, < a digit - > < number > - < a digit - > < some number >
01, 0000011, 20, < a digit - > < number > - < a digit - > < some number >
01, 0000011, 30, < a number--> < number > - < number > - < number > -
01, 0000011, 40, 0, 0, 0, 0
I tried a UNION, but it prevented the view to eliminate most of the MY_PAY_ITEMS lines, because it solves ALL MY_PAY_ITEMS instead of simply retrieve lines for the EMP passed to the view. The same seems to be true for outer joins.
Hi Paula,
It does not handle SEQNUM 40, it's just that your second set of test data did not SEQNUM 40. When I put in the first set of values MY_ITEM_DISPLAY, I get:
DISP EMP SEQUENCE COL1 COL2 COL3 COL4
---- -------- ---------- ---------- ---------- ---------- ----------
01 00000011 10 101.1 103.1 105.1 104.1
01 00000011 20 107.1 113.1 104.1 109,1
01 00000011 30 101.1 104.1 109.1 99.99
01 00000011 40 0 0 0 0
If this isn't the issue, you will need to explain the requirement of "outer join" and what you want more. Apart from his return nothing if there is absolutely no element of remuneration of the employee, this query will always return a line for each line MY_ITEM_DISPLAY for the display_code. If there is absolutely no data, no return line seems reasonable.
-
Create a view with a column change journal
Hello
I have the following table:
create table test1)
number of site_number
date of change_date,
number of area_ha);
insert into test1 values (1, TO_DATE('1/1/2007','DD/MM/RRRR'), 20);
insert into test1 values (1, TO_DATE('1/1/2008','DD/MM/RRRR'), 30);
insert into test1 values (1, TO_DATE('1/1/2009','DD/MM/RRRR'), 25);
insert into test1 values (2, TO_DATE('1/1/2007','DD/MM/RRRR'), 50);
insert into test1 values (2, TO_DATE('1/1/2008','DD/MM/RRRR'), 60);
insert into test1 values (2, TO_DATE('1/1/2009','DD/MM/RRRR'), 60);
insert into test1 values (3, TO_DATE('1/1/2007','DD/MM/RRRR'), 20);
insert into test1 values (3, TO_DATE('1/1/2008','DD/MM/RRRR'), 25);
insert into test1 values (3, TO_DATE('1/1/2009','DD/MM/RRRR'), 30);
What I want to do is to have a view based on the table above which includes a column of change (change_log below) based on the anterior surface (area_ha) for each specific site_number. For example in the first line site_number 1 has increased the area of 20 hectares on the 01/01/2007 to 30 hectares on the next change_date for this site that 01/01/2008. How this could be done?
SITE_NUMBER CHANGE_DATE AREA_HA CHANGE_LOG 1 01/01/2007 20 NO CHANGE 1 01/01/2008 30 ADDED SPACE 1 01/01/2009 25 DELETED DOMAIN 2 01/01/2007 50 NO CHANGE 2 01/01/2008 60 ADDED SPACE 2 01/01/2009 60 NO CHANGE 3 01/01/2007 20 NO CHANGE 3 01/01/2008 25 ADDED SPACE 3 01/01/2009 30 ADDED SPACE I am using oracle 11g R2
Select site_number,
change_date,
area_ha,
sign of case (area_ha - lag(area_ha,1,area_ha) over (partition by order of change_date site_number))
When 1 "AREA ADDED.
When-1 then "ZONE DELETED."
Another 'NO CHANGE'
end change_log
of test1
order of site_number,
change_date
/
SITE_NUMBER CHANGE_DA AREA_HA CHANGE_LOG
----------- --------- ---------- ------------
1 1 JANUARY 07 20 NO CHANGE
1 1 JANUARY 08-30 ADDED SPACE
1 1 JANUARY 09 25 DELETED AREA
2 1 JANUARY 07 50 NO. CHANGE
2 1 JANUARY 08 60 ADDED SECTOR
2 1 JANUARY 09 60 NO. CHANGE
3 1ST JANUARY 07 20 NO. CHANGE
3 AREA 1 JANUARY 08 25 ADDED
3 1ST JANUARY 09 30 ADDED AREA9 selected lines.
SQL >
SY.
-
Create the form on table in the different schema
Hi all
in APEX I am logged in as long as user APEX_USER and the table, I'm trying to access the site with the creation on Table Wizard form belongs to the user. I have granted all privileges on a given user APEX_USER table, the wizard allows me to choose this table in the list, but when I press the next button, I get the following error message:
You do not have access to the schema that you import. Import failed.
Contact your administrator for the application.
Seems to me that something similar had been already discussed here, but still no response.
V4.1 assistants when you use a different schema
Please, what are the rights must have my APEX_USER to be able to create forms tables belonging to someone else?
Thank you very much
Pavel
Edit: I did the same thing on my laptop (APEX 4.2.6.00.03) here and it works as expected. This error I get to work with APEX 4.2.3.00.08 (of course you should not necessarily be the cause, very likely, I don't have all of the necessary privileges) :-).
Hi Mike,.
Thanks again for your response. If the schema was not related to my workspace, I would yet be able to choose the other schema of the selection list.
In fact, there seems to be a bug in the link in my message original (for example it is still not fixed in version 4.2.3), but fortunately I was able to find a workaround - I created a view with the same name and the same structure as the original table, and then I was able to generate the form with the wizard , finally I gave up the display and modification of processes page manually. So the solution is I have to force the DBA APEX upgraded to the current version :-).
Best regards
Pavel
-
Creating a view using multiple joins - by reducing the number of output lines
It is difficult to put into words exactly what I want to implement, so I'll just use an example. Let's say I have the following database:
game (id, time, place)
Reader (game_id, name)
Referee (game_id, name)
Foreign keys:
Player (game_id) references game (id)
Referee (game_id) references game (id)
It is a very special match, in which:
A game can have 1 to many players
A game can have from 1 to several arbitrators
I want to create the following view:
Game_overview (Game_id, time, player, referee)
It's easy to create this view with the following output:
Game1, 15:00, player1, Referee1
Game1, 15:00, player1, Referee2
Game1, 15:00, player2, Referee1
Game1, 15:00, player2, Referee2
Game1, 15:00, Joueur3, null
08:00, player1, Referee1, GaMe2
GaMe2, 08:00, player1, Referee2
HOWEVER, I want it to look like this:
Game1, 15:00, player1, Referee1
Game1, 15:00, player2, Referee2
Game1, 15:00, Joueur3, null
08:00, player1, Referee1, GaMe2
GaMe2, 08:00, null, Referee2
I think that this should not be TOO difficult to solve, but I can't really get my head around it.Welcome to the forum!
Whenever you have a problem, please post CREATE TABLE and INSERT statements for your sample data. Sinve it's your first post, I'll do it for you:
CREATE TABLE game ( id VARCHAR2 (10) PRIMARY KEY , time VARCHAR2 (10) --, location VARCHAR2 (10) -- No need to include columns that play no role in this problem ); INSERT INTO game (id, time) VALUES ('Game 1', '3PM'); INSERT INTO game (id, time) VALUES ('Game 2', '8AM'); CREATE TABLE player ( game_id VARCHAR2 (10) , name VARCHAR2 (10) ); INSERT INTO player (game_id, name) VALUES ('Game 1', 'Player 1'); INSERT INTO player (game_id, name) VALUES ('Game 1', 'Player 2'); INSERT INTO player (game_id, name) VALUES ('Game 1', 'Player 3'); INSERT INTO player (game_id, name) VALUES ('Game 2', 'Player 1'); CREATE TABLE referee ( game_id VARCHAR2 (10) , name VARCHAR2 (10) ); INSERT INTO referee (game_id, name) VALUES ('Game 1', 'Referee 1'); INSERT INTO referee (game_id, name) VALUES ('Game 1', 'Referee 2'); INSERT INTO referee (game_id, name) VALUES ('Game 2', 'Referee 1'); INSERT INTO referee (game_id, name) VALUES ('Game 2', 'Referee 2');
In this way, people who want to help you can recreate the problem and test their ideas.
In addition, to say what version of Oracle you are using. The following query will work in Oracle 9.1 or more.
What you asked is what I call a Query, fixed-price , and this is a way to do it:
WITH player_plus AS ( SELECT game_id , name , ROW_NUMBER () OVER ( PARTITION BY game_id ORDER BY name ) AS r_num FROM player ) , referee_plus AS ( SELECT game_id , name , ROW_NUMBER () OVER ( PARTITION BY game_id ORDER BY name ) AS r_num FROM referee ) SELECT g.id , g.time , p.name AS player_name , r.name AS referee_name FROM player_plus p FULL OUTER JOIN referee_plus r ON p.game_id = r.game_id AND p.r_num = r.r_num JOIN game g ON g.id = COALESCE (p.game_id, r.game_id) ORDER BY g.id , COALESCE (p.r_num, r.r_num) ;
Output:
ID TIME PLAYER_NAM REFEREE_NA ---------- ---------- ---------- ---------- Game 1 3PM Player 1 Referee 1 Game 1 3PM Player 2 Referee 2 Game 1 3PM Player 3 Game 2 8AM Player 1 Referee 1 Game 2 8AM Referee 2
I see that you have more arbitrators than players in a game. If such was not the case, then you might make it a bit more efficient using a LEFT OUTER JOIN between p and r, rather than a FULL OUTER JOIN, and you can also use only the columns of p where I use COALESCE.
Published by: Frank Kulash, March 9, 2012 18:15
Fixed spelling -
Create view with different schemas
Hello
I would like to create a view using data on different patterns.
For example, user A has a table1 and user B has also a table1.
On the schema user C, I would make a union of two table in the same point of view as:
If user C is running:
Select * from A.table1
Union
Select * from B.table1
It's ok, but when I try:
CREATE or REPLACE view view_table1 AS FORCE
Select * from A.table1
Union
Select * from B.table1
It returns the ERROR at line 0: ORA-01031: insufficient privileges
But the C user has SELECT ANY TABLE, update ANY TABLE, DELETE ANY TABLE,... rights
Someone has an idea?
Thank you!
Published by: bushi893 on August 30, 2010 19:53When you create a view containing the object of different owners, the other owners have to grant "with grant option" to the owner of the view. Thus, the view owner can grant to other users or patterns...
Example: The latter is the owner of a table called mine_a User_b is the owner of a table called yours_b
Let's say user_b want to create a view with a join of mine_a and yours_b
To see it working properly, it must give "grant select on mine_a to user_b with grant option.
Then user_b may grant select on this point of view to everyone.
-
Using DBMS_DATAPUMP with the LONG data type
I have a procedure below that calls the DBMS_DATAPUMP procedure using a REMOTE_LINK move a schema of one database to another. However, some tables in this schema have columns with the data type of LONG. And when I run it I get an error saying that you cannot move the data with the LONG data type using a REMOTE CONNECTION. So no data in these specific tables gets flying over.
Does anyone else have this problem? If so, do you have a work around? I tried to add a CLOB column in my table and affecting the new CLOB equal THROUGHOUT, but I couldn't get that to not work either... even when I tried to use a TO_LOB. If I could get that pass, then I could just slide ALONG, the schema, and then re-create the LONG column on the opposite side.
Here is my procedure...
DECLARE
/ * IMPORT/EXPORT VARIABLES * /.
v_dp_job_handle NUMBER; -The handful of job data pump
v_count NUMBER; -Index of the loop
v_percent_done NUMBER; -Percentage of job complete
v_job_state VARCHAR2 (30); -To keep track of job status
v_message KU$ _LOGENTRY; -For error messages and work in PROGRESS
v_job_status KU$ _JOBSTATUS; -The State of the work of get_status
v_status KU$ _STATUS; -The status returned by get_status object
v_logfile NUMBER;
T_DATE VARCHAR2 (13).
v_source_server_name VARCHAR2 (50);
v_destination_server_name VARCHAR2 (50);
BEGIN
v_project: = 'TEST ';
T_DATE: = TO_CHAR (SYSDATE, 'MMDDYYYY_HHMI');
v_source_server_name: = 'TEST_DB ';
v_dp_job_handle: = DBMS_DATAPUMP. OPEN)
OPERATION = > "IMPORT."
JOB_MODE = > "SCHEMA."
REMOTE_LINK = > v_source_server_name,
JOB_NAME = > v_project | ' _EXP_' | T_DATE,
VERSION = > 'LAST');
v_logfile: = DBMS_DATAPUMP. KU$ _FILE_TYPE_LOG_FILE;
DBMS_DATAPUMP. ADD_FILE)
MANAGE = > v_dp_job_handle,
FILENAME = > v_project | ' _EXP_' | T_DATE |'. JOURNAL '.
DIRECTORY = > 'DATAPUMP. "
FILETYPE = > v_logfile);
DBMS_DATAPUMP. () METADATA_FILTER
MANAGE = > v_dp_job_handle,
NAME = > 'SCHEMA_EXPR ',.
VALUE = > ' = "' | v_project | " ' ') ;
DBMS_DATAPUMP. START_JOB (v_dp_job_handle);
v_percent_done: = 0;
v_job_state: = "UNDEFINED";
WHILE (v_job_state! = "COMPLETED") AND (v_job_state! = "STOPPED")
LOOP
DBMS_DATAPUMP. GET_STATUS)
v_dp_job_handle,
DBMS_DATAPUMP. KU$ _STATUS_JOB_ERROR + DBMS_DATAPUMP. KU$ _STATUS_JOB_STATUS + DBMS_DATAPUMP. KU$ _STATUS_WIP.
-1,
v_job_state,
v_status);
v_job_status: = v_status. JOB_STATUS;
IF v_job_status. PERCENT_DONE! = v_percent_done THEN
DBMS_OUTPUT. Put_line ('* percent of the job done = ' |) To_char (v_job_status. PERCENT_DONE));
v_percent_done: = v_job_status. PERCENT_DONE;
END IF;
IF BITAND (v_status. MASK, DBMS_DATAPUMP. KU$ _STATUS_WIP)! = 0 THEN
v_message: = v_status. WORK IN PROGRESS;
ELSIF BITAND (v_status.mask, DBMS_DATAPUMP. KU$ _STATUS_JOB_ERROR)! = 0 THEN
v_message: = v_status. ERROR;
ON THE OTHER
v_message: = NULL;
END IF;
IF v_message IS NOT NULL THEN
v_count: = v_message. FIRST;
While v_count IS NOT NULL
LOOP
DBMS_OUTPUT. Put_line (v_message (v_count). LOGTEXT);
v_count: = v_message. Next (v_count);
END LOOP;
END IF;
END LOOP;
DBMS_OUTPUT. Put_line ("' job has completed");
DBMS_OUTPUT. Put_line (' State of the Final work = ' | v_job_state);
DBMS_DATAPUMP. Detach (v_dp_job_handle);
END;TO_LOB can be used to insert, create table in select and update the instructions to convert
So: You simply cannot use it in SELECT..., you can use CREATE TABLE BLAH AS SELECT TO_LOB (LONG_COLUMN) OF DREADED_TABLE_WITH_LONG_COL;
-
View with a column that is derived from a function
We can create a view with a column being filled using a pl/sql script, which uses 2 other columns on the same line as input?
Example,
Let's say I have a vision with
Reg. Don't | Total | Customer account | Flag of billing. CodeFn
$1234 45 2109 Y < value in this column would be what returns the expected script pl/sql, after using the Reg # (1234) and Total (45) as entries >
$1236 15 2101 Y < input values would be 1236 & 15 >.
Basically, I would like the script to generate a number that is returned in this column rather than do a simple Select stmt to extract columns from other tables/views.
Edit: The point of view does not display right... Here is a picture
view
Thank you!
Published by: jess_saunders on May 8, 2012 14:05Hello
jess_saunders wrote:
We can create a view with a column being filled using a pl/sql script, which uses 2 other columns on the same line as input?Example,
Let's say I have a vision withReg. Don't | Total | Customer account | Flag of billing. CodeFn
$1234 45 2109 Y
$1236 15 2101 Y. Of course, you can use a function that you created in the same way that you would use a built-in function:
CREATE OR REPLACE VIEW view_x AS SELECT reg_no , total , customer_account , billing_flag , my_function (reg_no, total) AS codefn FROM table_x ;
You cannot reference the procedures or anyonymous blocks in a CREATE VIEW statement (or any other SQL statement of stinks); only functions.
Basically, I would like the script to generate a number that is returned in this column rather than do a simple Select stmt to extract columns from other tables/views.
I don't know what you're saying here.
As long as the function has no arguments, or make any kind of DML or DDL, then you can use it in the definition of the view, as stated above. The function failed to contain SELECT statements.
Your notice must be based on other tables or views. If she does not really need anything from any other table, you can base your opinion on double. A CREATE VIEW statement must contain a query, and a query in Oracle must refer to a table or a view. -
Choose a view with nested object types
I use 11.2 DB. I created 2 types of objects. The contact_t has been integrated into the student_t object and I created a view with the nested object.
How do you choose the values of the object contact_t type in the view SQL? I want to see the values of the contact_t object in speerate areas (ie. contact_name, city, Department...)
Thank you
CREATE or REPLACE TYPE contact_t () AS OBJECT
DCID NUMBER (10),
Contact_Name VARCHAR2 (50).
City VARCHAR2 (50).
State VARCHAR2 (10),
zip VARCHAR2 (10),
e-mail VARCHAR2 (100))
CREATE or REPLACE TYPE students_t () AS OBJECT
DCID NUMBER (10),
ID NUMBER (10),
last_name VARCHAR2 (50).
first name VARCHAR2 (50).
middle_name VARCHAR2 (50).
contact contact_t)
VIEW to CREATE or REPLACE students_t students_view
WITH the OBJECT IDENTIFIER (dcid) AS
Select decided,
ID,
last_name,
first name,
middle_name,
contact_t (dcid, contact_name, city, state, zip, email)
FROM MyTable
What exactly is the problem? Are you an error? An ORA-01730 by chance?
Use the default STUDENTS_T constructor in the query from the view:
VIEW to CREATE or REPLACE students_t students_view
WITH the OBJECT IDENTIFIER (dcid) AS
Select (students_t)
DECIDED
id
last_name
first name
middle_name
, contact_t (dcid, contact_name, city, state, zip, email)
)
FROM MyTable;
Then, for example:
SQL > select t.id
2, t.contact.contact_name
3, t.contact.city
4 t students_view;
ID CONTACT. CONTACT CONTACT_NAME. CITY
----------- -------------------------------------------------- --------------------------------------------------
1 TEST LA
Maybe you are looking for
-
When I try to print, I get a message to save the file as *.xps file, but Mozilla unresponsive when I try it. Can always print from other browsers.
-
where the wifi antenna is located on current iMac?
FAQ for USB 3 says do not locate external behind Mac hard drives because the Wi - Fi and Bluetooth antennas are located at the hinge of the screen. Where are the antennas on the iMac to 2015?
-
Satellite L500 - 20 X - switch WLAN does not work after upgrade to Windows 8
Hello I extend my Toshiba Satellite L500 - 20 X for Windows 8.Unfortunately, since this update my WLAN switch is no longer working. All function keys work only (switch WLAN) F8 to F7, and F9 (touchpad) is more work. What can I do? Thanks in advance.
-
HP Pavilion dv6 notebook intermittent failure of keyboard
I have a HP Pavilion dv6 notebook, 1 year old. Windows 7 Home Premium SP1, 8 GB of Ram. I have an external wired keyboard (Logitech K120) and a separate wireless mouse. Frequently in the past few weeks, I noticed that the keyboard will fail once t
-
I have the HP pavilion computer laptop windows 7 and I broke the screen about a year, I can't see the start menus. I have been using an external monitor and it has always worked well, but now I can't see how to fix my computer to boot. I did a hard