Create view from multiple days tables
Hi,
I'm having existing oracle db with daily stat data, tables strangely named data_mon, data_tue, data_wed.. For my batch processing I plan to use view with multiple day data, let say for last 5 days.
Not sure how better implement my sql statement, with those _mon suffixes to make it more or less dynamic.
I also never create View from multiple tables, so probably I can do something that will add fresh daily data and delete 5 days old data?
Will appreciate you comments on details and whole concept. I have prev sql server experience.
Thanks
T
user12943718 wrote:
Hi,
I'm having existing oracle db with daily stat data, tables strangely named data_mon, data_tue, data_wed.. For my batch processing I plan to use view with multiple day data, let say for last 5 days.
Not sure how better implement my sql statement, with those _mon suffixes to make it more or less dynamic.
I also never create View from multiple tables, so probably I can do something that will add fresh daily data and delete 5 days old data?
Will appreciate you comments on details and whole concept. I have prev sql server experience.
Thanks
TChange the data model so you don't have 1 table for a day.
You just have a DATA table, and a column to denote the day of applicability.
Then you don't need a view, don't need anything dynamic, don't need to smash your head against a wall for a simple query ... etc.
Similar Messages
-
Creat View from Multiple tables , Multiple Select
Hello Everyone ,
I have a question and am not sure if this the correct forum to post it .
I have two table studentTable and CourseTable which is each student take more than one course . 1:M
for example Student1 take 2 courses (C1 , C2).
Student2 take 3 courses (C1,C2, C3).
I need to create a table/View that contain student information plus all the courses and the score for each course in one row.
for example
Row1= Student1_Id ,C1_code ,C1_name ,C1_Score ,C2_code,C2_name ,C2_Score
Row2=
Student2_Id,C1_code, C1_name,C1_Score,C2_code ,C2_name ,C2_Score , C3_code,C3_name,C3_Score
and since Student 1 just took two courses , I should enter NULL in 'Course 3 fields'
My Struggle is in the insert statement
I tried the following but it show an error
Insert Into Newtable
( St_ID, C1_code,c1_name, C1_Score ,C2_code ,C2_name,C2_score,C3_code ,C3_name,C3_score)
Select
(Select St_ID from StudentTable)
(Select C_code,c_name,c_Score
from Coursetable,SudentTable
where course.Stid =Studet.stid)
(Select C_code,c_name,c_Score
from course ,student
where course.Stid =Studet.stid ),
(Select C_code,c_name,c_Score
from course ,student
where course.Stid =Studet.stid );
I'm fully aware that the New table will break the rules of normalization ,but I need it in this way for specifc purpose.
I tried also the PIVOT BY functionality but no luck with it .
FYI , I'm not expert in using SQL Syntax , I just know the basic.
I will be great full for any helpfull suggestions to try ,
thank you very much.First Table is Member table which Represent
Students Information
.The fields in this table are
member_sk (PrimaryKey), full_or_part_time, gender, age_at_entry, age_band_at_entry, disability, ethnicity,
widening_participation_level, nationality
Second Table is Modules table which include
the Courses' scores that Student took .
The fields in this table are
Module_result_k(Primary Key), member_sk(Foreign key to connect to Member table), member_stage_sk
,module_k(Foreign key to connect to Module table), module_confirmed_grade_src, credit_or_result
Third Table is
AllModuleInfo which is include
general information for each course .The fields in this table are
Module_k (Primary key), module_name ,module_code, Module_credit, Module stage.
The New table
that I will create has the following fields
member_sk (PrimaryKey), full_or_part_time, gender, age_at_entry, age_band_at_entry, disability, ethnicity,
widening_participation_level, nationality
" This will be retrieved from Member table"
Also will include
Module 1_name ,module1_code, Module1_credit, Module1_ stage, member1_stage_sk
, module1_confirmed_grade_src, credit1_or_result
Module 2_name ,module2_code, Module2_credit, Module2_ stage, member2_stage_sk
, module2_confirmed_grade_src, credit2_or_result
I will repeat this fields 14 times which is equal to Maximum courses number
that any of the students took.
//// I hope now my questions become more clear -
How to CREATE VIEW to merge two tables each of which has CLOB-typed column
I failed in creating a view to merge two tables that have CLOB-type column each.
The details are:
Database: Oracle 9i (9.2.0)
Two tables "test" and "test_bak", each of which has the following structure:
ID Number(10, 0)
DUMMY VARCHAR2(20)
DUMMYCLOB CLOB
The following operation fails:
create view dummyview (id, dummy, dummyclob) as
select id, dummy, dummyclob from test
union
select id, dummy, dummyclob from test_bak;
I was announced:
select test.id, test.dummy, test.dummyclob
ERROR in line 2:
ORA-00932: inconsistent data type: required - , but CLOB presented.
But if creating views from only ONE table with CLOB-type columns, or from two tables WITHOUT CLOB-typed columns, the creation will succeed. The following 1) and 2) will succeed, both:
1) one table, with CLOB-typed column
create view dummyview (id, dummy, dummyclob) as
select id, dummy, dummyclob from test;
2) two tables, without CLOB-typed columns
create view dummyview (id, dummy) as
select id, dummy from test
union
select id, dummy from test_bak;
I want to merge the two tables all, with complete columns, how to write the CREATE VIEW SQL statement?
many thanks in advanceDong Wenyu,
No.
But you could do this:
SELECT source.*, nvl (tab1.clob_column, tab2.clob_column)
FROM your_table1 tab1, your_table2 tab2, (
SELECT primary_key, ...
FROM your_table1
UNION
SELECT primary_key, ...
FROM your_table2
) source
WHERE source.primary_key = tab1.id (+)
AND source.primary_key = tab2.id (+)
In other words, do the set operation (UNION (ALL)/INTERSECT/MINUS) on just the PK columns before pulling in the LOB columns.
d. -
Hi,
I would like to create a view from 4 different tables. How do I do it?.
Say for example, I need user_id from table A which has the trans_id in table B and C. and I need to get a admin_id from table D and show these related fields in one single row . I'm trying to create a view to achieve this.
Pls help.
Thanks,
AnanthAre you asking how to write the SQL, or just how to define the view (which I guess is pretty much the same thing)?
-
How to setup Compressor to create video from multiple sequences within FCP?
I am wondering how I can set compressor up to create videos from multiple sequences within FCP. When I click file -> export - > compressor for a sequence and go into the program, it doesn't allow me to go back into FCP. I just get a spinning beach ball. Is there no way to set it up so I can prep a bunch of fcp sequences within compressor and then click submit and walk away? I have over 100 sequences that need to be exported so it would be a little difficult to do this one at a time. Thanks.
Batch processing
*Step one. Make sure everything in every sequence is rendered.*
*Step two. Make a folder somewhere and name it something relevant.*
*Step three. In FCP select all you sequences that you want to compress and right click (option), choose Batch Export from the contextual menu.*
*Step three point one. In the batch export window click on settings and choose the folder you made in step two for the destination. Make sure Make Self-Contained is not check and include Audio and Video.*
*Step four. Click export in the batch window.*
Once that is done you can close FCP.
Now in Compressor
*Step five. Make a setting that will give you the output that you want (mpeg2, AC3, h.264, whatever). Make a destination for where you want to save the output.*
*Step six. Make a droplet from the settings you made in step five.*
You can quit Compressor now.
*Step seven. Take the files that you batch exported from FCP in step three and four and drop them on the droplet you made in step six.*
o| TOnyTOny |o -
Query regarding the data type for fetcing records from multiple ODS tables
hey guys;
i have a query regarding the data type for fetcing records from multiple ODS tables.
if i have 2 table with a same column name then in the datatype under parent row node i cant add 2 nodes with the same name.
can any one help with some suggestion.Hi Mudit,
One option would be to go as mentioned by Padamja , prefxing the table name to the column name or another would be to use the AS keyoword in your SQL statement.
AS is used to rename the column name when data is being selected from your DB.
So, the query Select ename as empname from emptable will return the data with column name as empname.
Regards,
Bhavesh -
Getting Error ORA-00604 While Creating View from front Ent
Hello All,
I am getting ORA-00604 while creating view from the front end. And some time I get Maximum cursor open, It is ok amy be I am opening cursors in while loop. While ORA-00604 is giving lots of truble to me. In help it said to contact Oracle service, I dont know how to do that. Help me.Please post your view definition including the complete error_message and also the relevant parts of your code with the while loop.
-
Create XML (using DTD) from multiple relation tables
Hello and thank you in advanced.
I'm trying to create an XML document, based on a specific DTD, by selecting information from multiple tables in the database.
Is there a tool (in XDK maybe?) that will allow me to map my relational tables to a specific DTD?
I could build the XML manually, but I was hoping that Oracle has already solved this problem with an automated tool.
Thanks again,
Sean CloutierIs that the same thing as me writing an XSQL document which contains all of my queries (or views).
In other words, do I have to map everything by hand or is there a tool to do that for me?
thanks again,
Sean
null -
Creating an XML file from multiple sql tables
I have very little xml experience, but need to generate an xml file from multiple table. I know what the output needs to look like, but do not know how to setup the code. Any help would be appreciated.
- <Practice SourceID="EPIC" ExternalPracticeID="PPAWB">
- <Provider ExternalProviderID="TB2" FirstName="THOMAS G" LastName="BREWSTER">
- <Patient ExternalPatientID="99999" OldExternalPatID="" FirstName="test" MiddleName="J" LastName="test" Gender="M" DateOfBirth="2005-08-12" SocSecNumber="000-00-0000" LanguageID="22" AddressOne="test" AddressTwo="" City="test" StateID="20" ZipCode="99999" DayPhone="" EveningPhone="207-999-9999" StatusID="">
<Measure MeasureID="2" MeasureValue="5" MeasureDate="2008-10-24 13:43:00" />
<Measure MeasureID="2" MeasureValue="5" MeasureDate="2008-10-24 14:23:00" />
<Measure MeasureID="3" MeasureValue="1" MeasureDate="2008-10-24 13:43:00" />
<Measure MeasureID="3" MeasureValue="1" MeasureDate="2008-10-24 14:23:00" />
<Measure MeasureID="32" MeasureValue="3" MeasureDate="2008-10-24 13:51:00" />
<Measure MeasureID="33" MeasureValue="1" MeasureDate="2008-10-24 13:43:00" />
<Measure MeasureID="33" MeasureValue="1" MeasureDate="2009-02-09 10:09:00" />
<Measure MeasureID="4" MeasureValue="5" MeasureDate="2008-10-24 13:43:00" />
<Measure MeasureID="4" MeasureValue="5" MeasureDate="2008-10-24 14:23:00" />
<Measure MeasureID="40" MeasureValue="2008-10-24 13:43:00" MeasureDate="2008-10-24 13:43:00" />
<Measure MeasureID="40" MeasureValue="2008-10-24 14:23:00" MeasureDate="2008-10-24 14:23:00" />
<Measure MeasureID="41" MeasureValue="2008-10-24 13:43:00" MeasureDate="2008-10-24 13:43:00" />
<Measure MeasureID="41" MeasureValue="2008-10-24 13:51:00" MeasureDate="2008-10-24 13:51:00" />
</Patient>
</Provider>
</Practice>You are interested in XMLElement and probably XMLAgg. Since you didn't list a version, I can't provide links to the corresponding documentation. I cringe at all the attributes on the Patient element as that info should really be elements.
To create the Measure node, your overall SQL statement may look something like (not tested)
SELECT XMLElement....
XMLAgg(SELECT XMLElement
FROM measures_table
WHERE join condition to parent)
FROM patient,
provider,
practice
WHERE join conditionsFor additional help, please include your version (4 digits), some sample data, and what you have tried. -
How to create XMLTYPE View from the XMLType table
Hi:
I have a large XML file and inserted to the XMLTYPE table
For the XQUERY purpose I would like to create XMLView of the table.
The examples I got from Oracle to create XML view are for small files.
Can some one help me how to create XMLType VIEW for large XML Files ( 20,000 lines )?
Ali_2Have a look at the examples given on XMLType Views (based on relational tables) or standard views (based on XMLType storage) in the FAQ url located on the main page of this forum site regarding XMLDB.
-
Crate view from multiple tables in mysql
does anybody know what the correct syntax is?
I need to do the following:
create view myView as select * from tOne, tTwo, tThree;this does not work in mysql. How this can be done?
thanksYou need to be using a version of MySQl that supports views, 5.0 or greater. This SQL will tell you which version you are using:
SELECT version();The tables also need to exist prior to the creation of the view.
Otherwise, that syntax should work...
http://dev.mysql.com/doc/refman/5.0/en/create-view.html -
Create view structure based on table
Hi,
I've got two tables one spec table containing a table num, column name and column length. For example:
Table num Column name Column length
1 client_id 8
1 client_name 15
1 client_gender 1
2 order_num 4
2 order_date 8
...and one data table containing multiple records with table num and data for each table num defined in spec table. For example:
Table num Data
1 12345678Ben Anderson M
1 75486923Evy Jans F
2 123420/05/07
2 000117/04/07
...How can I create a script to create a view for table num '1' based on the strucure defined in the spec table and containing the data of table one that is stored in the data table?
Thanks.
Regards,
KenAssuming that the spec table has a column position column then given these tables:
SQL> SELECT * FROM tab_spec;
TAB_ID COL_NAME COL_LEN COL_POS
1 client_id 8 1
1 client_name 15 2
1 client_gender 1 3
2 order_num 4 1
2 order_date 8 2
SQL> SELECT * FROM tab_data;
TAB_ID DATA
1 12345678Ben Anderson M
1 75486923Evy Jans FA procedure along the lines of:
CREATE PROCEDURE make_view (p_tab_id IN NUMBER,
p_view_name IN VARCHAR2) AS
l_sql VARCHAR2(32767);
l_start NUMBER := 1;
BEGIN
l_sql := 'CREATE VIEW '||p_view_name||' AS SELECT ';
FOR r IN (SELECT col_name, col_len
FROM tab_spec
WHERE tab_id = p_tab_id
ORDER BY col_pos) LOOP
l_sql:= l_sql||'SUBSTR(data,'||l_start||', '||r.col_len||') '||
r.col_name||',';
l_start := l_start + r.col_len;
END LOOP;
l_sql := RTRIM(l_sql, ',')||' FROM tab_data WHERE tab_id = '||p_tab_id;
EXECUTE IMMEDIATE l_sql;
END;should do the trick. Note that the owner of the procedure will need to have the CREATE VIEW privilege granted directly and not through a role.
Having done this, I must reiterate what others have already said. This is a spectacularly bad idea. Rather than creating a view, I would change it to generate a CREATE TABLE statement to dump the data into proper tables.
John -
Creating pdf from multiple docs in PS8
i need to create a multi page PDF docs from multiple docs using photoshop elements 8. source docs will be other formats (e.g. MS WORD), but i could convert to pdf.
any help would be greatly appreciated.Yes you can open Writer (the word processing/text module) and use it like a blank word document. You can copy and paste from other sources, import image files, tables and objects and save as PDF.
This is how it looks:
Click to enlarge -
Create View from Database Links - Question
Question
I'm missing something simple.
I'm trying to create a view, from a Database Link.
CREATE VIEW view_name
AS SELECT a.*
FROM schema.tablename@dblink a;
When I run this in the SQL Commands window.
I get this error message.
ORA-00933: SQL command not properly ended
What am I missing? Any help is appreciated...<i>CREATE VIEW vw_name
AS SELECT a.*
FROM [email protected] a;
</i>
<br>
1) User (schema) which is creating view must have proper db_link to source database. For that try this for testing purpose:
select 1 from [email protected]<br>
If this fail then db_link is not ok! This step is absolute must to go any further step to!!!
<br>
2) when db_link is set, then your view should be named as:
CREATE VIEW vw_name
AS SELECT *
FROM <b>schema_name</b>.[email protected];<br>
please pay attention to "schema_name", because from remote side every table is in some schema so it really need declaration of owner schema.
<br>
Hope this helps... -
I need to create an "empty" view which would select from an user type. Is it possible?
I have:
create or replace TYPE my_type as object
my_col varchar2(13)
create or replace type my_type_array as table of my_type;
And I need something like:
create view my_view as select my_col from my_type_array where 1=2
I'm not selecting anything I just need an view to read names and types of my_type_array fields. Is it possible?If you just want to see the name and datatypes of your types attributes, just:
SQL> select attr_name
2 from DBA_TYPE_ATTRS
3 where type_name = 'MY_TYPE';
ATTR_NAME
MY_COL
1 row selected.
Maybe you are looking for
-
Backup Volume cannot be mounted
Time machine stopped working for me back in July. I've looked at every post and tried nearly everything, and I cannot get it working again. The error through the Time Machine pref pane is "The Backup volume cannot be mounted." The errors in the conso
-
Delete P.R.permanantly from the system
I s there any programme Or t-code available in sap mm that will delete the all the purchase requisitions (P.R) for selecting certain criteria. In other words,how to delete all the P.R. in sap mm with certain criteria so that they can not be displye
-
Screen detection in clamshell mode problems
I have a weird issue with clamshell mode in Lion 10.7.2 Hardware: MacBook Air 13" i5 1.7, Apple Cinema Display 30" connected with Apple Mini DisplayPort to Dual-Link DVI adapter. Normally I use the computer in clamshell mode, with the laptop lid clos
-
App updates in iTunes confusion
Whenever I open iTunes it always says under applications that I have updates but whenever I click on e.g. 9 updates available I'm told there are no updates!!! It's really annoying. Does anyone know why this is happening and how I can resolve it? Than
-
I forgot my admin password for my Macbook Pro OS X version 10.9, how can i recover it and reset my password? Thank you!