Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > what's wrong with my code? (Attaching an image)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-03, 00:49
alram alram is offline
Registered User
 
Join Date: May 2003
Posts: 15
Unhappy how to attach a file to Oracle Forms? pls help!

hi! i'm trying to attach an image/file to a form and then save it in my table. 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.

btw, i'm using Oracle Forms. my code:


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

/* 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(IR_ATTACHMENT);
v_entity_dtl_file :=get_filename(IR_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 IR_ATTACHMENT is null then
alert_msg('Invalid data file...','I',true );
end if;
n_file := TEXT_IO.FOPEN(IR_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 '||''''||IR_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!

Last edited by alram : 05-19-03 at 11:32.
Reply With Quote
  #2 (permalink)  
Old 05-19-03, 11:12
alram alram is offline
Registered User
 
Join Date: May 2003
Posts: 15
hmmm...

hmm.. i think my code is wrong because it creates a batch file.. and i don't need it.

can somebody pls help me figure out how to attach a file (*.bmp, *.jpg, etc.) to my form?

i included a picture of it... the Attach Sample opens the dialog box to include the file.. saving is easy because i can already save the rest of the form.

pls, pls, help?
Attached Images
File Type: jpg loadattachment.jpg (6.4 KB, 358 views)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On