How to schedule a view in oracle
Hi,
I want to schedule a view(creating view) that runs everyday at 8'o clock in morning. how can i do this in oracle.
Thanks in advance
Hi
Sorry for last reply....!! Try like this....!!
create a procedure like this...
create or replace procedure dummy as
begin
execute immediate'create or replace view dummy1 as select * from emp';
end;Then create a job as .....
declare
vJobNumber binary_integer;
begin
dbms_job.submit(job => vJobNumber,next_date => sysdate,interval =>'trunc(SYSDATE+1)+8/24',
what => 'begin dummy; end;');
dbms_output.put_line('Job number assigned: ' || to_char(vJobNumber));
commit;
end;KPR
Edited by: KPR on Jul 9, 2011 11:47 AM
Similar Messages
-
Does any one know how to wrap a view in Oracle, I know it is not possible, yet. Are there any third party software to wrap the logic in the view.
Thanks,
SanjayYour best bet is to write a view that queries the source tables and contains any necessary business logic
CREATE VIEW VBASE AS SELECT A.COLUMN_A FROM TABLE_1 A, TABLE_2 B, TABLE_3 C WHERE A.ID = B.ID AND B.ID = C.ID;
create a view for exposure to the user that queries the base view.
CREATE VIEW VSECURE AS SELECT COLUMN_B FROM VBASE;
and grant privileges to VSECURE.
GRANT SELECT ON VSECURE TO SECURE_USER;
This will allow the user to see, query, and describe VSECURE without seeing the definition for VBASE.
The advantage of the this approach is that the query engine can still push predicates down into the base view to optimize the performance or the query where as this is limited with the pipeline function and can become a tuning headache.
eg.
SQL> -----------------------------------------
SQL> -- create some tables
SQL> -----------------------------------------
SQL> CREATE TABLE table_1(ID NUMBER, MESSAGE VARCHAR2(100))
Table created.
SQL> CREATE TABLE table_2(ID NUMBER, message2 VARCHAR2(100))
Table created.
SQL> CREATE TABLE table_3(ID NUMBER, message3 VARCHAR2(100))
Table created.
SQL> -----------------------------------------
SQL> -- populate tables with some data
SQL> -----------------------------------------
SQL> INSERT INTO table_1
SELECT ROWNUM,
CASE
WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'HELLO there joe'
ELSE 'goodbye joe'
END
FROM DUAL
CONNECT BY LEVEL < 1000000
999999 rows created.
SQL> INSERT INTO table_2
SELECT ROWNUM,
CASE
WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'how are you joe'
ELSE 'good to see you joe'
END
FROM DUAL
CONNECT BY LEVEL < 1000000
999999 rows created.
SQL> INSERT INTO table_3
SELECT ROWNUM,
CASE
WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'just some data'
ELSE 'other stuff'
END
FROM DUAL
CONNECT BY LEVEL < 1000000
999999 rows created.
SQL> -----------------------------------------
SQL> --create base view
SQL> -----------------------------------------
SQL> CREATE OR REPLACE VIEW vbase AS
SELECT a.MESSAGE,
c.message3
FROM table_1 a,
table_2 b,
table_3 c
WHERE a.ID = b.ID
AND b.ID = c.ID
View created.
SQL> -----------------------------------------
SQL> --create secure view using base view
SQL> -----------------------------------------
SQL> CREATE OR REPLACE VIEW vsecure AS
SELECT MESSAGE,
message3
FROM vbase
View created.
SQL> -----------------------------------------
SQL> -- create row type for pipeline function
SQL> -----------------------------------------
SQL> CREATE OR REPLACE TYPE vbase_row
AS OBJECT
message varchar2(100),
message3 varchar2(100)
Type created.
SQL> -----------------------------------------
SQL> -- create table type for pipeline function
SQL> -----------------------------------------
SQL> CREATE OR REPLACE TYPE vbase_table
AS TABLE OF vbase_row;
Type created.
SQL> -----------------------------------------
SQL> -- create package
SQL> -----------------------------------------
SQL> CREATE OR REPLACE PACKAGE pkg_getdata AS
FUNCTION f_get_vbase
RETURN vbase_table PIPELINED;
END;
Package created.
SQL> -----------------------------------------
SQL> -- create package body with pipeline function using same query as vbase
SQL> -----------------------------------------
SQL> CREATE OR REPLACE PACKAGE BODY pkg_getdata AS
FUNCTION f_get_vbase
RETURN vbase_table PIPELINED IS
CURSOR cur IS
SELECT a.MESSAGE,
c.message3
FROM table_1 a,
table_2 b,
table_3 c
WHERE a.ID = b.ID
AND b.ID = c.ID;
BEGIN
FOR rec IN cur
LOOP
PIPE ROW ( vbase_row ( rec.MESSAGE, rec.message3 ) );
END LOOP;
END;
END pkg_getdata;
Package body created.
SQL> -----------------------------------------
SQL> -- create secure view using pipeline function
SQL> -----------------------------------------
SQL> CREATE or replace VIEW vsecure_with_pipe AS
SELECT *
FROM TABLE ( pkg_getdata.f_get_vbase ( ) )
View created.
SQL> -----------------------------------------
SQL> -- this would grant select on the 2 views, one with nested view, one with nested pipeline function
SQL> -----------------------------------------
SQL> GRANT SELECT ON vsecure TO test_user
Grant complete.
SQL> GRANT SELECT ON vsecure_with_pipe TO test_user
Grant complete.
SQL> explain plan for
SELECT *
FROM vsecure
WHERE MESSAGE LIKE 'HELLO%'
Explain complete.
SQL> SELECT *
FROM TABLE ( DBMS_XPLAN.display ( ) )
PLAN_TABLE_OUTPUT
Plan hash value: 3905984671
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 16939 | 2365K| | 3098 (3)| 00:00:54 |
|* 1 | HASH JOIN | | 16939 | 2365K| 2120K| 3098 (3)| 00:00:54 |
|* 2 | HASH JOIN | | 24103 | 1835K| | 993 (5)| 00:00:18 |
|* 3 | TABLE ACCESS FULL| TABLE_1 | 24102 | 1529K| | 426 (5)| 00:00:08 |
| 4 | TABLE ACCESS FULL| TABLE_2 | 1175K| 14M| | 559 (3)| 00:00:10 |
| 5 | TABLE ACCESS FULL | TABLE_3 | 826K| 51M| | 415 (3)| 00:00:08 |
Predicate Information (identified by operation id):
1 - access("B"."ID"="C"."ID")
2 - access("A"."ID"="B"."ID")
3 - filter("A"."MESSAGE" LIKE 'HELLO%')
Note
PLAN_TABLE_OUTPUT
- dynamic sampling used for this statement
23 rows selected.
SQL> -----------------------------------------
SQL> -- note that the explain plan shows the predicate pushed down into the base view.
SQL> -----------------------------------------
SQL> explain plan for
SELECT count(*)
FROM vsecure_with_pipe
WHERE MESSAGE LIKE 'HELLO%'
Explain complete.
SQL> SELECT *
FROM TABLE ( DBMS_XPLAN.display ( ) )
PLAN_TABLE_OUTPUT
Plan hash value: 19045890
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 15 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 2 | | |
|* 2 | COLLECTION ITERATOR PICKLER FETCH| F_GET_VBASE | | | | |
Predicate Information (identified by operation id):
2 - filter(VALUE(KOKBF$) LIKE 'HELLO%')
14 rows selected.
SQL> -----------------------------------------
SQL> -- note that the filter is applied on the results of the pipeline function
SQL> -----------------------------------------
SQL> set timing on
SQL> SELECT count(*)
FROM vsecure
WHERE MESSAGE LIKE 'HELLO%'
COUNT(*)
19999
1 row selected.
Elapsed: 00:00:01.42
SQL> SELECT count(*)
FROM vsecure_with_pipe
WHERE MESSAGE LIKE 'HELLO%'
COUNT(*)
19999
1 row selected.
Elapsed: 00:00:04.11
SQL> -----------------------------------------
SQL> -- note the difference in the execution times.
SQL> ----------------------------------------- -
How to schedule jobs for brtools/oracle on EP
How to schedule jobs for brtools/oracle (Update statistics
Chech db
Db verify
) on an EP system where as no tool for java to do that (like db13). How to invoke it with cron?In Brtools you can always see the "Command line" before executing an action, You can simply copy that and use it to run BRTOOLS command from prompt, You can make a script with it and schedule via Cron.
Regards
Juan -
How to create a view with Oracle apps Org initialization ?
Hi,
How to create a view which needs Oracle apps org initialization to provide the correct data .
The purpose of the view is to be accessed in Primavera DB via a DB link for reporting purpose.
So how should the org be initialized so that the view returns the correct data when accessed from the remote data base using the DB link?
EX: step1 run fnd_client_info.set_org_context for the org
step2 query the veiw returns correct data in Oracle.
How can this be achieved if the view needs to be accessed via DB link?
sample view sql :
select po_header_id
from po_distributions_all pod
where (apps.po_intg_document_funds_grp.get_active_encumbrance_func
('PO',
pod.po_distribution_id
) <> 0
Thanks in advance!
DarshiniHi,
This is not possible in Oracle. What u can do is create the view without the where clasue and supply the where clause at runtime.
Hope this helps...
Regards,
Ganesh R -
How to schedule a JOB in oracle
hi experts,
i dont know why the following job has not run between the time from '25/MAR/2009 03:45 PM' to '25/MAR/2009 03:46 PM'.
i have kept the repeat_interval => 'FREQ=SECONDLY'. so i believe this job has to run 60 time, but its not running. please check this and guide me the right direction.
create table temp1(id number,value varchar2(25));
begin
dbms_scheduler.create_job(
job_name => 'SCHE_TEST'
,job_type => 'PLSQL_BLOCK'
,job_action => 'begin INSERT INTO temp1 VALUES (1, ''TEST'') end; '
,start_date => '25/MAR/2009 03:45 PM'
,end_date => '25/MAR/2009 03:46 PM'
,repeat_interval => 'FREQ=SECONDLY'
,enabled => TRUE
,comments => 'Demo for job schedule.');
end;
My ORACLE version is 10g
thanks
nidhi
Edited by: knidhi on Mar 25, 2009 4:21 PM
Edited by: knidhi on Mar 25, 2009 4:23 PMhi Keith,
it is working fine when i modified the code as follows
declare
l_start_date date := TO_date('30/MAR/2009 10:17:00',
'DD/MON/YYYY HH24:MI:SS');
l_end_date date := TO_date('30/MAR/2009 10:18:00',
'DD/MON/YYYY HH24:MI:SS');
begin
dbms_scheduler.create_job(
job_name => 'SCHE_TEST1'
,job_type => 'PLSQL_BLOCK'
,job_action => 'begin INSERT INTO temp1 VALUES (1, ''TEST''); commit; end; '
,start_date => l_start_date
,repeat_interval => 'FREQ=SECONDLY'
,end_date => l_end_date
,enabled => TRUE
,comments => 'Demo for job schedule.');
end;
thanks
Kalanidhi -
How to Register a View in Oracle Applications
Hi,
I have created a Custom View and want it to see it in one of the BPA Pages. For this purpose I shall need to register the view in Oracle Applications.
Can you please provide me clues to do so. I tried the Application Developer responsibility, there I can only query the view and not register them.
Also if I try using backend I could get hold of Package AD_DD which registers a table. Any clues for registering the View would be welcome.
ThanksThanks for your response.
Actually I need to show Sales Order Line No, Federal Id and a few other Fields on our Invoice. Now these are not available in Oracle Recievables view. So I was trying to create my own View.
I created a View in database. Now I am trying to create a Data source and associate this (custom created) View to it. However my View is not showing in the Views List of Values.
I am not sure whether I am doing it right. Can you please help me with this. Any pointers to a document which explains my requirement would be great.
Thanks
Sumit -
How to schedule dependent job in oracle
I would like to schedule a job which should be dependent on the completion of previous job. How is it achieved in oracle 10g
refer to this examples about DBMS_SCHEDULER.CREATE_CHAIN to form job dependency.
-
How to create sub views in Oracle SQL
I am trying to write a select statement through TOAD that needs to build a view and then query from that view further in the same statement. I don't mean create a VIEW in the common sense of running a CREATE VIEW command, I mean creating one dynamically within an SQL statement. Here's what I mean - in DB2 sql I can write the following:
WITH COUNT_NUM
COUNT_ADS
AS
(SELECT
COUNT(AD_ID)
FROM AD
WHERE CONTRACT_ID = '000234123'
SELECT * FROM COUNT_NUM;
Obviously this is a real simple example but you get the idea. Using this syntax you can create numerous sub-views to build data into your final select. My question is how to do this for Oracle. I have searched tons of help pages and sites but the only reference is to creating permanent views. I do not want to create temporary views either as I do not have adequate system permissions - I only want to create dynamic ones within my SQL.
Thanks in advance for any help!In Oracle, the equivalent concept is known as an in-line view. The Oracle version of your statement is:
SELECT *
FROM (SELECT COUNT(AD_ID) count_ads
FROM AD
WHERE CONTRACT_ID = '000234123')Essentially, you can use an in-line view anywhere you would use a "real" view or a table, so the follwoing is also possible:
SELECT a.contract_id, a.count_ads, b.count_pages
FROM (SELECT contract_id,ad_id,COUNT(*) count_ads
FROM ad
GROUP BY contract_id,ad_id) ads,
(SELECT ad_id,count(*) count_pages
FROM ad_pages
GROUP BY ad_id) ad_pages
WHERE ads.ad_id = ad_pages.ad_idHTH
John -
How to create materlised view in oracle 10g what are the step to create it
hi,
this hafeez i have a database in oracle 10g now i want to create materlised view to the database what arre the step required for it.You should refer to documentation for more information:
[Overview of Materialized Views|http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#CNCPT411]
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/] -
How to deal with views ?
Hello,
How to deal with views and Oracle Lite ?
Do I have to package views ? Of course, no updatable...
How do you manage to use views in your win32 app and Olite ?
ThanksI upgrade to 5.0.2.10.0, now I see a new tab in packager wizard where I can add views or indexes to application, but when connecting to import views, the wizard doesn't show views only indexes of the schema of my database...
Why ??? -
I have one package and in side that package i have 5 Procedure like
a;
b;
c;
I would like to run that Package every 2 hrs automatically , Please provide me the solution how to schedule this job ..and i would like to get the errors while executing those Procedures
thanks
MAASHHi,
You cannot run a package, you can only run a procedure in the package.
In Oracle 10g and up the recommended way to do this is using dbms_scheduler for example to run scott.pkg.a every two hours you would do
begin
dbms_scheduler.create_job('myjob',
job_type=>'plsql_block',
job_action=>'scott.pkg.a();',
repeat_interval=>'freq=hourly;interval=2;byminute=0',
enabled=>true);
end;
Errors and successful runs will be logged in all_scheduler_job_run_details.
For more info see the Scheduler documentation at
http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/scheduse.htm (examples)
http://st-doc.us.oracle.com/11/111/appdev.111/b28419/d_sched.htm (reference documentation)
There is also a dedicated forum for dbms_scheduler questions here
Scheduler
Hope this helps,
Ravi. -
How to maintain Entries for VIEWS in ORacle Sql developer
hi gurus,
Could you please help in maintaining an entries for VIEW is Oracle SQL develope...I have created a VIEW by name SD_WH08....now i need to maintain some entries in this for my testing purpose...how do i do this?
Your help is very much appreciated.
RegardsWhat do you mean by "maintaining an entries for VIEW" ?
K. -
How to Export Snapshots and Materlized View in Oracle 9i
Hi,
How to Export Snapshots and Materlized View in Oracle 9i .
I require to Migrate from 9i to 10g with either Export or Script.
Please helpUsing exp-imp for snapshots generally causes problems, at least for me. I would prefer taking their creation scripts and running them on the new database.
By the way, what do you mean by "migrate from 9i to 10g"? Are you trying to create the same snapshots in another (10g) database or are you trying to upgrade your 9i database to 10g? If it is the latter then you can just upgrade the database automatically with the upgrade assistant or manually using upgrade scripts. -
How to schedule jobs in Oracle?
Hello everyone,
Can you explain me how to schedule job in oracle?
I want to execute one stored procedure weekly. How would I schedule job to execute that procedure weekly?
Regards
SwatiSwati wrote:>
> Or can I schedule this job in oralce itself?
> Regards
Hi,
before 10g:
you may check the dbms_job package in ORACLE.
simply it can execute i.e. a procedure with a scheduled time pattern:
DBMS_JOB.SUBMIT (
job OUT BINARY_INTEGER,
what IN VARCHAR2,
next_date IN DATE DEFAULT sysdate,
interval IN VARCHAR2 DEFAULT 'null' );
example (the commit is important because without it no job will be started): weekly job at 9 a.m.
BEGIN
DECLARE
v_JobNum NUMBER;
BEGIN
DBMS_JOB.SUBMIT(v_JobNum,'your_proc;',sysdate,'trunc(sysdate)+7+9/24');
commit;
end;
END;
sysdate:
your date when to execute it
trunc(sysdate)79/24 :
execute the job weekly , reset to midnight , add 9 hours. the interval has to be set that way that you avoid a sliding job
10g and above:
you have a additional package dbms_scheduler (a more advanced implementation)
please check the documentation -
How to handle EXTENDED Views SQL 2000 to Oracle Migration
Hi All,
I am in the process of migrating SQL server 2000 database to Orcle databse. I would like to know how to handle the views created in SQL server with Extended clause.
See below for example for SQL 2000 view.
create view "Order Details Extended" AS
SELECT "Order Details".OrderID, "Order Details".ProductID, Products.ProductName,
"Order Details".UnitPrice, "Order Details".Quantity, "Order Details".Discount,
(CONVERT(money,("Order Details".UnitPrice*Quantity*(1-Discount)/100))*100) AS ExtendedPrice
FROM Products INNER JOIN "Order Details" ON Products.ProductID = "Order Details".ProductID
Thanks in advance for your reply.
RameshRamesh
The Workbench has a problem with spaces in identifiers which will be fixed in a later release.
Apart from that large drawback the view should work ok. [The parser handles convert and aliases]
Turloch
Maybe you are looking for
-
Scanning using LaserJet Pro M1217 nfw MFP
Product: HP LaserJet Pro M1217nfw MFP Mac OSX - Mountain Lion I would like to scan using this printer. I can not find a reliable method. Any suggestion?
-
HT204034 I am not able to use my State Band of India VISA credit card in itunes store?
Hi I want to change my payment information for that I'm putting my credit card details and submit but it says use valid payment method. While my Visa credit card is running n activated. On the other hand when i use another master card for that and it
-
Mouse will only click with the right button...
recently my macbook has decided that i dont need a right mouse button, and the touchpad is not responsive when clicking either. i have some suspicion that the trackpad button might be stuck. im also curious as to whether the usb's might be messed up.
-
I have been using flash player to watch foxnews and it has recently started reseting the volume to 0
I have been watching fox news .com using flash player and the web site is set for auto play. As it advances to the next news story the volume keeps being reset to zero at the start of each segment. This is very annoying since I must turn the volume u
-
Double drop down list on managing second list based on selection of first l
hello experts, I call the values into the two drop down list box through the database and now I want to manag second drop down list box based on the selection of first drop down list box. So how can I do it? Any suggestions, jsp code and ideas will b