|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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! Last edited by alram1031 : May 19th, 2003 at 07:18 PM. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > how to attach/load a file in Oracle Forms? pls help! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|