Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

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
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old May 19th, 2003, 07:14 PM
alram1031 alram1031 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 13 alram1031 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question how to attach/load a file in Oracle Forms? pls help!

hi! i'm trying to attach an file (*.bmp, *.jpg, *.txt, etc.) to a form and then save it in my table, SIR. i can open the dialog box just fine (i used GET_FILE_NAME) .. but when i try to load the file, it takes forever (like it's not responding anymore) although the Task Manager says that it is still responding. that's the only part missing... i can save the other form details just fine.

i've tried the code below but realized that i don't think i need to create a batch file at all... so I have to start over.

can someone help me pls?


Note:
SIR_ATTACHMENT is also the textbox which will hold the filename.
SIR_ATTACHMENT is of LONG datatype.

/* WHEN-BUTTON-PRESSED trigger to load the file */
declare
p_username varchar2(100) := get_application_property(username);
p_password varchar2(100) := get_application_property(password);
p_connect varchar2(100);
p_userid varchar2(300) := null;
p_text varchar2(500) := null;
N_FILE text_io.file_type;
v_entity_dtl varchar2(50);
v_entity_dtl_file varchar2(100);
v_file varchar2(150);
batch_file varchar2(150);
b_file text_io.file_type;
v_table_name varchar2(40):= ‘SIR’;
v_columns varchar2(1000) := ‘SIR_ATTACHMENT’;

begin
tool_env.getvar('service_name' ,p_connect);

-- GET THE PATH
v_entity_dtl:= get_path(:SIR_ATTACHMENT);
v_entity_dtl_file :=get_filename(:SIR_ATTACHMENT);
v_file := v_entity_dtl||v_entity_dtl_file;
:MESSAGE := 'Please Wait...';

:GLOBAL.g_bad := v_entity_dtl||v_entity_dtl_file||'.bad';
:GLOBAL.g_log := v_entity_dtl||v_entity_dtl_file||'.log';

if :SIR_ATTACHMENT is null then
alert_msg('Invalid data file...','I',true );
end if;
n_file := TEXT_IO.FOPEN(:SIR_ATTACHMENT,'R');
if not text_io.is_open( n_file ) then
alert_msg('Source file not found...!!','I',true);
else
text_io.fclose( n_file );
end if;

-- CREATE A CONTROL FILE
n_file := TEXT_IO.FOPEN( v_file||'.ctl','W');

-- INSERT THE TEXT ENTRY TO THE CONTROL FILE
TEXT_IO.PUT_LINE( N_FILE ,'LOAD DATA' );
TEXT_IO.PUT_LINE( N_FILE ,'INFILE '||''''||:SIR_ATTACHMENT||'''');
TEXT_IO.PUT_LINE( N_FILE ,'APPEND'||' INTO TABLE '||v_table_name);
TEXT_IO.PUT_LINE( N_FILE ,'FIELDS TERMINATED BY '','' OPTIONALLY ENCLOSED BY ''"''
TRAILING NULLCOLS
('||v_columns||' )
');

if text_io.is_open( n_file ) then
TEXT_IO.FCLOSE(N_FILE);
end if;

-- USERID PARAMETER OF THE SQLLDR
p_userid := p_username || '/' || p_password || '@' || p_connect;

-- THE EXACT SQLLDR COMMAND INCLUDING THE PARAMETER
p_text := 'sqlldr userid=' || p_userid ||' control='||v_file||'.ctl '||'log='||v_file||'.log';

-- create a batch file here before a call by the host
b_file := TEXT_IO.FOPEN( v_file||'.bat','W');

-- INSERT THE TEXT COMMAND TO THE BATCH FILE
TEXT_IO.PUT_LINE( b_file ,'echo off' );
TEXT_IO.PUT_LINE( b_file ,p_text );
TEXT_IO.PUT_LINE( b_file ,'' );
TEXT_IO.PUT_LINE( b_file ,'echo ...............................................');
TEXT_IO.PUT_LINE( b_file ,'echo * *');
TEXT_IO.PUT_LINE( b_file ,'echo --- C L O S E T H I S W I N D O W N O W ---');
if text_io.is_open( b_file ) then
TEXT_IO.FCLOSE(b_file);
end if;
Set_application_property(Cursor_style,'BUSY');
batch_file := v_file||'.BAT';

-- EXECUTE THE BATCH FILE
host( batch_file,NO_SCREEN );

-- DELETE THE BATCH FILE
host( 'Del '||v_file||'.bat',NO_SCREEN );
if not form_success or form_fatal or form_failure then
Set_application_property(Cursor_style,'DEFAULT');
alert_msg('Errors occured during the process, pls. check all the recources..','I',true);
end if;


END;



i appreciate the help! thanks in advance!
Attached Images
File Type: jpg load.jpg (84.1 KB, 420 views)

Last edited by alram1031 : May 19th, 2003 at 07:18 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > how to attach/load a file in Oracle Forms? pls help!


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


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





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