Home » SQL & PL/SQL » SQL & PL/SQL » UTL_TCP usage
UTL_TCP usage [message #39081] Thu, 13 June 2002 10:01 Go to next message
SAI PADMANABHAN
Messages: 3
Registered: June 2002
Junior Member
I have written a code which sends an string to a server and receives string back from that server, using UTL_TCP.It is successfully writing to the server and the other server also responds back, but my rpogram is not getting out of the loop or never quits.Hence i dont know if its reading properly or not.

can someone point out what the problem could be.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CREATE OR REPLACE
procedure comm(v_trans in varchar2,v_error in out varchar2,v_reply in out varchar2) is
c utl_tcp.connection;
v_out varchar2(2000);
v_write PLS_INTEGER:=0;
ret_val pls_integer;

BEGIN
c:= utl_tcp.open_connection('10.244.124.219',2000);
ret_val := utl_tcp.write_line(c, v_trans);
ret_val := utl_tcp.write_line(c);
BEGIN
LOOP
v_reply := utl_tcp.get_line(c, TRUE); -- read result
END LOOP;
EXCEPTION
WHEN utl_tcp.end_of_input THEN
NULL; -- end of input
END;
utl_tcp.close_connection(c);
exception
WHEN utl_tcp.end_of_input THEN
NULL; -- end of input
when others then
v_error := substr(SQLERRM,1,100);
END;
/
Re: UTL_TCP usage [message #39082 is a reply to message #39081] Thu, 13 June 2002 11:14 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
try this
CREATE OR REPLACE procedure comm
(	
v_trans in	varchar2,
v_error in out	varchar2,
v_reply in out	varchar2)
is
c	utl_tcp.connection;
v_out	varchar2(2000);
v_write PLS_INTEGER:=0;
ret_val pls_integer;
BEGIN
	BEGIN
	c := utl_tcp.open_connection('10.244.124.219',2000);
	ret_val := utl_tcp.write_line(c, v_trans);
	ret_val := utl_tcp.write_line(c);
	LOOP
		v_reply := utl_tcp.get_line(c, TRUE); -- read result
	END LOOP;
	EXCEPTION
		WHEN utl_tcp.end_of_input THEN
			NULL; -- end of input
			utl_tcp.close_connection(c);
		When others then
			v_error := substr(SQLERRM,1,100);
	end;
UTL_TCP.CLOSE_CONNECTION(c);
END;
/
Re: UTL_TCP usage [message #39114 is a reply to message #39081] Mon, 17 June 2002 13:52 Go to previous messageGo to next message
SAI PADMANABHAN
Messages: 3
Registered: June 2002
Junior Member
It did not work.
The utl_tcp.get_line function is looking for a carriage return or a line feed character and is not able to find it.
The string that i get from the other server does not have a carriage return and hence the program hangs there.
Any Suggestions?
Re: UTL_TCP usage [message #39130 is a reply to message #39114] Tue, 18 June 2002 14:22 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
can you post the error messages along with code?
Previous Topic: Best methode to cache data in packages?
Next Topic: Re: retrieving data from an OUT parameter
Goto Forum:
  


Current Time: Tue May 14 12:07:01 CDT 2024