Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Import from text files and SQL*Loader

Posted on 2006-04-28
7
Medium Priority
?
985 Views
Last Modified: 2008-01-09
Hey,

I need to be able to import a text file into an Oracle database table every minute. Is it possible to automate this task using SQL*Loader from inside the Oracle database (via PL/SQL combined with DBMS_Scheduler) without using an OS-specific scheduler?

Cheers
0
Comment
Question by:Mus_Bak
5 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 16560296
Hello Mus_Bak,

create a job which to execute sqlloader (if you prefer it) or use DBMS_FILE pack to do it

HTH

I
0
 

Author Comment

by:Mus_Bak
ID: 16560669
Hello ivostoykov,

Allright, I'll try out your suggestions. I was under the impression that execution of sqllloader was not possible from inside the Oracle database. Do you have any idea as to how to execute sqlloader via scheduler? As far as I know sqlloader is not an intergrated part of Oracle database.
0
 
LVL 10

Expert Comment

by:ravindran_eee
ID: 16561055
U can write a small batch file/command file and make use of Windows scheduler to schedule the same..
0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 16561073
Hi Mus_Bak,

depends where in Oracle you are trying to, but generally you can using HOST command

regards

I
0
 
LVL 48

Accepted Solution

by:
schwertner earned 1000 total points
ID: 16561595
I think that the more flexible way is to use External tables that
can be selected as ordinary Oracle tables:

create directory med as 'c:\med' ; -- on main
GRANT READ  ON DIRECTORY med TO lsmedical;
GRANT WRITE ON DIRECTORY med TO lsmedical;



drop table lsmedical.USERMEDBASIC_EXT;
create table lsmedical.USERMEDBASIC_EXT (
                   PZN  VARCHAR2(33),
                   NAME VARCHAR2(111)   )
    organization external  
    (type oracle_loader  
     default directory med
     access parameters (records delimited by newline
     fields terminated by '|')
     location ('med-de-formatted.txt','med-de-insulin-formatted.txt',
               'med-us-formatted.txt','med-us-insulin-formatted.txt'));

After that you can schedule a stored procedure that can implement the
logics you need:

CREATE OR REPLACE PROCEDURE syncr IS
BEGIN
   .....
END syncr;


set serveroutput on
set linesize 10000
variable x number;
begin
   DBMS_OUTPUT.enable(100000);  
   dbms_job.submit(:x,'syncr;',trunc(sysdate),'trunc(sysdate+1/24/60)');
   commit;
   dbms_output.put_line(TO_char(:x));
end;
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to recover a database from a user managed backup
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question