Home » Other » Client Tools » Nightly utility to generate table for report (Windows)
Nightly utility to generate table for report [message #641429] |
Fri, 14 August 2015 12:18 |
|
tgatkins
Messages: 4 Registered: August 2015 Location: Huntsville
|
Junior Member |
|
|
Hi All-
It's been almost 20 years since I administered a database, so I need a kick-start.
I'm looking to develop a simple utility to run nightly at a specified time. It will select columns from tables (I know how to write SQL) and place them in a temporary table for reports.
I have a remote ODBC connection, and am using Windows.
What is the most straightforward tool / approach for this?
Thanks,
Tim Atkins
|
|
|
Re: Nightly utility to generate table for report [message #641431 is a reply to message #641429] |
Fri, 14 August 2015 12:27 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
Hi,
Welcome to the forum!
Please read and follow the OraFAQ Forum Guide and How to use [code] tags.
You can have a look at DBMS_SCHEDULER to schedule a job. Executing a sql script through DBMS_SCHEDULER in Windows is a bit tricky. See the following example as a start:
BEGIN
dbms_scheduler.create_job('MY_JOB',
job_action=>'C:\WINDOWS\SYSTEM32\CMD.EXE',
number_of_arguments=>3,
job_type=>'executable',
start_date => SYSTIMESTAMP,
repeat_interval => 'freq=hourly; byminute=0,30; bysecond=0;',
end_date => NULL,
enabled=> false);
dbms_scheduler.set_job_argument_value('MY_JOB',1,'/q');
dbms_scheduler.set_job_argument_value('MY_JOB',2,'/c');
dbms_scheduler.set_job_argument_value('MY_JOB',3,
'D:\SCRIPTS\my_sql.bat');
dbms_scheduler.enable('MY_JOB');
END;
/
Now your my_sql.bat would look like:
sqlplus user@sid/password @D:\scripts\script.sql
exit
Regards,
Lalit
|
|
|
|
Re: Nightly utility to generate table for report [message #641452 is a reply to message #641433] |
Sat, 15 August 2015 02:29 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Yet another option is to create an Apex (Application Express) application for the reporting purposes. As you already know how to use SQL, here's a short walkthrough: - download and install Oracle 11g Express Edition database. It already contains Apex 4.0 (unless I'm wrong); the most recent version is 5.0, but it doesn't really matter in this case. The above link contains version 5.0 so - if you want to bother, go on and install it AFTER you install 11g XE
- Both 11g XE and Apex are fre to use, even in production. You don't have to pay anything for any of those. Of course, there are some restrictions but I presume that - currently - they aren't significant.
- Apex is a GUI tool, used via internet browser, and lets you create a nice application in a matter of a few clicks. The Apex link also contains documentation. True, you'll need some time to create a workspace, developer (as an Apex "user") but it is all described in there. If you need assistance, say so.
- In Apex, you can create reports, where its "Interactive Reports" offer quite a lot of flexibility, even for end users.
- Furthermore, you can create graphs in a matter of a few clicks along with a simple SQL SELECT statement
- As it is Oracle, there will be no problem of connecting your XE with the database that contains data. If you forgot, it is the database link that you'll need
- It means that perhaps you don't even need a "job" which will populate some "temporary tables" (as your initial message suggests) - Apex can fetch those data directly.
That's - more or less - all I meant to say. Although it might sound complicated, it is a rather interesting idea. Don't just discard it, thing about Apex a minute or two.
|
|
|
|
|
|
|
|
|
Re: Nightly utility to generate table for report [message #641994 is a reply to message #641984] |
Fri, 28 August 2015 14:52 |
|
EdStevens
Messages: 1376 Registered: September 2013
|
Senior Member |
|
|
tgatkins wrote on Fri, 28 August 2015 13:14Thanks, Ed!
BTW, some more thoughts on the OTG subject.
As I said, the gateway can be installed on any server. It is just a switchboard. I have multiple oracle databases on multiple servers needing gateway services to connect to multiple non-oracle databases on multiple servers. So I really preferred that the GW be on a 'neutral' site. Since we are in all cases using the gateway for ODBC (rather than any of the db-specific gateways) it made sense to put it on a Windows server where ODBC was already configured. I chose to put it on the server that hosts most of our prod MSSQL databases, but again, that was for convenience, not any techinical requirement.
Second, you need to put some thought into what you name your db links when you create them in a specific oracle database. Suppose the target database was name sybprod (sybase, production) You might be tempted to name the link 'sybprod'. But if you were to refresh a test database with a backup of this, that test database would have the db link 'sybprod'. Is that really what you want? No, I prefer to give the db links a more generic name, specific enough to identify the db, but not committing to 'prod' vs 'test' (vs. 'dev', etc). That way the link and any code the references it remains environment neutral.
Third, and a continuation of the last point, when you create the db link you have a choice of hard-coding the entire address of the target db, or simply referencing a net service name (tnsnames.ora entry). For the same reasons mentioned above, it can be a pain to have that info replicated to another (test) database, carrying with it a 'commitment' to connect to a specific (production) database. To that end, I choose to reference a net service name that, in itself is not 'commiting' to prod/test/etc, and let that final resolution/commitment be made in the tnsnames.ora file. That way code/names/references inside the database (and thus replicated when the database is used as a base for refreshing other databases) remain 'neutral' and get resolved by a configuration file (tnsnames.ora) on whatever server the db is running on.
Of course, the above won't work if you have your prod and test databases running out of the same ORACL_HOME on the same server.
|
|
|
Goto Forum:
Current Time: Sat Dec 21 23:00:55 CST 2024
|