Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old January 20th, 2004, 05:29 AM
dhingra dhingra is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 dhingra User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to dhingra
PL/SQL procedures and triggers

I have to create an empty file in one of the directories on unix server. This event should be triggered by a trigger attached to one table. So whenever there is an insert or update to that table it should invoke the trigger which should inturn create the blank file.
Can anyone help me out.... i am not very comfortable in PL/SQL.

Reply With Quote
  #2  
Old January 20th, 2004, 10:43 AM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
One option:
Create a java method that creates a directory.
Load this java file as a Java Stored Procedure
Create an ON UPDATE INSERT TRIGGER on this table that calls the java stored procedure passing the name of the new directory.
...
Another option using Oracle Pipes is discussed here:
http://www.oreview.com/9704flet.htm
__________________
El éxito consiste en una serie de pequeñas victorias día a día

MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html

Reply With Quote
  #3  
Old January 21st, 2004, 03:23 AM
dhingra dhingra is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 dhingra User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to dhingra
Hi Victor,

That is how its currently setup in my project except for that the directory is hardcoded in the java program. For some reason the java program is throwing an exception :

ORA-29532: Java call terminated by uncaught Java exception: java.lang.NullPointerException

ORA-04088: error during execution of trigger 'MAPPER.INSUPDACCTMONTHTRG'



Also can you explain how a compiled java class is loaded into oracle installed on a unix server.

Reply With Quote
  #4  
Old January 21st, 2004, 08:01 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
Still you have another option to do so. look at the following code:

DECALRE
v_file UTL_FILE.FILE_TYPE;
v_filename varchar2(40):='emp.log';
v_locat varchar2(200):='/orant/bin';
BEGIN
if utl_file.is_open(v_file) then
dbms_output.put_line('file opened');
else
dbms_output.put_line('file closed');
end if;
v_file:=SYS.UTL_FILE.FOPEN(v_locat,v_filename,'w');
UTL_FILE.FCLOSE(v_file);
dbms_output.put_line('File has been created');
EXCEPTION
when UTL_FILE.invalid_path then
raise_application_error(-2000, '****Exception caught : Invalid path defined');
when UTL_FILE.invalid_mode then
raise_application_error(-2001, '****Exception caught : Invalid mode');
END;
/

Before run the above code, Specify the accessible directories for the UTL_FILE functions in the initialization file using the UTL_FILE_DIR parameter. For example:

UTL_FILE_DIR = <directory name>

OR

UTL_FILE_DIR = *

'*' has a special meaning this entry turns off directory access checking, and it makes any directory accessible to the UTL_FILE functions.

Regards

Reply With Quote
  #5  
Old February 10th, 2004, 03:35 AM
dhingra dhingra is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 dhingra User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to dhingra
Hi Shafique,

I tried you suggestions and its working when i try to update the table in sqlplus.
However the same setup when tried through the toad tool or a GUI running on windows gives me the following error:

ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "SYS.UTL_FILE", line 101
ORA-06512: at "SYS.UTL_FILE", line 157
ORA-06512: at "ITSTMAPPER.TESTPROC", line 12
ORA-06512: at "ITSTMAPPER.TESTCTRIG", line 1
ORA-04088: error during execution of trigger 'ITSTMAPPER.TESTCTRIG'

Can you help me out.




Here is my procedure code:

CREATE OR REPLACE PROCEDURE testproc
IS
v_file UTL_FILE.FILE_TYPE;
v_filename varchar2(40):='emp.log';
v_locat varchar2(200):='/var/opt/intf/data/stage';
BEGIN
if UTL_FILE.is_open(v_file) then
dbms_output.put_line('file opened');
else
dbms_output.put_line('file closed');
end if;
v_file:=SYS.UTL_FILE.FOPEN(v_locat,v_filename,'w');
UTL_FILE.FCLOSE(v_file);
dbms_output.put_line('File has been created');
EXCEPTION
when UTL_FILE.invalid_path then
raise_application_error(-20000, '****Exception caught : Invalid path defined');
when UTL_FILE.invalid_mode then
raise_application_error(-20001, '****Exception caught : Invalid mode');
END;
/




Here is my trigger code:

CREATE OR REPLACE TRIGGER testctrig
AFTER UPDATE OR INSERT ON ControlData
FOR EACH ROW
CALL testproc
;

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > PL/SQL procedures and triggers


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway