Unix Technical Forum

How to Schedule Query Execution ?

This is a discussion on How to Schedule Query Execution ? within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Dear All, I have written a SQL Query for generating report. I want this query to get executed automatically ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 11:15 AM
Pankaj_Jha
 
Posts: n/a
Default How to Schedule Query Execution ?

Dear All,

I have written a SQL Query for generating report. I want this query to
get executed automatically every day at 9:00 AM. Suppose the query is
like this

Select e.empname, e.dept, s.basicsalary, s.hra, s.da, s.grosssalary
from employee e, salary s
where e.empid=s.empid

Can U tell me how to do this.

Thanks in advance

Pankaj Jha

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 11:15 AM
jonwat
 
Posts: n/a
Default Re: How to Schedule Query Execution ?


Pankaj_Jha wrote:
> Dear All,
>
> I have written a SQL Query for generating report. I want this query to
> get executed automatically every day at 9:00 AM. Suppose the query is
> like this
>
> Select e.empname, e.dept, s.basicsalary, s.hra, s.da, s.grosssalary
> from employee e, salary s
> where e.empid=s.empid
>
> Can U tell me how to do this.
>
> Thanks in advance
>
> Pankaj Jha


Check out:

http://asktom.oracle.com/pls/ask/f?p...A:633537913184

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 11:15 AM
Brian Peasland
 
Posts: n/a
Default Re: How to Schedule Query Execution ?

Pankaj_Jha wrote:
> Dear All,
>
> I have written a SQL Query for generating report. I want this query to
> get executed automatically every day at 9:00 AM. Suppose the query is
> like this
>
> Select e.empname, e.dept, s.basicsalary, s.hra, s.da, s.grosssalary
> from employee e, salary s
> where e.empid=s.empid
>
> Can U tell me how to do this.
>
> Thanks in advance
>
> Pankaj Jha
>


Which version of Oracle?

What do you want done with the output from the above?

Cheers,
Brian


--
================================================== =================

Brian Peasland
dba@nospam.peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-08-2008, 11:15 AM
oradbamohan@gmail.com
 
Posts: n/a
Default Re: How to Schedule Query Execution ?

Hi,

This query you can write in procedure like abcd. Then call the
procedure from sql prompt like this '


'sqlplus scott/tiger@oracle exec abcd'
exit;

The above code will be stored in like dos batch file .'xyz.bat' . The
xyz batch file can put it in a windows scheduler. When your time is
happend it will automaticall run the batch file in scheduler then you
proc also.

Thanks,

Mohan Reddy G

Pankaj_Jha wrote:
> Dear All,
>
> I have written a SQL Query for generating report. I want this query to
> get executed automatically every day at 9:00 AM. Suppose the query is
> like this
>
> Select e.empname, e.dept, s.basicsalary, s.hra, s.da, s.grosssalary
> from employee e, salary s
> where e.empid=s.empid
>
> Can U tell me how to do this.
>
> Thanks in advance
>
> Pankaj Jha


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-08-2008, 11:15 AM
Pankaj_Jha
 
Posts: n/a
Default Re: How to Schedule Query Execution ?


Brian Peasland wrote:

> Pankaj_Jha wrote:
> > Dear All,
> >
> > I have written a SQL Query for generating report. I want this query to
> > get executed automatically every day at 9:00 AM. Suppose the query is
> > like this
> >
> > Select e.empname, e.dept, s.basicsalary, s.hra, s.da, s.grosssalary
> > from employee e, salary s
> > where e.empid=s.empid
> >
> > Can U tell me how to do this.
> >
> > Thanks in advance
> >
> > Pankaj Jha
> >

>
> Which version of Oracle?
>
> What do you want done with the output from the above?
>
> Cheers,
> Brian
>
>
> --
> ================================================== =================
>
> Brian Peasland
> dba@nospam.peasland.net
> http://www.peasland.net
>
> Remove the "nospam." from the email address to email me.
>
>
> "I can give it to you cheap, quick, and good.
> Now pick two out of the three" - Unknown


================================================== ===========

Dear Brian

I am Using Oracle 10g client on my machine to connect with Oracle 10g
Server to connect with Server (Since Database is actually on Server).

Also i want the Out put of the query to be directed to a .xls or .txt
file.

Thanks

Pankaj Jha

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-08-2008, 11:15 AM
Pankaj_Jha
 
Posts: n/a
Default Re: How to Schedule Query Execution ?


oradbamohan@gmail.com wrote:

> Hi,
>
> This query you can write in procedure like abcd. Then call the
> procedure from sql prompt like this '
>
>
> 'sqlplus scott/tiger@oracle exec abcd'
> exit;
>
> The above code will be stored in like dos batch file .'xyz.bat' . The
> xyz batch file can put it in a windows scheduler. When your time is
> happend it will automaticall run the batch file in scheduler then you
> proc also.
>
> Thanks,
>
> Mohan Reddy G
>
> Pankaj_Jha wrote:
> > Dear All,
> >
> > I have written a SQL Query for generating report. I want this query to
> > get executed automatically every day at 9:00 AM. Suppose the query is
> > like this
> >
> > Select e.empname, e.dept, s.basicsalary, s.hra, s.da, s.grosssalary
> > from employee e, salary s
> > where e.empid=s.empid
> >
> > Can U tell me how to do this.
> >
> > Thanks in advance
> >
> > Pankaj Jha



================================================== =========

Hello Mohan

Can you show me this thruogh an example
What actually the Batch file should contain.

Suppose the
user name : abc
password : xyz
host string : pqr

and procedure name is empdetail


Thanks

Pankaj Jha

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-08-2008, 11:15 AM
Brian Peasland
 
Posts: n/a
Default Re: How to Schedule Query Execution ?

Pankaj_Jha wrote:
> Brian Peasland wrote:
>
>> Pankaj_Jha wrote:
>>> Dear All,
>>>
>>> I have written a SQL Query for generating report. I want this query to
>>> get executed automatically every day at 9:00 AM. Suppose the query is
>>> like this
>>>
>>> Select e.empname, e.dept, s.basicsalary, s.hra, s.da, s.grosssalary
>>> from employee e, salary s
>>> where e.empid=s.empid
>>>
>>> Can U tell me how to do this.
>>>
>>> Thanks in advance
>>>
>>> Pankaj Jha
>>>

>> Which version of Oracle?
>>
>> What do you want done with the output from the above?
>>
>> Cheers,
>> Brian
>>
>>
>> --
>> ================================================== =================
>>
>> Brian Peasland
>> dba@nospam.peasland.net
>> http://www.peasland.net
>>
>> Remove the "nospam." from the email address to email me.
>>
>>
>> "I can give it to you cheap, quick, and good.
>> Now pick two out of the three" - Unknown

>
> ================================================== ===========
>
> Dear Brian
>
> I am Using Oracle 10g client on my machine to connect with Oracle 10g
> Server to connect with Server (Since Database is actually on Server).
>
> Also i want the Out put of the query to be directed to a .xls or .txt
> file.
>
> Thanks
>
> Pankaj Jha
>


Put the following in a text file named my_script.sql:

spool c:\directory\my_output.txt
Select e.empname, e.dept, s.basicsalary, s.hra, s.da, s.grosssalary
from employee e, salary s
where e.empid=s.empid;
spool off
exit

Then create a batch file called my_sql.bat which contains:

set ORACLE_HOME=c:\oracle\10.2.0
sqlplus system/manager @my_output.txt

Schedule the batch file with your Windows scheduler.

You may have to make some substitutions to the above as I do not know
your directory structure. The above also assumes that you are running on
Windows. If using Unix/Linux, slight modifications will be needed.

An alternative, since you are using 10g, is to schedule the above with
DBMS_SCHEDULER.


HTH,
Brian



--
================================================== =================

Brian Peasland
dba@nospam.peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:30 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com