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 AREA
9 selected lines.
SQL >
SY.
Tags: Database
Similar Questions
-
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. -
Create table works, create materialized view only - long column names?
Hello.
I have no probs creating a table as well: -.
CREATE TABLE blah
(
DEVICE_ID
)
in select
"Device_ID" AS DEVICE_ID
"of"sum" Device"@ed_link_3
where "Device_ID" < 5;
But when I try to create a materialized view:
Blah1 CREATE MATERIALIZED VIEW
(
DEVICE_ID
)
< various materialized view parms >
in select
"Device_ID" AS DEVICE_ID
"of"sum" Device"@ed_link_3
where "Device_ID" < 5;
It fails with errors: -.
ORA-04052: error occurred when searching to the top of the remote object Aggregate.Device@ED_LINK_3
ORA-01948: length of the name of the identifier (31) exceeds maximum (30)
Is there a way to get around this?
Is the problem with the columns of the remote table of device, which I do NOT need to import to have column names that are longer than 30 characters?
For now, I want only the Device_ID column which is a simple 9 characters long.
Oh, and the remote database is MySQL.
I'm uncomfortable with the < parms of materialized view > as they work fine when I choose a different remote table with only short column names.
Thank you.To my knowledge, you have the option
(a) create view (with shortened column names or only with desired columns if they are already less than 30 char limit) side of mysql
(b) use dbms_passthrough to force the analysis to be done on mysql (as in the example provided by SY here use dbms_passthrough to create a view )
However, I prefer to stick to one), because with dbms_passtrhough, you retrieve row by row.Best regards
Maxim
-
How to create a table with editable column values.
Hello world
I think it's very simple, but I am unable to find how to do this. This is my requirement. I need to create a table with n columns and 1 line initially. the user must be able to enter data into this table and click of a button must insert the data into the database table. Also, there should be a button at the bottom of the table to add 1 line to the table.
I know how to do the insertion of data, but can someone please let me know how to create a table which allows the user to enter data and how to create a line button Add 1?
Thanks in advance!Raghu,
Go through the tutorial of Toolbox Page & Advanced section of the Guide of the OFA table.
Step 1 - you need to create EO & VO from this EO. This EO will be table of database where you want to insert the data.
Step 2 - create an advanced table region. (See this section in table advanced for more details)
Step 3 - attach this VO in the BC4J region advanced Table component.
Kind regards
GYAN -
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 Table View with even a column name but another Table?
Hi all
I have the problem to create a tableview with the same column name, but in the other table.
Table I: -.
Table - PAC051MPROFORMA
Column - MNR, visitid
Table - PAC051TPROFORMA
Column - MNR, visitid
Table - PAC052MTRANSBILL
Column - MNR, visitid
Then, I want to create a table for this table. It comes to my SQL
Pacviewproforma CREATE VIEW (MNR, visitid, MNR, visitid, MNR, visitid)
Like some PAC051MPROFORMA.mrn, PAC051MPROFORMA.visitid, PAC051TPROFORMA.mrn, PAC051TPROFORMA.visitid, PAC052MTRANSBILL.mrn, PAC052MTRANSBILL.visitid
where
* (a.PAC051MPROFORMA.mrn = PAC051TPROFORMA.mrn) *.
and
* (a.PAC051TPROFORMA.mrn = PAC052TRANSBILL.mrn) *.
SQL return this error ORA-00957 =: duplicate column name
Can I change this SQL for
Pacviewproforma CREATE VIEW (MNR, visitid)
Like some PAC051MPROFORMA.mrn, PAC051MPROFORMA.visitid, PAC051TPROFORMA.mrn, PAC051TPROFORMA.visitid, PAC052MTRANSBILL.mrn, PAC052MTRANSBILL.visitid
where
* (a.PAC051MPROFORMA.mrn = PAC051TPROFORMA.mrn) *.
and
* (a.PAC051TPROFORMA.mrn = PAC052TRANSBILL.mrn) *.
This time this error return = ORA-01730: number of column names specified invalid
What should I do?
Thank you...Hello
SQL> CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid) 2 As Select 3 PAC051MPROFORMA.mrn, 4 PAC051MPROFORMA.visitid, 5 PAC051TPROFORMA.mrn, 6 PAC051TPROFORMA.visitid, 7 PAC052MTRANSBILL.mrn, 8 PAC052MTRANSBILL.visitid 9 from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL 10 where 11 (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn) 12 and 13 (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn); CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid) * ERROR at line 1: ORA-00957: duplicate column name
Please give different names to each column.
Something like that...
SQL> CREATE OR REPLACE VIEW pacviewproforma (MPROFORMA_mrn,MPROFORMA_visitid,TPROFORMA_mrn,TPROFORMA _visitid,MTRANSBILL_mrn,MTRANSBILL_visitid) 2 As Select 3 PAC051MPROFORMA.mrn, 4 PAC051MPROFORMA.visitid, 5 PAC051TPROFORMA.mrn, 6 PAC051TPROFORMA.visitid, 7 PAC052MTRANSBILL.mrn, 8 PAC052MTRANSBILL.visitid 9 from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL 10 where 11 (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn) 12 and 13 (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn); View created. SQL> DESC pacviewproforma; Name Null? Type ----------------------------------------- -------- ---------------------------- MPROFORMA_MRN NUMBER MPROFORMA_VISITID NUMBER TPROFORMA_MRN NUMBER TPROFORMA_VISITID NUMBER MTRANSBILL_MRN NUMBER MTRANSBILL_VISITID NUMBER
ORA-01730: number of column names specified invalid
The list of the nmae column you specified for the CREATE VIEW must correspond with the list of SELECTION in the view.
Twinkle
-
Create the view with the Unique ID column
I need to create a view.
The view is created using unions on 4 tables.
The problem is that I need to create a unique id column in the view that I use in an Oracle Apex application and need to drill down to each line.
Any help appreciated
GusYou cannot use oracle sequences directly in the query that is connected with other queries using Union or INTERSECT or less cluses.
Other cases where you cannot use a sequence are:
-In a WHERE clause
-In a GROUP BY or ORDER BY clause
-In a SEPARATE clause
-Along with a UNION or INTERSECT or LESS
-In a subqueryIn order to better you will love
Select seqname.nextval, col1, col2
Of
(
Union
..
..
)as mentioned in one of the previous answer by the other members of the community...
Alternatively, you can use rownum speed of sequence to a unique number as below examle:
Select rownum, col1, col2
Of
(
Union
..
..
)Kind regards
Lifexisxnotxsoxbeautiful... -
Create Materialized View ORA-01723: columns of length zero are not allowed
I am trying to create a materialized view that derives from a column of a function and I get: ORA-01723: columns null are not allowed.
I use 10 gr 2 with the following definition (simple version):
CREATE MATERIALIZED VIEW ACES
SELECT
function_name (column_name) alias_de_colonne
FROM table_name;
I even tried to cast it as below:
CREATE MATERIALIZED VIEW ACES
SELECT
Cast (function_name (column_name) AS VARCHAR2 (200)) alias_de_colonne
FROM table_name;
My function has an exception to return a value, even if no value are.
I looked everywhere for the solution. Someone at - there a way around this problem? I really need my function to calculate the column because it has business rules that I can't join in my definition of the materialized view. My only hope around this is to insert values into a table and then create a materialized table view, I don't want to do that if someone has a solution around this.
Any help would be greatly appreciated.
Thank you
Kyle
Published by: Kyle Miller on April 19, 2011 08:28Have you tried to create a table with the correct structure and then by creating the view materialized, based on the predefined table as described here...
http://www.oaktable.NET/content/ultra-fast-MV-alteration-using-prebuilt-table-option
?
See you soon
Ben
-
Create the view with the dynamic from clause
Hi all
you might have some ideas to help me out of my problem I just "created myself" ;-)
I have an unknown quantity and not constant of the tables using the same structure of the table and I have a main table
that contains all the names of these table types. Now, I want to create a unique view that contains all the columns in each table
and an extra column name containing the name of the corresponding table.
I found a solution for this but only if I knew that all the table names while creating my view.
Here is what I currently have:
master_table:
TABLENAME ID
1 table_01
2 table_02
table_01:
ID NAME
1 eins
zwei 2
drei 3
table_02:
ID NAME
1 a
2 two
3 three
I think 'tab1tab2' on these 2 table looks like this:
ID NAME TABLENAME
1 table_01 eins
2 zwei table_01
3 drei table_01
1 a table_02
2 two table_02
3 three table_02
I have reached this point of view with:
CREATE OR REPLACE VIEW TAB1TAB2 ('ID', 'NAME', 'TABLENAME')
AS
SELECT id, name, 'table_01' AS table_01 FROM tablename
UNION
SELECT id, name, 'table_02' AS tablename FROM table_02;
Is it possible to create as many select statements and union that I entered (tablenames) into my master_table to achieve the same results as my opinion hard?
Thank you very much in advance for your help
Best regards
Majocreate or replace view v_alltables
Select * from v_all;These two statement contradict each other in some way, Don't they?
path ID number name 'id', varchar2 (20) 'name' of the path) x;
the column names are case sensitive - try
id number path 'ID' , name varchar2(20) path 'NAME' ) x;
assuming that the names of the columns are named like that.
-
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
-
Syntax to create the view with 2 inline tables
Hello
If I run this SQL, I can compile a view without error:
CREATE OR REPLACE FORCE VIEW APPS.XX_TEST ( period_name , ytd ) AS with tbl_data AS ( SELECT '1314-03:OCT' period_name, -100 YTD FROM DUAL UNION ALL SELECT '1314-03:OCT' period_name, -1250 YTD FROM DUAL UNION ALL SELECT '1314-03:OCT' period_name, 10922 YTD FROM DUAL UNION ALL SELECT '1314-02:SEP' period_name, -100 YTD FROM DUAL UNION ALL SELECT '1314-01:AUG' period_name, 0 YTD FROM DUAL UNION ALL SELECT '1314-00:OBL' period_name, 0 YTD FROM DUAL UNION ALL SELECT '1213-14:CBL' period_name, -350 YTD FROM DUAL UNION ALL SELECT '1213-13:ADJ' period_name, -350 YTD FROM DUAL UNION ALL SELECT '1213-12:JUL' period_name, -100 YTD FROM DUAL ) SELECT period_name , ytd FROM tbl_data;
I need to create a view that includes the 2 tables inline (sorry if this is the incorrect terminology), using this SQL:
CREATE OR REPLACE FORCE VIEW APPS.XX_TEST2 ( period_name , ytd ) AS with tbl_data AS ( SELECT '1314-03:OCT' period_name, -100 YTD FROM DUAL UNION ALL SELECT '1314-03:OCT' period_name, -1250 YTD FROM DUAL UNION ALL SELECT '1314-03:OCT' period_name, 10922 YTD FROM DUAL UNION ALL SELECT '1314-02:SEP' period_name, -100 YTD FROM DUAL UNION ALL SELECT '1314-01:AUG' period_name, 0 YTD FROM DUAL UNION ALL SELECT '1314-00:OBL' period_name, 0 YTD FROM DUAL UNION ALL SELECT '1213-14:CBL' period_name, -350 YTD FROM DUAL UNION ALL SELECT '1213-13:ADJ' period_name, -350 YTD FROM DUAL UNION ALL SELECT '1213-12:JUL' period_name, -100 YTD FROM DUAL ), got_analytics AS ( SELECT period_name, ytd, ROW_NUMBER () OVER (ORDER BY period_name) AS a_num, ROW_NUMBER () OVER (ORDER BY period_name DESC) AS d_num, FIRST_VALUE (ytd) OVER (ORDER BY period_name) - FIRST_VALUE (ytd) OVER (ORDER BY period_name DESC) AS dif FROM tbl_data ) SELECT * FROM got_analytics;
I get this message:
ORA-24344: success with compilation error
There are no other errors but to provide additional information. I am using TOAD.
I was wondering if it is not possible to create a view in this way, or if I'm missing something?
I had a peek here:
ORA-24344: success with Compilation error
I'm using TOAD, trying to SHOW the ERRORS immediately after the code above only returned 'No Errors'.
I also looked here:
ORA-24344: success with compilation error
Ran the same code SQL/Plus, but "Show Errors" or "see the err" also returned "No. Errors."
Any advice would be much appreciated.
Thank you very much.
Hello
Try this
CREATE OR REPLACE FORCE VIEW APPS.XX_TEST2 ( period_name , ytd , a_num -- because you select * you need all rows , d_num , dif ) AS ...
concerning
Kay -
Definition of the erroneous view importing view with text column expression
Hello
I use SQL DM v 3.3.0.744.
When importing a view designer and the column has a column expression, a frowned upon request is created.
Example generated by the designer:
CREATE OR REPLACE FORCE VIEW VIEW6
+ (COL1) +.
AS SOME substr (col1, 55, 1)
OF TAB1 T1
The following text is generated by DM:
CREATE OR REPLACE VIEW VIEW6 (COL1)
IN SELECT
COL1 COL1;
The following remarks:
-l' column expression is not repeated.
-the underlying table/view is not included.
Can you trigger a bug for that?
JoopHi Joop,
Can you trigger a bug for that?
Our knowledge of the designer is limited, so it's better create you a service request and describe how you created this view and/or provide an example in the form of exported the repository designer example.
Maybe that's the best export to do as a text file.
The same applies for this Migration of Designer: bad alias for the table/view used in viewsPhilippe
-
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 "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 -
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.
Maybe you are looking for
-
Frequent Beachballing, crashing apps, system crash
Also, OS seems to "forget" that either the app should be used to open an MS Office document using Preview or Text edit instead. Report of audit of being: EtreCheck version: 3.0.3 (307) Report generated 2016-09-17 11:48:45 Download https://etrecheck.c
-
WRITE the Panel on Thunderbird v 31.3 flashes white to gray
I had all sorts of problems of password definition Thunderbird v 31.3 upward with an e-mail FS.NET account. Having finally reached so the emails I have a problem now with email addresses turning RED when he entered but especially WRITING Panel flashe
-
Cannot find my Satellite L655 - 149 Toshiba Middle site is
I bought the new laptop Satellite L655-149 with serial--> 8A450311Qmore information--> PSK1JE-05R00XAR before buying, I searched Toshiba Middle East and I found it, but now I can not find it and it cannot save in the Toshiba site... Please help me...
-
Why Firefox Sync is not protected by 2FA OTP?
There is no option to add 2FA to your sync account. So you can't log in to synchronize your information to a public computer without endangering your password and your account to full synchronization.
-
Alienware M17X r4 does not not the studio SB Tru at the beginning upward
I have a r4 Alienware M17X who just had replaced MB and when it starts, the sound is tinny and weak. The SB module with all controls as EQ and as such does not load at startup... but if I change the settings of the EQUALIZER it "snaps" and it starts