Home » Developer & Programmer » Forms » How to call bat file from Oracle Form
How to call bat file from Oracle Form [message #278015] Thu, 01 November 2007 08:02 Go to next message
realoneomer@gmail.com
Messages: 25
Registered: September 2007
Location: Islamabad
Junior Member
Hi Every One
Can some one tell me how to call batch file from Oracle froms 10g

Thanks

Omer Shahzad(realoneomer@gmail.com)

[Updated on: Thu, 01 November 2007 23:20]

Report message to a moderator

Re: How to call bat file from Oracle Form [message #278086 is a reply to message #278015] Thu, 01 November 2007 14:24 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Using the HOST built-in.
Re: How to call bat file from Oracle Form [message #278190 is a reply to message #278015] Fri, 02 November 2007 05:55 Go to previous messageGo to next message
athar.fitfd@hotmail.com
Messages: 193
Registered: October 2007
Location: pakistan
Senior Member
i think this will work

host('d:\filename.bat');

e.g.
Re: How to call bat file from Oracle Form [message #278209 is a reply to message #278190] Fri, 02 November 2007 06:51 Go to previous messageGo to next message
realoneomer@gmail.com
Messages: 25
Registered: September 2007
Location: Islamabad
Junior Member
Thanks alot
it is working

[Updated on: Fri, 02 November 2007 06:52]

Report message to a moderator

Re: How to call bat file from Oracle Form [message #546953 is a reply to message #278190] Sat, 10 March 2012 12:42 Go to previous messageGo to next message
laxminath
Messages: 14
Registered: March 2012
Location: calcutta
Junior Member
athar.fitfd@hotmail.com wrote on Fri, 02 November 2007 05:55
i think this will work

host('d:\filename.bat');

e.g.



Dear sir,
i am also facing this type of problem, my batch file is working properly by double clicking on batch file but when i am calling through Forms [32 Bit] Version 10.1.2.0.2(pc..Its deployed on web) it's not working


please help me
with warm regars
laxminath
Re: How to call bat file from Oracle Form [message #546955 is a reply to message #546953] Sat, 10 March 2012 12:50 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
CLIENT_HOST might be what you are looking for.
Re: How to call bat file from Oracle Form [message #546994 is a reply to message #546955] Sun, 11 March 2012 01:09 Go to previous messageGo to next message
laxminath
Messages: 14
Registered: March 2012
Location: calcutta
Junior Member
Dear sir i am using the same thing, but it's not working.
Re: How to call bat file from Oracle Form [message #547011 is a reply to message #546994] Sun, 11 March 2012 08:03 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
"It's not working" is less than descriptive. What did you exactly do? What is your environment (operating system version)? Where is the batch file located (local disk, application server)? How does your code look like? Where did you put it? What happened when you tested it? Did Oracle respond at all? If so, how? Any error? Which one?
Re: How to call bat file from Oracle Form [message #547065 is a reply to message #547011] Mon, 12 March 2012 02:41 Go to previous messageGo to next message
laxminath
Messages: 14
Registered: March 2012
Location: calcutta
Junior Member
dear sir ,
my system environment is-microsoft windows XP professional version 2002 service pack 2

my batch file located in E:\ drive(local Disk)

my batch file code is-D:\ORACLE\PRODUCT\10.2.0\DB_1\BIN\SQLLDR USERID=HRPAY/HRPAY@orcl CONTROL=E:\DEMO.CTL LOG=E:\DEMO.LOG

and my CTL & DAT filr also in E:\ drive(local disk)

my CTL file code is-
Load Data
INFILE 'E:\test.DAT'
INTO TABLE eatsm
truncate
fields terminated by "," optionally enclosed by ' " '
(VC_COMP_CODE CHAR(2),
VC_YEAR CHAR(4),
VC_MONTH CHAR(2),
VC_DT CHAR(2),
VC_CODE Char(2),
DT_MOD_DATE DATE "DD-MM-YYYY"
)


All it's working when i am double clicking on batch file but when i am trying to run this batch file through developer form 10g(oracle product 10.2.0) it's not working and not showing any error.

code in form- host('E:\MYBATCH.BAT');
please see also in attachment
  • Attachment: DEMO.CTL
    (Size: 0.24KB, Downloaded 1241 times)
Re: How to call bat file from Oracle Form [message #547096 is a reply to message #547065] Mon, 12 March 2012 04:50 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
Littefoot told you to use client_host.
Re: How to call bat file from Oracle Form [message #547130 is a reply to message #547096] Mon, 12 March 2012 08:34 Go to previous messageGo to next message
laxminath
Messages: 14
Registered: March 2012
Location: calcutta
Junior Member
thanx for replying me sir,

when i am using "client_host " instead of "host" , during the compilation of form it's showing error that-
"ora-01041 internal error hostdef extension doesn't exist."



with warm regards
laxminath
Re: How to call bat file from Oracle Form [message #547131 is a reply to message #547130] Mon, 12 March 2012 08:37 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
Sounds like there's something wrong with your forms setup:
01041, 00000, "internal error. hostdef extension doesn't exist"
// *Cause: Pointer to hstdef extension in hstdef is null.
// *Action: Report as a bug

I suggest you look the error up on My Oracle Support.
Re: How to call bat file from Oracle Form [message #547142 is a reply to message #547131] Wed, 12 March 2008 15:34 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
here is your solution enjoy

HOST('cmd /c start "" "c:\batchfilename.bat" scott/tiger@test""');





Cool
Re: How to call bat file from Oracle Form [message #547145 is a reply to message #547131] Wed, 12 March 2008 15:43 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member

here is your solution i think and can admin staff of this forum why my post is removed automatically


HOST('cmd /c start "" "c:\compile_all.bat " scott/tiger@test""');


CLIENT_HOST('cmd /c rundll32 url.dll,FileProtocolHandler C:\test.bat');





Thnaks
Re: How to call bat file from Oracle Form [message #547154 is a reply to message #547131] Mon, 12 March 2012 23:54 Go to previous messageGo to next message
laxminath
Messages: 14
Registered: March 2012
Location: calcutta
Junior Member
thank you for replaying me sir


Sir
can we direct insert the data without using batch file through the following code? -

HOST('D:\oracle\product\10.2.0\db_1\BIN\sqlldr USERID=HRPAY/HRPAY@ORCL CONTROL=E:\DEMO.CTL LOG=E:\DEMO.LOG');

above code is also not working sir and when i am using 'Client_Host' instead of 'Host' it's showing the same error (ora-201, identifier 'client_host' must be declared
Re: How to call bat file from Oracle Form [message #547221 is a reply to message #547154] Tue, 13 March 2012 06:40 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
i am using same thing with but its working fine here anyway try something else like



u can use either SQL Loader or external Tables. or u have to choosed SQL loader option and created a form along with a control file and batch file based.

Control File

LOAD DATA
INFILE 'D:\mughals\Pay\Clock Dump\CLK_050611\clock_dump.txt'
INTO TABLE ARS_CLOCK_DUMP
(TDATE	 POSITION(01:08) DATE 'YYYYMMDD',	
VER	 POSITION(09:10) CHAR,
EMPNO	 POSITION(11:15) CHAR,
TTIME	 POSITION(16:19) CHAR,
BRADD	 POSITION(21:22) CHAR
)



Batch file being called from the form

sqlldr userid=mughal/mughal@owais 
       ERRORS=500000  
       control=D:\mughals\Pay\Modified\Forms\ars_clock_dump.ctl
       log=D:\mughals\Pay\Modified\Forms\ars_clock_dump.log



and the above batch files is called from the form using

host('D:\mughals\Pay\Modified\Forms\load_data.bat',no_screen);



With above all the form works perfectly which is the development evironment and also client PC.

-------Other Solution-------when-button-pressed----------------

declare
 usid varchar2(10):= get_application_property(username);
 pwd  varchar2(10):= get_application_property(password);
 db   varchar2(10):= get_application_property(connect_string); 

begin

   v_ctl_file   := text_io.FOPEN(v_live_path||'ars_clock_dump.ctl', 'w'); 
   text_io.PUT_LINE (v_ctl_file, 'LOAD DATA'); 
   text_io.PUT_LINE (v_ctl_file, 'INFILE '''||v_live_path||'clock_dump.txt''');
   text_io.PUT_LINE (v_ctl_file, 'INTO TABLE ARS_CLOCK_DUMP');
   text_io.PUT_LINE (v_ctl_file, '(TDATE	 POSITION(01:08) DATE ''YYYYMMDD'',');
   text_io.PUT_LINE (v_ctl_file, 'VER	 POSITION(09:10) CHAR,');
   text_io.PUT_LINE (v_ctl_file, 'EMPNO	 POSITION(11:15) CHAR,');
   text_io.PUT_LINE (v_ctl_file, 'TTIME	 POSITION(16:19) CHAR,');
   text_io.PUT_LINE (v_ctl_file, 'BRADD	 POSITION(21:22) CHAR'); 
   text_io.PUT_LINE (v_ctl_file, ')'); 
   text_io.FCLOSE   (v_ctl_file); 
    
   v_bat_file   := text_io.FOPEN(v_live_path||'load_data.bat', 'w'); 
   text_io.PUT_LINE (v_bat_file, 'sqlldr userid  = '|| usid || '/' ||pwd || '@' ||db || ' ERRORS=1000000  control = '|| v_live_path||'ars_clock_dump.ctl log = '|| v_live_path||'ars_clock_dump.log'); 
   text_io.FCLOSE   (v_bat_file); 
		               
   host(v_live_path||'load_data.bat',no_screen);
		    
Exception when others then
        message(sqlerrm||dbms_error_text);
        message(' ');
end;      



Presently i am working on all these things which i given detail for u as above

hope it should work for u

Best regards
Re: How to call bat file from Oracle Form [message #547225 is a reply to message #547221] Tue, 13 March 2012 06:46 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
@mughals_king - host doesn't work in a three tire environment as it runs on the web-server not the client pc.
That's why we told the OP to use client_host instead.
Re: How to call bat file from Oracle Form [message #547245 is a reply to message #547225] Tue, 13 March 2012 09:35 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
Yes @cookiemonster you are right that's why i suggested him first regarding "clien_host" which i tried and its working fine i am also working on web envi.

CLIENT_HOST('cmd /c rundll32 url.dll,FileProtocolHandler C:\test.bat');


Thanks & Best Regards
Re: How to call bat file from Oracle Form [message #547876 is a reply to message #547225] Sat, 17 March 2012 12:45 Go to previous message
laxminath
Messages: 14
Registered: March 2012
Location: calcutta
Junior Member
thank you sir
Previous Topic: How to use same collection on two forms
Next Topic: Calling Reports from Oracle forms 10g
Goto Forum:
  


Current Time: Fri Jul 05 23:10:14 CDT 2024